From 935d846a3c59c8c38226c70b3d5e335f413fd264 Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Wed, 8 Nov 2023 12:56:35 +0100 Subject: [PATCH] update to monorepo & v1.1.0 (#621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - new monorepo structure in polkadot-sdk for substrate, cumulus and polkadot - new node binary setup in `node/src` , compatible with new basic collator - new collator impl in `cumulus/client/consensus/aura/src/collators/basic.rs` - mangata-node’s `Cargo.toml` alphabetic sorting - decoupling of concrete runtime types, eg. `type TokenId = u64`, from pallets - `try-runtime` is a standalone CLI tool now - `parachain-staking` pallet has been moved from moonbeam repo to mangata-node --- .dockerignore | 20 +- .github/workflows/reusable-build-and-test.yml | 29 +- .github/workflows/reusable-e2e-tests.yml | 14 +- .gitignore | 2 +- Cargo.lock | 6372 ++++++++++------- Cargo.toml | 1781 +---- README.md | 16 +- devops/helmfiles/config/fungible.yaml | 2 +- devops/parachain-launch/config.yml | 6 +- devops/parachain-launch/kusama-fast-oak.yml | 2 +- devops/parachain-launch/kusama-fast.yml | 2 +- devops/parachain-launch/mangata-karura.yml | 2 +- devops/parachain-launch/mangata-oak.yml | 2 +- devops/parachain-launch/multichain.yml | 2 +- devops/zombienet/mangata-local.toml | 18 +- devops/zombienet/oak-mangata-rococo.toml | 2 +- .../statemine_managata_rococo_local.toml | 2 +- docker-cargo.sh | 2 +- node/Cargo.toml | 255 +- node/bin/main.rs | 7 - .../{command_helper.rs => benchmarking.rs} | 34 +- node/src/chain_spec/mangata_kusama.rs | 115 +- node/src/chain_spec/mangata_rococo.rs | 106 +- node/src/chain_spec/mod.rs | 54 +- node/src/cli.rs | 118 +- node/src/client.rs | 389 - node/src/command.rs | 845 ++- node/src/lib.rs | 10 - node/src/main.rs | 32 + node/src/rpc.rs | 34 +- node/src/service.rs | 681 +- pallets/bootstrap/Cargo.toml | 90 +- pallets/bootstrap/src/benchmarking.rs | 92 +- pallets/bootstrap/src/lib.rs | 336 +- pallets/bootstrap/src/mock.rs | 154 +- pallets/bootstrap/src/tests.rs | 97 +- pallets/fee-lock/Cargo.toml | 71 +- pallets/fee-lock/src/benchmarking.rs | 52 +- pallets/fee-lock/src/lib.rs | 100 +- pallets/fee-lock/src/mock.rs | 100 +- pallets/fee-lock/src/tests.rs | 155 +- pallets/issuance/Cargo.toml | 69 +- pallets/issuance/src/benchmarking.rs | 17 +- pallets/issuance/src/lib.rs | 125 +- pallets/issuance/src/mock.rs | 50 +- pallets/issuance/src/tests.rs | 76 +- pallets/maintenance/Cargo.toml | 68 +- pallets/maintenance/src/lib.rs | 2 +- pallets/maintenance/src/mock.rs | 55 +- pallets/maintenance/src/tests.rs | 4 - pallets/multipurpose-liquidity/Cargo.toml | 83 +- .../src/benchmarking.rs | 68 +- pallets/multipurpose-liquidity/src/lib.rs | 277 +- pallets/multipurpose-liquidity/src/mock.rs | 202 +- pallets/multipurpose-liquidity/src/tests.rs | 420 +- pallets/parachain-staking/Cargo.toml | 68 + pallets/parachain-staking/README.md | 26 + pallets/parachain-staking/migrations.md | 42 + pallets/parachain-staking/src/benchmarks.rs | 1941 +++++ pallets/parachain-staking/src/lib.rs | 3549 +++++++++ pallets/parachain-staking/src/mock.rs | 662 ++ pallets/parachain-staking/src/set.rs | 89 + pallets/parachain-staking/src/tests.rs | 5086 +++++++++++++ pallets/parachain-staking/src/traits.rs | 43 + pallets/parachain-staking/src/types.rs | 1545 ++++ pallets/parachain-staking/src/weights.rs | 642 ++ pallets/proof-of-stake/Cargo.toml | 85 +- pallets/proof-of-stake/src/benchmarking.rs | 97 +- pallets/proof-of-stake/src/lib.rs | 158 +- pallets/proof-of-stake/src/mock.rs | 148 +- pallets/proof-of-stake/src/reward_info.rs | 55 +- pallets/proof-of-stake/src/tests.rs | 44 +- pallets/sudo-origin/Cargo.toml | 29 +- pallets/sudo-origin/src/mock.rs | 46 +- pallets/sudo-origin/src/tests.rs | 3 +- pallets/xyk/Cargo.toml | 93 +- pallets/xyk/rpc/Cargo.toml | 26 +- pallets/xyk/rpc/src/lib.rs | 31 +- pallets/xyk/runtime-api/Cargo.toml | 30 +- pallets/xyk/runtime-api/src/lib.rs | 5 +- pallets/xyk/src/benchmarking.rs | 357 +- pallets/xyk/src/lib.rs | 1314 ++-- pallets/xyk/src/mock.rs | 128 +- pallets/xyk/src/tests.rs | 55 +- rpc/nonce/Cargo.toml | 22 +- rpc/nonce/src/lib.rs | 2 +- runtime/common/Cargo.toml | 378 +- runtime/common/src/constants.rs | 3 +- runtime/common/src/lib.rs | 848 ++- runtime/common/src/migration.rs | 71 +- runtime/common/src/xcm_config.rs | 19 +- runtime/integration-test/Cargo.toml | 97 +- runtime/integration-test/src/bootstrap.rs | 11 +- runtime/integration-test/src/identity.rs | 1 - .../integration-test/src/proof_of_stake.rs | 2 +- runtime/integration-test/src/setup.rs | 26 +- .../src/xcm/kusama_xcm_transfer.rs | 18 +- runtime/integration-test/src/xcm/mod.rs | 12 +- runtime/integration-test/src/xyk.rs | 4 +- runtime/mangata-kusama/Cargo.toml | 365 +- runtime/mangata-kusama/src/lib.rs | 246 +- .../src/weights/frame_system.rs | 4 + runtime/mangata-kusama/src/xcm_config.rs | 20 +- runtime/mangata-rococo/Cargo.toml | 373 +- runtime/mangata-rococo/src/lib.rs | 314 +- .../src/weights/frame_system.rs | 4 + runtime/mangata-rococo/src/xcm_config.rs | 19 +- scripts/build-image.sh | 2 +- scripts/dev_manifest.sh | 4 +- scripts/run_benchmark.sh | 2 +- 110 files changed, 23163 insertions(+), 9820 deletions(-) delete mode 100644 node/bin/main.rs rename node/src/{command_helper.rs => benchmarking.rs} (83%) delete mode 100644 node/src/client.rs delete mode 100644 node/src/lib.rs create mode 100644 node/src/main.rs create mode 100644 pallets/parachain-staking/Cargo.toml create mode 100644 pallets/parachain-staking/README.md create mode 100644 pallets/parachain-staking/migrations.md create mode 100644 pallets/parachain-staking/src/benchmarks.rs create mode 100644 pallets/parachain-staking/src/lib.rs create mode 100644 pallets/parachain-staking/src/mock.rs create mode 100644 pallets/parachain-staking/src/set.rs create mode 100644 pallets/parachain-staking/src/tests.rs create mode 100644 pallets/parachain-staking/src/traits.rs create mode 100644 pallets/parachain-staking/src/types.rs create mode 100644 pallets/parachain-staking/src/weights.rs diff --git a/.dockerignore b/.dockerignore index 66662fa886..fafe5039bd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,18 +1,5 @@ -.git -.github -target -devops -!devops/dockerfiles/parachain-registrator/src -launch -scripts -workflows -Makefile -Tiltfile -**/target/ -**/*.txt -**/*.md -./docker-cargo -./mvr/docker-cargo +* + !/target/release/polkadot-collator !/docker-cargo/release/wbuild/mangata-kusama-runtime/mangata_kusama_runtime.compact.compressed.wasm !/docker-cargo/release/wbuild/mangata-kusama-runtime/mangata_kusama_runtime.compact.compressed.wasm.md5 @@ -38,6 +25,3 @@ Tiltfile !target/release/mangata-node !target/release/wbuild/mangata* - -# dotfiles in the repo root -/.* diff --git a/.github/workflows/reusable-build-and-test.yml b/.github/workflows/reusable-build-and-test.yml index 37c552f73f..63b1a0d4e2 100644 --- a/.github/workflows/reusable-build-and-test.yml +++ b/.github/workflows/reusable-build-and-test.yml @@ -13,7 +13,7 @@ on: required: true type: string builder_image: - default: mangatasolutions/node-builder:multi-nightly-2022-11-15 + default: mangatasolutions/node-builder:multi-nightly-2023-05-22 description: Docker image used for Rust builds required: false type: string @@ -249,11 +249,14 @@ jobs: ~/.cache/sccache key: cargo-try-runtime-${{ inputs.cache_version }}-${{ hashFiles('Cargo.lock') }} + - name: Build try-runtime Rococo & Kusama node + run: cargo build --release --features=try-runtime,mangata-rococo,mangata-kusama + - name: Run try-runtime Rococo testnet - run: cargo run --release --features=try-runtime,mangata-rococo try-runtime --chain=rococo --runtime=target/release/wbuild/mangata-rococo-runtime/mangata_rococo_runtime.wasm on-runtime-upgrade live --uri wss://collator-01-ws-rococo.mangata.online:443 + run: try-runtime --runtime=target/release/wbuild/mangata-rococo-runtime/mangata_rococo_runtime.wasm on-runtime-upgrade live --uri wss://collator-01-ws-rococo.mangata.online:443 - name: Run try-runtime Kusama Mainnet - run: cargo run --release --features=try-runtime try-runtime --chain=kusama --runtime=target/release/wbuild/mangata-kusama-runtime/mangata_kusama_runtime.wasm on-runtime-upgrade live --uri wss://kusama-rpc.mangata.online:443 + run: try-runtime --runtime=target/release/wbuild/mangata-kusama-runtime/mangata_kusama_runtime.wasm on-runtime-upgrade live --uri wss://kusama-rpc.mangata.online:443 run-benchmarks: name: Run runtime benchmarks @@ -296,7 +299,7 @@ jobs: run: | mkdir ./benchmarks && target/release/mangata-node benchmark pallet \ -l=info,xyk=error,collective-mangata=warn,bootstrap=warn \ - --chain kusama \ + --chain mangata-kusama \ --execution wasm \ --wasm-execution compiled \ --pallet '*' \ @@ -308,7 +311,7 @@ jobs: - name: Run block & extrinsic overhead benchmarks run: | - target/release/mangata-node benchmark overhead --execution native --chain kusama-local -lblock_builder=debug --max-ext-per-block 50000 --base-path . + target/release/mangata-node benchmark overhead --execution native --chain mangata-kusama-local -lblock_builder=debug --max-ext-per-block 50000 --base-path . cp block_weights.rs extrinsic_weights.rs ./benchmarks - name: Upload logs and docker images to GitHub @@ -351,12 +354,12 @@ jobs: - name: Export wasms run: | - /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=kusama -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=kusama -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=kusama-local -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=kusama-local -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=rococo -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=rococo -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=rococo-local -l=info,xyk=error > /dev/null' - /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=rococo-local -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=mangata-kusama -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=mangata-kusama -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=mangata-kusama-local -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=mangata-kusama-local -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=mangata-rococo -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=mangata-rococo -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-state --chain=mangata-rococo-local -l=info,xyk=error > /dev/null' + /bin/bash -c 'target/release/mangata-node export-genesis-wasm --chain=mangata-rococo-local -l=info,xyk=error > /dev/null' diff --git a/.github/workflows/reusable-e2e-tests.yml b/.github/workflows/reusable-e2e-tests.yml index 9d28f9392e..94cd0c4a0b 100644 --- a/.github/workflows/reusable-e2e-tests.yml +++ b/.github/workflows/reusable-e2e-tests.yml @@ -120,9 +120,9 @@ jobs: - command: "yarn test-experimentalStaking" fast: true - command: "yarn test-crowdloan" - fast: false + fast: false - command: "yarn test-sdk" - fast: true + fast: true runs-on: [e2e-gke] timeout-minutes: 180 env: @@ -196,6 +196,10 @@ jobs: working-directory: devops/parachain-launch run: npx @open-web3/parachain-launch generate config.yml + - name: Remove obsolete node run args from generated docker-compose.yml + working-directory: devops/parachain-launch/output + run: sed -i '/ws-external/d' docker-compose.yml + - run: docker ps --no-trunc - name: Start mangata-node parachain working-directory: devops/parachain-launch/output @@ -275,13 +279,13 @@ jobs: - name: Add GCP bucket URL link for stored node data on job failure if: failure() run: echo '[GCP Bucket link](https://console.cloud.google.com/storage/browser/mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }})' >> $GITHUB_STEP_SUMMARY - + - name: Stop previous parachain if running working-directory: devops/parachain-launch/output run: | docker kill $(docker ps -q) 2>/dev/null && echo $? docker-compose down -v - + test-complete: needs: [setup-report, e2e-test-matrix] if: always() @@ -299,7 +303,7 @@ jobs: TESTMO_URL: ${{ secrets.TESTMO_URL }} TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} continue-on-error: true - + slack-notify-nook: needs: [e2e-test-matrix] if: failure() diff --git a/.gitignore b/.gitignore index 2c07997c8b..aa0e128da1 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,4 @@ build_rs_cov.profraw .actrc # Ignore generated credentials from google-github-actions/auth -gha-creds-*.json \ No newline at end of file +gha-creds-*.json diff --git a/Cargo.lock b/Cargo.lock index d76e1b0f16..c71a2d1acf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,20 +14,20 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.26.2", + "gimli 0.27.3", ] [[package]] name = "addr2line" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.27.2", + "gimli 0.28.0", ] [[package]] @@ -90,9 +90,9 @@ dependencies = [ [[package]] name = "aes" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher 0.4.4", @@ -115,12 +115,12 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead 0.5.2", - "aes 0.8.2", + "aes 0.8.3", "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", @@ -149,44 +149,42 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.11", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", - "getrandom 0.2.9", + "getrandom 0.2.11", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] -name = "aho-corasick" -version = "1.0.1" +name = "allocator-api2" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" -dependencies = [ - "memchr", -] +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "always-assert" @@ -194,6 +192,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -214,30 +218,29 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -253,9 +256,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -263,9 +266,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "approx" @@ -289,6 +292,20 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "aquamarine" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df752953c49ce90719c7bf1fc587bc8227aed04732ea0c0f85e5397d7fdbd1a1" +dependencies = [ + "include_dir", + "itertools 0.10.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "arc-swap" version = "1.6.0" @@ -296,16 +313,195 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] -name = "array-bytes" -version = "4.2.0" +name = "ark-bls12-381" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381-bandersnatch" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cde0f2aa063a2a5c28d39b47761aa102bda7c13c84fc118a61b87c7b2f785c" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-scale" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b08346a3e38e2be792ef53ee168623c9244d968ff00cd70fb9932f6fe36393" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "parity-scale-codec", +] + +[[package]] +name = "ark-scale" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bd73bb6ddb72630987d37fa963e99196896c0d0ea81b7c894567e74a2f83af" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ark-secret-scalar" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "ark-transcript", + "digest 0.10.7", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "ark-transcript" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "digest 0.10.7", + "rand_core 0.6.4", + "sha3", +] [[package]] name = "array-bytes" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" +checksum = "de17a919934ad8c5cc99a1a74de4e2dab95d6121a8f27f94755ff525b630382c" [[package]] name = "arrayref" @@ -313,6 +509,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayvec" version = "0.5.2" @@ -321,9 +526,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -338,7 +543,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time", ] [[package]] @@ -354,7 +559,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time", ] [[package]] @@ -392,12 +597,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "asn1_der" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" - [[package]] name = "assert_matches" version = "1.5.0" @@ -406,73 +605,199 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] +[[package]] +name = "async-executor" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +dependencies = [ + "async-lock 2.8.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.1", + "futures-lite 1.13.0", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "blocking", + "futures-lite 1.13.0", +] + [[package]] name = "async-io" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", - "polling", - "rustix 0.37.19", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" +dependencies = [ + "async-lock 3.0.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.0.1", + "parking", + "polling 3.3.0", + "rustix 0.38.21", "slab", - "socket2", + "tracing", "waker-fn", + "windows-sys 0.48.0", ] [[package]] name = "async-lock" -version = "2.7.0" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "45e900cdcd39bb94a14487d3f7ef92ca222162e6c7c3fe7cb3550ea75fb486ed" dependencies = [ - "event-listener", + "event-listener 3.0.1", + "event-listener-strategy", + "pin-project-lite 0.2.13", ] +[[package]] +name = "async-net" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0434b1ed18ce1cf5769b8ac540e33f01fa9471058b5e89da9e06f3c882a8c12f" +dependencies = [ + "async-io 1.13.0", + "blocking", + "futures-lite 1.13.0", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if", + "event-listener 3.0.1", + "futures-lite 1.13.0", + "rustix 0.38.21", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "async-signal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +dependencies = [ + "async-io 2.2.0", + "async-lock 2.8.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 0.38.21", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-task" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" + [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "asynchronous-codec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] +[[package]] +name = "atomic-take" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" + [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atty" @@ -493,19 +818,41 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ - "addr2line 0.19.0", + "addr2line 0.21.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object 0.30.3", + "miniz_oxide", + "object 0.32.1", "rustc-demangle", ] +[[package]] +name = "bandersnatch_vrfs" +version = "0.0.1" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381-bandersnatch", + "ark-ff", + "ark-scale 0.0.11", + "ark-serialize", + "ark-std", + "dleq_vrf", + "fflonk", + "merlin 3.0.0", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "ring 0.1.0", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "base-x" version = "0.2.11" @@ -519,10 +866,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" [[package]] -name = "base58" +name = "base16ct" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -532,9 +879,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -554,20 +901,12 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", ] -[[package]] -name = "binary-merkle-tree" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" -dependencies = [ - "hash-db 0.16.0", -] - [[package]] name = "bincode" version = "1.3.3" @@ -579,30 +918,52 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.39", ] +[[package]] +name = "bip39" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" +dependencies = [ + "bitcoin_hashes", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bitvec" version = "1.0.1" @@ -624,40 +985,49 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq 0.1.5", +] + [[package]] name = "blake2b_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", - "arrayvec 0.7.2", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.3.0", ] [[package]] name = "blake2s_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" +checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", - "arrayvec 0.7.2", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.3.0", ] [[package]] name = "blake3" -version = "1.3.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq", - "digest 0.10.7", + "constant_time_eq 0.3.0", ] [[package]] @@ -715,11 +1085,27 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "blocking" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" +dependencies = [ + "async-channel", + "async-lock 2.8.0", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 1.13.0", + "piper", + "tracing", +] + [[package]] name = "bounded-collections" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07fbd1d11282a1eb134d3c3b7cf8ce213b5161c6e5f73fb1b98618482c606b64" +checksum = "ca548b6163b872067dc5eb82fd130c56881435e30367d2073594a3d9744120dd" dependencies = [ "log", "parity-scale-codec", @@ -742,6 +1128,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "0.2.17" @@ -750,14 +1145,14 @@ checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", - "regex-automata", + "regex-automata 0.1.10", ] [[package]] name = "bstr" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" dependencies = [ "memchr", "serde", @@ -774,9 +1169,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -792,21 +1187,21 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bzip2-sys" @@ -821,18 +1216,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" dependencies = [ "serde", ] @@ -845,7 +1240,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -853,11 +1248,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -882,9 +1278,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.10.3" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", ] @@ -913,6 +1309,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + [[package]] name = "chacha20poly1305" version = "0.9.1" @@ -920,36 +1327,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ "aead 0.4.3", - "chacha20", + "chacha20 0.8.2", "cipher 0.3.0", - "poly1305", + "poly1305 0.7.2", "zeroize", ] [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] name = "cid" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ed9c8b2d17acb8110c46f1da5bf4a696d745e1474a16db0cd2b49cd0249bf2" +checksum = "b9b68e3193982cd54187d71afdb2a271ad4cf8af157858e9cb911b91321de143" dependencies = [ "core2", "multibase", - "multihash 0.16.3", + "multihash", "serde", "unsigned-varint", ] @@ -1004,51 +1410,49 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] [[package]] name = "clap_derive" -version = "4.3.0" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "coarsetime" -version = "0.1.23" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a90d114103adbc625300f346d4d09dfb4ab1c4a8df6868435dd903392ecf4354" +checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" dependencies = [ "libc", "once_cell", @@ -1066,6 +1470,27 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color-print" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d" +dependencies = [ + "color-print-proc-macro", +] + +[[package]] +name = "color-print-proc-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e37866456a721d0a404439a1adae37a31be4e0055590d053dfe6981e05003f" +dependencies = [ + "nom", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -1074,15 +1499,35 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "6.1.4" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "fflonk", + "merlin 3.0.0", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "common-runtime" version = "4.0.0" @@ -1100,10 +1545,10 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "log", "mangata-support", "mangata-types", @@ -1141,7 +1586,7 @@ dependencies = [ "parachain-info", "parachain-staking", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", "scale-info", @@ -1161,20 +1606,20 @@ dependencies = [ "sp-ver", "sp-version", "sp-weights", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", "ver-api", - "xcm", - "xcm-builder", - "xcm-executor", "xyk-runtime-api", ] [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] @@ -1188,20 +1633,47 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", + "unicode-width", "windows-sys 0.45.0", ] [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "const-random" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.11", + "once_cell", + "tiny-keccak", +] [[package]] name = "constant_time_eq" -version = "0.2.5" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "convert_case" @@ -1255,37 +1727,36 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc42ba2e232e5b20ff7dc299a812d53337dadce9a7e39a238e6a5cb82d2e57b" +checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" +checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" dependencies = [ - "arrayvec 0.7.2", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli 0.26.2", - "hashbrown 0.12.3", + "gimli 0.27.3", + "hashbrown 0.13.2", "log", "regalloc2", "smallvec", @@ -1294,33 +1765,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f2154365e2bff1b1b8537a7181591fdff50d8e27fa6e40d5c69c3bad0ca7c8" +checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687e14e3f5775248930e0d5a84195abef8b829958e9794bf8d525104993612b4" +checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" [[package]] name = "cranelift-entity" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" +checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8483c2db6f45fe9ace984e5adc5d058102227e4c62e5aa2054e16b0275fd3a6e" +checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" dependencies = [ "cranelift-codegen", "log", @@ -1330,15 +1801,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9793158837678902446c411741d87b43f57dadfb944f2440db4287cda8cbd59" +checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" [[package]] name = "cranelift-native" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72668c7755f2b880665cb422c8ad2d56db58a88b9bebfef0b73edc2277c13c49" +checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" dependencies = [ "cranelift-codegen", "libc", @@ -1347,9 +1818,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.2" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852ce4b088b44ac4e29459573943009a70d1b192c8d77ef949b4e814f656fc1" +checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1372,9 +1843,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -1385,16 +1856,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1408,14 +1869,14 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset 0.9.0", "scopeguard", ] @@ -1431,9 +1892,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -1456,6 +1917,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1508,12 +1981,13 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "clap", "parity-scale-codec", "sc-chain-spec", "sc-cli", + "sc-client-api", "sc-service", "sp-core", "sp-runtime", @@ -1523,7 +1997,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -1546,18 +2020,29 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", + "cumulus-client-collator", "cumulus-client-consensus-common", + "cumulus-client-consensus-proposer", + "cumulus-primitives-aura", "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-interface", "futures", "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", "sc-client-api", "sc-consensus", "sc-consensus-aura", + "sc-consensus-babe", "sc-consensus-slots", "sc-telemetry", + "schnellru", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -1568,6 +2053,9 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-ver", "substrate-prometheus-endpoint", "tracing", ] @@ -1575,7 +2063,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-client-pov-recovery", @@ -1588,18 +2076,61 @@ dependencies = [ "polkadot-primitives", "sc-client-api", "sc-consensus", + "sc-consensus-babe", "schnellru", "sp-blockchain", "sp-consensus", + "sp-consensus-slots", + "sp-core", "sp-runtime", + "sp-timestamp", "sp-trie", + "substrate-prometheus-endpoint", + "tracing", +] + +[[package]] +name = "cumulus-client-consensus-proposer" +version = "0.1.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "anyhow", + "async-trait", + "cumulus-primitives-parachain-inherent", + "sp-consensus", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "thiserror", +] + +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", "tracing", ] [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1608,7 +2139,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-primitives", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "sc-client-api", "sp-blockchain", @@ -1622,7 +2153,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1646,7 +2177,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -1681,11 +2212,13 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "cumulus-pallet-parachain-system", "frame-support", "frame-system", "pallet-aura", + "pallet-timestamp", "parity-scale-codec", "scale-info", "sp-application-crypto", @@ -1697,7 +2230,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-dmp-queue" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1709,13 +2242,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", + "staging-xcm", ] [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -1728,7 +2261,7 @@ dependencies = [ "log", "mangata-support", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "scale-info", "sp-core", "sp-externalities", @@ -1739,24 +2272,25 @@ dependencies = [ "sp-std", "sp-trie", "sp-version", - "xcm", + "staging-xcm", + "trie-db", ] [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "cumulus-pallet-session-benchmarking" version = "3.0.0" -source = "git+https://github.com/mangata-finance/cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -1770,7 +2304,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1780,13 +2314,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", + "staging-xcm", ] [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -1801,30 +2335,45 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-executor", + "staging-xcm", + "staging-xcm-executor", +] + +[[package]] +name = "cumulus-primitives-aura" +version = "0.1.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-primitives", + "sp-api", + "sp-consensus-aura", + "sp-runtime", + "sp-std", ] [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", + "scale-info", "sp-api", "sp-runtime", "sp-std", "sp-trie", - "xcm", + "staging-xcm", ] [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1847,7 +2396,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "futures", @@ -1860,7 +2409,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1870,15 +2419,15 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", ] [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1886,7 +2435,6 @@ dependencies = [ "futures", "futures-timer", "polkadot-cli", - "polkadot-client", "polkadot-service", "sc-cli", "sc-client-api", @@ -1903,7 +2451,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1921,63 +2469,72 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 6.1.0", + "array-bytes", "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", "cumulus-relay-chain-rpc-interface", "futures", - "lru 0.9.0", + "polkadot-availability-recovery", + "polkadot-collator-protocol", "polkadot-core-primitives", "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-runtime-api", "polkadot-node-network-protocol", "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "polkadot-service", "sc-authority-discovery", - "sc-client-api", "sc-network", "sc-network-common", "sc-service", "sc-tracing", + "sc-utils", + "schnellru", "sp-api", - "sp-blockchain", "sp-consensus", "sp-consensus-babe", "sp-runtime", - "tokio", "tracing", ] [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", + "either", "futures", "futures-timer", "jsonrpsee", - "lru 0.9.0", "parity-scale-codec", + "pin-project", "polkadot-overseer", + "rand 0.8.5", "sc-client-api", "sc-rpc-api", "sc-service", + "schnellru", "serde", "serde_json", + "smoldot", + "smoldot-light", "sp-api", "sp-authority-discovery", "sp-consensus-babe", "sp-core", + "sp-runtime", "sp-state-machine", "sp-storage", + "thiserror", "tokio", + "tokio-util", "tracing", "url", ] @@ -1985,7 +2542,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1993,6 +2550,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-std", + "sp-trie", ] [[package]] @@ -2023,23 +2581,50 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", - "platforms 3.0.2", + "platforms", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "curve25519-dalek-ng" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.6.4", + "subtle-ng", + "zeroize", +] + [[package]] name = "cxx" -version = "1.0.94" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" dependencies = [ "cc", "cxxbridge-flags", @@ -2049,9 +2634,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.94" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" dependencies = [ "cc", "codespan-reporting", @@ -2059,24 +2644,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "cxxbridge-flags" -version = "1.0.94" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" [[package]] name = "cxxbridge-macro" -version = "1.0.94" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -2151,6 +2736,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "der-parser" version = "7.0.0" @@ -2179,6 +2774,15 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] + [[package]] name = "derivative" version = "2.2.0" @@ -2276,6 +2880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -2329,7 +2934,51 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", +] + +[[package]] +name = "dleq_vrf" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-scale 0.0.10", + "ark-secret-scalar", + "ark-serialize", + "ark-std", + "ark-transcript", + "arrayvec 0.7.4", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "docify" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4235e9b248e2ba4b92007fe9c646f3adf0ffde16dc74713eacc92b8bc58d8d2f" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47020e12d7c7505670d1363dd53d6c23724f71a90a3ae32ff8eba40de8404626" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.39", + "termcolor", + "toml 0.7.8", + "walkdir", ] [[package]] @@ -2346,9 +2995,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -2373,9 +3022,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" @@ -2383,10 +3032,24 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der 0.7.8", + "digest 0.10.7", + "elliptic-curve 0.13.6", + "rfc6979 0.4.0", + "signature 2.1.0", + "spki 0.7.2", ] [[package]] @@ -2395,7 +3058,17 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", ] [[package]] @@ -2405,13 +3078,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", - "ed25519", + "ed25519 1.5.3", "rand 0.7.3", - "serde", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.1.1", + "ed25519 2.2.3", + "rand_core 0.6.4", + "serde", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" @@ -2426,11 +3112,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" +dependencies = [ + "curve25519-dalek 4.1.1", + "ed25519 2.2.3", + "hashbrown 0.14.2", + "hex", + "rand_core 0.6.4", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" @@ -2438,18 +3139,37 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", "digest 0.10.7", - "ff", + "ff 0.12.1", "generic-array 0.14.7", - "group", + "group 0.12.1", "hkdf", "pem-rfc7468", - "pkcs8", + "pkcs8 0.9.0", "rand_core 0.6.4", - "sec1", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.3", + "digest 0.10.7", + "ff 0.13.0", + "generic-array 0.14.7", + "group 0.13.0", + "pkcs8 0.10.2", + "rand_core 0.6.4", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -2474,33 +3194,33 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041f5090df68b32bcd905365fd51769c8b9d553fe87fde0b683534f10c01bd2" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "enumn" -version = "0.1.8" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" +checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -2535,32 +3255,48 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ - "errno-dragonfly", "libc", "windows-sys 0.48.0", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "01cec0252c2afff729ee6f00e903d479fba81784c8e2bd77447673471fdfaea1" dependencies = [ - "cc", - "libc", + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", ] [[package]] -name = "event-listener" -version = "2.5.3" +name = "event-listener-strategy" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener 3.0.1", + "pin-project-lite 0.2.13", +] [[package]] name = "exit-future" @@ -2593,26 +3329,25 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 1.0.109", ] [[package]] name = "expander" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" dependencies = [ "blake2", "fs-err", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "extrinsic-shuffler" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "derive_more", "log", @@ -2646,6 +3381,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "fatality" version = "0.0.6" @@ -2663,7 +3404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5aa1e3ae159e592ad222dc90c5acbad632b527779ba88486abe92782ab268bd" dependencies = [ "expander 0.0.4", - "indexmap", + "indexmap 1.9.3", "proc-macro-crate", "proc-macro2", "quote", @@ -2690,11 +3431,34 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fflonk" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#e141d4b6f42fb481aefe1b479788694945b6940d" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "merlin 3.0.0", +] + [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" [[package]] name = "file-per-thread-logger" @@ -2708,13 +3472,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -2754,13 +3518,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2781,16 +3545,16 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", ] [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2804,12 +3568,11 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-support-procedural", "frame-system", - "futures", "linregress", "log", "parity-scale-codec", @@ -2830,10 +3593,10 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "Inflector", - "array-bytes 4.2.0", + "array-bytes", "chrono", "clap", "comfy-table", @@ -2869,12 +3632,13 @@ dependencies = [ "sp-database", "sp-externalities", "sp-inherents", + "sp-io", "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-std", "sp-storage", "sp-trie", + "sp-wasm-interface", "thiserror", "thousands", "ver-api", @@ -2883,18 +3647,18 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2911,18 +3675,18 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "aquamarine", + "aquamarine 0.1.12", "extrinsic-shuffler", "frame-support", "frame-system", "frame-try-runtime", "log", - "merlin", + "merlin 2.0.1", "parity-scale-codec", "scale-info", - "schnorrkel", + "schnorrkel 0.9.1", "sp-core", "sp-io", "sp-runtime", @@ -2932,9 +3696,9 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "15.1.0" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" +checksum = "87cf1549fba25a6fcac22785b61698317d958e96cac72a59102ea45b9ae64692" dependencies = [ "cfg-if", "parity-scale-codec", @@ -2945,95 +3709,112 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "async-recursion", "futures", + "indicatif", + "jsonrpsee", "log", "parity-scale-codec", "serde", "sp-core", "sp-io", "sp-runtime", + "sp-state-machine", + "spinners", "substrate-rpc-client", "tokio", + "tokio-retry", ] [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "bitflags", + "aquamarine 0.3.2", + "bitflags 1.3.2", + "docify", "environmental", "frame-metadata", "frame-support-procedural", "impl-trait-for-tuples", "k256", "log", + "macro_magic", "mangata-types", - "once_cell", "parity-scale-codec", "paste", "scale-info", "serde", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", + "sp-debug-derive", + "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-staking", "sp-state-machine", "sp-std", "sp-tracing", "sp-weights", + "static_assertions", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", + "expander 2.0.0", "frame-support-procedural-tools", "itertools 0.10.5", + "macro_magic", + "proc-macro-warning", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "cfg-if", "extrinsic-shuffler", "frame-support", "log", @@ -3052,22 +3833,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "frame-system-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -3082,7 +3848,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "sp-api", @@ -3091,7 +3857,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "parity-scale-codec", @@ -3118,11 +3884,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f5b6908aecca5812a4569056285e58c666588c9573ee59765bf1d3692699e2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.19", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -3134,9 +3900,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -3149,9 +3915,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -3159,15 +3925,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -3177,9 +3943,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -3187,24 +3953,34 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +dependencies = [ + "futures-core", + "pin-project-lite 0.2.13", +] + [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -3214,21 +3990,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "rustls 0.20.9", + "webpki 0.22.4", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -3238,9 +4014,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -3249,7 +4025,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "pin-utils", "slab", ] @@ -3280,6 +4056,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -3305,9 +4082,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -3331,25 +4108,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval 0.6.1", ] [[package]] name = "gimli" -version = "0.26.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] [[package]] name = "gimli" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glob" @@ -3359,12 +4136,12 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ - "aho-corasick 0.7.20", - "bstr 1.5.0", + "aho-corasick", + "bstr 1.7.0", "fnv", "log", "regex", @@ -3376,16 +4153,27 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ - "ff", + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", "rand_core 0.6.4", "subtle", ] [[package]] name = "h2" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -3393,7 +4181,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -3402,9 +4190,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.7" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" dependencies = [ "log", "pest", @@ -3414,12 +4202,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - [[package]] name = "hash-db" version = "0.16.0" @@ -3441,7 +4223,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -3450,7 +4232,18 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", +] + +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash 0.8.6", + "allocator-api2", + "serde", ] [[package]] @@ -3470,18 +4263,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -3495,6 +4279,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hkdf" version = "0.12.3" @@ -3544,6 +4334,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -3574,14 +4373,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -3591,9 +4390,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -3603,9 +4402,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -3617,8 +4416,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", - "socket2", + "pin-project-lite 0.2.13", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3627,31 +4426,33 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.2" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ + "futures-util", "http", "hyper", "log", - "rustls 0.20.8", + "rustls 0.21.8", "rustls-native-certs", "tokio", "tokio-rustls", + "webpki-roots 0.25.2", ] [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows 0.48.0", + "windows-core", ] [[package]] @@ -3682,9 +4483,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3702,11 +4503,11 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" +checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" dependencies = [ - "async-io", + "async-io 1.13.0", "core-foundation", "fnv", "futures", @@ -3716,7 +4517,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows 0.34.0", + "windows", ] [[package]] @@ -3748,6 +4549,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "include_dir" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -3759,6 +4579,35 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.2", +] + +[[package]] +name = "indexmap-nostd" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" + +[[package]] +name = "indicatif" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + [[package]] name = "inout" version = "0.1.3" @@ -3817,7 +4666,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.3", "libc", "windows-sys 0.48.0", ] @@ -3830,34 +4679,42 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", + "socket2 0.5.5", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] [[package]] name = "ipnet" -version = "2.7.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.19", + "hermit-abi 0.3.3", + "rustix 0.38.21", "windows-sys 0.48.0", ] +[[package]] +name = "is_executable" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9acdc6d67b75e626ad644734e8bc6df893d9cd2a834129065d3dd6158ea9c8" +dependencies = [ + "winapi", +] + [[package]] name = "itertools" version = "0.9.0" @@ -3876,37 +4733,47 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" dependencies = [ "jsonrpsee-core", + "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", "jsonrpsee-types", @@ -3916,9 +4783,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" dependencies = [ "futures-util", "http", @@ -3932,18 +4799,18 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.25.2", ] [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", - "arrayvec 0.7.2", - "async-lock", + "arrayvec 0.7.4", + "async-lock 2.8.0", "async-trait", "beef", "futures-channel", @@ -3963,11 +4830,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-http-client" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls", + "jsonrpsee-core", + "jsonrpsee-types", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "jsonrpsee-proc-macros" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c" +checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck", "proc-macro-crate", @@ -3978,9 +4864,9 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb69dad85df79527c019659a992498d03f8495390496da2f07e6c24c2b356fc" +checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", @@ -4000,9 +4886,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" dependencies = [ "anyhow", "beef", @@ -4014,9 +4900,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b83daeecfc6517cfe210df24e570fb06213533dfb990318fae781f4c7119dd9" +checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" dependencies = [ "http", "jsonrpsee-client-transport", @@ -4026,14 +4912,15 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", + "ecdsa 0.16.8", + "elliptic-curve 0.13.6", + "once_cell", + "sha2 0.10.8", ] [[package]] @@ -4045,108 +4932,10 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "kusama-runtime" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "kusama-runtime-constants", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-conviction-voting", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-multisig", - "pallet-nis", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-ranked-collective", - "pallet-recovery", - "pallet-referenda", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-society", - "pallet-staking", - "pallet-staking-runtime-api", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-whitelist", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "static_assertions", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "kusama-runtime-constants" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "polkadot-primitives", @@ -4178,9 +4967,9 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2182b8219fee6bd83aacaab7344e840179ae079d5216aa4e249b4d704646a844" +checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", @@ -4190,6 +4979,17 @@ dependencies = [ "smallvec", ] +[[package]] +name = "landlock" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520baa32708c4e957d2fc3a186bc5bd8d26637c33137f399ddfc202adb240068" +dependencies = [ + "enumflags2", + "libc", + "thiserror", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -4204,9 +5004,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -4218,12 +5018,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libm" version = "0.2.1" @@ -4231,28 +5025,30 @@ source = "git+https://github.com/rust-lang/libm?rev=2f3fc968f43d345f9b449938d050 [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" -version = "0.50.1" +version = "0.51.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7b0104790be871edcf97db9bd2356604984e623a08d825c3f27852290266b8" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.9", + "getrandom 0.2.11", "instant", - "libp2p-core 0.38.0", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", "libp2p-dns", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", "libp2p-noise", "libp2p-ping", "libp2p-quic", @@ -4263,44 +5059,32 @@ dependencies = [ "libp2p-webrtc", "libp2p-websocket", "libp2p-yamux", - "multiaddr 0.16.0", - "parking_lot 0.12.1", + "multiaddr", "pin-project", - "smallvec", ] [[package]] -name = "libp2p-core" -version = "0.38.0" +name = "libp2p-allow-block-list" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a8fcd392ff67af6cc3f03b1426c41f7f26b6b9aff2dc632c1c56dd649e571f" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "log", - "multiaddr 0.16.0", - "multihash 0.16.3", - "multistream-select", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "prost", - "prost-build", - "rand 0.8.5", - "rw-stream-sink", - "sec1", - "sha2 0.10.6", - "smallvec", - "thiserror", - "unsigned-varint", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", "void", - "zeroize", ] [[package]] @@ -4316,8 +5100,8 @@ dependencies = [ "instant", "libp2p-identity", "log", - "multiaddr 0.17.1", - "multihash 0.17.0", + "multiaddr", + "multihash", "multistream-select", "once_cell", "parking_lot 0.12.1", @@ -4333,12 +5117,12 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e42a271c1b49f789b92f7fc87749fa79ce5c7bdc88cbdfacb818a4bca47fec5" +checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" dependencies = [ "futures", - "libp2p-core 0.38.0", + "libp2p-core", "log", "parking_lot 0.12.1", "smallvec", @@ -4347,20 +5131,21 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c052d0026f4817b44869bfb6810f4e1112f43aec8553f2cb38881c524b563abf" +checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" dependencies = [ "asynchronous-codec", + "either", "futures", "futures-timer", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "lru 0.8.1", - "prost", - "prost-build", - "prost-codec", + "lru 0.10.1", + "quick-protobuf", + "quick-protobuf-codec", "smallvec", "thiserror", "void", @@ -4368,29 +5153,29 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ - "bs58", - "ed25519-dalek", + "bs58 0.4.0", + "ed25519-dalek 2.0.0", "log", - "multiaddr 0.17.1", - "multihash 0.17.0", + "multiaddr", + "multihash", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", "zeroize", ] [[package]] name = "libp2p-kad" -version = "0.42.1" +version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" +checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4398,13 +5183,13 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "smallvec", "thiserror", "uint", @@ -4414,19 +5199,20 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f378264aade9872d6ccd315c0accc18be3a35d15fc1b9c36e5b6f983b62b5b" +checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.10", "tokio", "trust-dns-proto", "void", @@ -4434,11 +5220,11 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad8a64f29da86005c86a4d2728b8a0719e9b192f4092b609fd8790acb9dec55" +checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ - "libp2p-core 0.38.0", + "libp2p-core", "libp2p-identify", "libp2p-kad", "libp2p-ping", @@ -4446,40 +5232,22 @@ dependencies = [ "prometheus-client", ] -[[package]] -name = "libp2p-mplex" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core 0.38.0", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "unsigned-varint", -] - [[package]] name = "libp2p-noise" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "log", "once_cell", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "snow", "static_assertions", "thiserror", @@ -4489,14 +5257,15 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929fcace45a112536e22b3dcfd4db538723ef9c3cb79f672b98be2cc8e25f37f" +checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" dependencies = [ + "either", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", "libp2p-swarm", "log", "rand 0.8.5", @@ -4505,70 +5274,68 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha" +version = "0.7.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" +checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-tls", "log", "parking_lot 0.12.1", "quinn-proto", "rand 0.8.5", - "rustls 0.20.8", + "rustls 0.20.9", "thiserror", "tokio", ] [[package]] name = "libp2p-request-response" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" +checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" dependencies = [ "async-trait", - "bytes", "futures", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", - "log", "rand 0.8.5", "smallvec", - "unsigned-varint", ] [[package]] name = "libp2p-swarm" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" dependencies = [ "either", "fnv", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm-derive", "log", - "pin-project", "rand 0.8.5", "smallvec", - "thiserror", "tokio", "void", ] [[package]] name = "libp2p-swarm-derive" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d527d5827582abd44a6d80c07ff8b50b4ee238a8979e05998474179e79dc400" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" dependencies = [ "heck", "quote", @@ -4577,17 +5344,17 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257baf6df8f2df39678b86c578961d48cc8b68642a12f0f763f56c8e5858d" +checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core 0.38.0", + "libp2p-core", "log", - "socket2", + "socket2 0.4.10", "tokio", ] @@ -4599,26 +5366,26 @@ checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.2", + "libp2p-core", "libp2p-identity", "rcgen 0.10.0", - "ring", - "rustls 0.20.8", + "ring 0.16.20", + "rustls 0.20.9", "thiserror", - "webpki 0.22.0", + "webpki 0.22.4", "x509-parser 0.14.0", "yasna", ] [[package]] name = "libp2p-wasm-ext" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb1a35299860e0d4b3c02a3e74e3b293ad35ae0cee8a056363b0c862d082069" +checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" dependencies = [ "futures", "js-sys", - "libp2p-core 0.38.0", + "libp2p-core", "parity-send-wrapper", "wasm-bindgen", "wasm-bindgen-futures", @@ -4626,9 +5393,9 @@ dependencies = [ [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha" +version = "0.4.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb6cd86dd68cba72308ea05de1cebf3ba0ae6e187c40548167955d4e3970f6a" +checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" dependencies = [ "async-trait", "asynchronous-codec", @@ -4637,13 +5404,13 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-noise", "log", - "multihash 0.16.3", - "prost", - "prost-build", - "prost-codec", + "multihash", + "quick-protobuf", + "quick-protobuf-codec", "rand 0.8.5", "rcgen 0.9.3", "serde", @@ -4657,42 +5424,52 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d705506030d5c0aaf2882437c70dab437605f21c5f9811978f694e6917a3b54" +checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.38.0", + "libp2p-core", "log", "parking_lot 0.12.1", "quicksink", "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] name = "libp2p-yamux" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f63594a0aa818642d9d4915c791945053877253f08a3626f13416b5cd928a29" +checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" dependencies = [ "futures", - "libp2p-core 0.38.0", + "libp2p-core", "log", - "parking_lot 0.12.1", "thiserror", "yamux", ] +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "librocksdb-sys" -version = "0.8.3+7.4.4" +version = "0.11.0+8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557b255ff04123fcc176162f56ed0c9cd42d8f357cf55b3fabeb60f7413741b3" +checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" dependencies = [ "bindgen", "bzip2-sys", @@ -4753,9 +5530,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.9" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "pkg-config", @@ -4764,9 +5541,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -4788,9 +5565,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -4807,11 +5584,17 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" + [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -4819,30 +5602,24 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] name = "lru" -version = "0.9.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" -dependencies = [ - "hashbrown 0.13.2", -] +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" [[package]] name = "lru-cache" @@ -4882,6 +5659,54 @@ dependencies = [ "libc", ] +[[package]] +name = "macro_magic" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aee866bfee30d2d7e83835a4574aad5b45adba4cc807f2a3bbba974e5d4383c9" +dependencies = [ + "macro_magic_core", + "macro_magic_macros", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e766a20fd9c72bab3e1e64ed63f36bd08410e75803813df210d1ce297d7ad00" +dependencies = [ + "const-random", + "derive-syn-parse", + "macro_magic_core_macros", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_core_macros" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "macro_magic_macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" +dependencies = [ + "macro_magic_core", + "quote", + "syn 2.0.39", +] + [[package]] name = "mangata-kusama-runtime" version = "4.0.0" @@ -4900,10 +5725,10 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "log", "mangata-support", "mangata-types", @@ -4916,6 +5741,7 @@ dependencies = [ "orml-xtokens", "pallet-aura", "pallet-authorship", + "pallet-balances", "pallet-bootstrap", "pallet-collective-mangata", "pallet-crowdloan-rewards", @@ -4940,7 +5766,7 @@ dependencies = [ "parachain-info", "parachain-staking", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", "scale-info", @@ -4956,95 +5782,73 @@ dependencies = [ "sp-runtime", "sp-session", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-ver", "sp-version", "sp-weights", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", "ver-api", - "xcm", - "xcm-builder", - "xcm-executor", "xyk-runtime-api", ] [[package]] name = "mangata-node" -version = "0.1.0" +version = "0.32.0" dependencies = [ - "cfg-if", "clap", + "color-print", "common-runtime", "cumulus-client-cli", + "cumulus-client-collator", "cumulus-client-consensus-aura", "cumulus-client-consensus-common", - "cumulus-client-network", + "cumulus-client-consensus-proposer", + "cumulus-client-consensus-relay-chain", "cumulus-client-service", - "cumulus-pallet-parachain-system", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-relay-chain-rpc-interface", - "cumulus-test-relay-sproof-builder", - "derive_more", - "extrinsic-shuffler", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", - "frame-system-rpc-runtime-api", "futures", "hex", - "hex-literal", "jsonrpsee", "log", "mangata-kusama-runtime", "mangata-rococo-runtime", - "mangata-rpc-nonce", - "mangata-types", - "pallet-timestamp", "pallet-transaction-payment-mangata", "pallet-transaction-payment-mangata-rpc", "parity-scale-codec", "polkadot-cli", - "polkadot-parachain", "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-service", - "polkadot-test-service", "sc-basic-authorship-ver", - "sc-block-builder-ver", "sc-chain-spec", "sc-cli", "sc-client-api", "sc-consensus", - "sc-consensus-aura", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", "sc-executor", - "sc-keystore", "sc-network", - "sc-network-bitswap", - "sc-network-common", - "sc-network-light", "sc-network-sync", + "sc-offchain", "sc-rpc", - "sc-rpc-api", "sc-service", "sc-sysinfo", "sc-telemetry", "sc-tracing", "sc-transaction-pool", "sc-transaction-pool-api", - "schnorrkel", "serde", + "serde_json", "sp-api", "sp-block-builder", "sp-blockchain", - "sp-consensus", "sp-consensus-aura", - "sp-consensus-slots", "sp-core", "sp-inherents", "sp-io", @@ -5053,17 +5857,14 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-storage", "sp-timestamp", - "sp-tracing", "sp-transaction-pool", - "sp-trie", "sp-ver", - "sub-tokens", + "staging-xcm", "substrate-build-script-utils", + "substrate-frame-rpc-system", "substrate-prometheus-endpoint", - "tokio", - "try-runtime-cli", + "tempfile", "ver-api", "xyk-rpc", "xyk-runtime-api", @@ -5087,10 +5888,10 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "log", "mangata-support", "mangata-types", @@ -5128,7 +5929,7 @@ dependencies = [ "parachain-info", "parachain-staking", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", "scale-info", @@ -5144,16 +5945,17 @@ dependencies = [ "sp-runtime", "sp-session", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-ver", "sp-version", "sp-weights", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", "ver-api", - "xcm", - "xcm-builder", - "xcm-executor", "xyk-runtime-api", ] @@ -5180,7 +5982,7 @@ dependencies = [ [[package]] name = "mangata-support" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "mangata-types", @@ -5193,7 +5995,7 @@ dependencies = [ [[package]] name = "mangata-types" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", @@ -5202,6 +6004,12 @@ dependencies = [ "sp-std", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "match_cfg" version = "0.1.0" @@ -5214,7 +6022,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -5225,9 +6033,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" dependencies = [ "autocfg", "rawpointer", @@ -5235,26 +6043,27 @@ dependencies = [ [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if", "digest 0.10.7", ] [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memfd" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.37.19", + "rustix 0.38.21", ] [[package]] @@ -5285,19 +6094,22 @@ dependencies = [ ] [[package]] -name = "memory-db" -version = "0.32.0" +name = "memoffset" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "hash-db 0.16.0", + "autocfg", ] [[package]] -name = "memory_units" -version = "0.4.0" +name = "memory-db" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +dependencies = [ + "hash-db", +] [[package]] name = "merlin" @@ -5311,6 +6123,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "mick-jaeger" version = "0.1.8" @@ -5328,15 +6152,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -5348,20 +6163,19 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", - "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "log", @@ -5373,7 +6187,6 @@ dependencies = [ "sp-consensus", "sp-consensus-beefy", "sp-core", - "sp-io", "sp-mmr-primitives", "sp-runtime", ] @@ -5381,7 +6194,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "anyhow", "jsonrpsee", @@ -5421,24 +6234,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "multiaddr" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aebdb21e90f81d13ed01dc84123320838e53963c2ca94b60b305d3fa64f31e" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "multibase", - "multihash 0.16.3", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - [[package]] name = "multiaddr" version = "0.17.1" @@ -5450,7 +6245,7 @@ dependencies = [ "data-encoding", "log", "multibase", - "multihash 0.17.0", + "multihash", "percent-encoding", "serde", "static_assertions", @@ -5471,9 +6266,9 @@ dependencies = [ [[package]] name = "multihash" -version = "0.16.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "blake2b_simd", "blake2s_simd", @@ -5481,22 +6276,11 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", "unsigned-varint", ] -[[package]] -name = "multihash" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" -dependencies = [ - "core2", - "multihash-derive", - "unsigned-varint", -] - [[package]] name = "multihash-derive" version = "0.8.0" @@ -5533,9 +6317,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.2" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ "approx", "matrixmultiply", @@ -5549,9 +6333,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", @@ -5592,7 +6376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -5645,12 +6429,24 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", ] +[[package]] +name = "no-std-net" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "nohash-hasher" version = "0.2.0" @@ -5675,9 +6471,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -5686,9 +6482,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -5699,7 +6495,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "itoa", ] @@ -5727,40 +6523,46 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.3", "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" -version = "0.29.0" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", - "hashbrown 0.12.3", - "indexmap", + "hashbrown 0.13.2", + "indexmap 1.9.3", "memchr", ] [[package]] name = "object" -version = "0.30.3" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -5785,9 +6587,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -5809,9 +6611,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "orchestra" -version = "0.2.1" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0766f60d83cac01c6e3f3bc36aaa9056e48bea0deddb98a8c74de6021f3061" +checksum = "227585216d05ba65c7ab0a0450a3cf2cbd81a98862a54c4df8e14d5ac6adb015" dependencies = [ "async-trait", "dyn-clonable", @@ -5826,12 +6628,11 @@ dependencies = [ [[package]] name = "orchestra-proc-macro" -version = "0.2.1" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8e83dbd049009426b445424a1104c78e6172a4c13e3614e52a38262785a5d7" +checksum = "2871aadd82a2c216ee68a69837a526dfe788ecbe74c4c5038a6acdbff6653066" dependencies = [ - "expander 1.0.0", - "indexmap", + "expander 0.0.6", "itertools 0.10.5", "petgraph", "proc-macro-crate", @@ -5852,37 +6653,40 @@ dependencies = [ [[package]] name = "orml-asset-registry" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "mangata-types", + "log", "orml-traits", "pallet-xcm", "parity-scale-codec", "scale-info", "serde", + "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", ] [[package]] name = "orml-tokens" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "mangata-types", + "log", "orml-traits", "parity-scale-codec", "scale-info", "serde", + "sp-arithmetic", + "sp-core", "sp-runtime", "sp-std", ] @@ -5890,26 +6694,27 @@ dependencies = [ [[package]] name = "orml-traits" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-support", "impl-trait-for-tuples", "num-traits", "orml-utilities", "parity-scale-codec", + "paste", "scale-info", "serde", "sp-core", "sp-io", "sp-runtime", "sp-std", - "xcm", + "staging-xcm", ] [[package]] name = "orml-unknown-tokens" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-support", "frame-system", @@ -5918,18 +6723,19 @@ dependencies = [ "scale-info", "serde", "sp-std", - "xcm", + "staging-xcm", ] [[package]] name = "orml-utilities" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-support", "parity-scale-codec", "scale-info", "serde", + "sp-core", "sp-io", "sp-runtime", "sp-std", @@ -5938,7 +6744,7 @@ dependencies = [ [[package]] name = "orml-xcm" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-support", "frame-system", @@ -5946,31 +6752,32 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-std", - "xcm", + "staging-xcm", ] [[package]] name = "orml-xcm-support" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "frame-support", "orml-traits", "parity-scale-codec", "sp-runtime", "sp-std", - "xcm", - "xcm-executor", + "staging-xcm", + "staging-xcm-executor", ] [[package]] name = "orml-xtokens" version = "0.4.1-dev" -source = "git+https://github.com/mangata-finance//open-runtime-module-library?branch=mangata-dev#82fa856f8bf2815b998a758e7ce70958bec0c540" +source = "git+https://github.com/mangata-finance/open-runtime-module-library?branch=develop#bc3920b659f73fbdd388bb1d4182cac9e78ab7a9" dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", + "log", "orml-traits", "orml-xcm-support", "pallet-xcm", @@ -5980,8 +6787,8 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-executor", + "staging-xcm", + "staging-xcm-executor", ] [[package]] @@ -5990,9 +6797,9 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", ] [[package]] @@ -6001,28 +6808,53 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", ] [[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" +name = "pallet-asset-tx-payment" +version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "cfg-if", - "libm 0.1.4", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-assets" +version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", ] [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", + "log", "pallet-timestamp", "parity-scale-codec", "scale-info", @@ -6035,7 +6867,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -6051,7 +6883,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -6065,7 +6897,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6078,7 +6910,7 @@ dependencies = [ "scale-info", "sp-application-crypto", "sp-consensus-babe", - "sp-consensus-vrf", + "sp-core", "sp-io", "sp-runtime", "sp-session", @@ -6089,8 +6921,10 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "aquamarine 0.3.2", + "docify", "frame-benchmarking", "frame-election-provider-support", "frame-support", @@ -6109,7 +6943,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6124,10 +6958,11 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", + "log", "pallet-authorship", "pallet-session", "parity-scale-codec", @@ -6143,10 +6978,10 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", - "binary-merkle-tree 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "array-bytes", + "binary-merkle-tree", "frame-support", "frame-system", "log", @@ -6161,6 +6996,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-state-machine", "sp-std", ] @@ -6199,7 +7035,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6217,7 +7053,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6233,10 +7069,29 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-collator-selection" +version = "3.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6253,7 +7108,7 @@ dependencies = [ [[package]] name = "pallet-collective-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6270,7 +7125,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6287,9 +7142,9 @@ dependencies = [ [[package]] name = "pallet-crowdloan-rewards" version = "0.6.0" -source = "git+https://github.com/mangata-finance//crowdloan-rewards?branch=mangata-dev#6d7f6cc5c8c5122e031e88062ffc48d7c6bc8f3e" +source = "git+https://github.com/mangata-finance/crowdloan-rewards?branch=upgrade/v1.1.0#5d3f9554285c7f0df1abd6ece7c9ba0e93942e5e" dependencies = [ - "ed25519-dalek", + "ed25519-dalek 1.0.1", "frame-benchmarking", "frame-support", "frame-system", @@ -6311,7 +7166,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6329,14 +7184,14 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", "rand 0.8.5", "scale-info", @@ -6346,26 +7201,13 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", -] - -[[package]] -name = "pallet-election-provider-support-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-system", - "parity-scale-codec", - "sp-npos-elections", - "sp-runtime", + "strum 0.24.1", ] [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6373,12 +7215,13 @@ dependencies = [ "parity-scale-codec", "sp-npos-elections", "sp-runtime", + "sp-std", ] [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6390,14 +7233,16 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", + "sp-staking", "sp-std", ] [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "docify", "frame-benchmarking", "frame-election-provider-support", "frame-support", @@ -6419,7 +7264,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "hex-literal", + "hex-literal 0.3.4", "lazy_static", "log", "mangata-support", @@ -6443,7 +7288,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6466,7 +7311,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6482,7 +7327,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6502,7 +7347,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6550,7 +7395,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "hex-literal", + "hex-literal 0.3.4", "lazy_static", "log", "mangata-support", @@ -6571,7 +7416,24 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-message-queue" +version = "7.0.0-dev" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6579,20 +7441,23 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", "sp-std", + "sp-weights", ] [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -6612,7 +7477,7 @@ dependencies = [ "frame-support", "frame-system", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "lazy_static", "log", "mangata-support", @@ -6635,7 +7500,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6651,7 +7516,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6667,11 +7532,12 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", "log", + "pallet-balances", "parity-scale-codec", "scale-info", "sp-core", @@ -6679,12 +7545,13 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-std", + "sp-tracing", ] [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6704,7 +7571,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6715,7 +7582,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -6732,7 +7599,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6756,7 +7623,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6780,7 +7647,7 @@ dependencies = [ "frame-support", "frame-system", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "lazy_static", "libm 0.2.1", "log", @@ -6808,7 +7675,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6823,7 +7690,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6841,7 +7708,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -6856,7 +7723,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6875,7 +7742,7 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "1.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -6890,8 +7757,9 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", @@ -6907,7 +7775,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -6921,6 +7789,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", + "sp-state-machine", "sp-std", "sp-trie", ] @@ -6928,13 +7797,14 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "pallet-session", "pallet-staking", + "parity-scale-codec", "rand 0.8.5", "sp-runtime", "sp-session", @@ -6944,13 +7814,17 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "rand_chacha 0.2.2", "scale-info", + "sp-arithmetic", + "sp-io", "sp-runtime", "sp-std", ] @@ -6958,7 +7832,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6981,18 +7855,18 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "log", "sp-arithmetic", @@ -7001,7 +7875,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "sp-api", @@ -7010,7 +7884,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7027,8 +7901,9 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", @@ -7041,8 +7916,9 @@ dependencies = [ [[package]] name = "pallet-sudo-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -7073,7 +7949,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7085,13 +7961,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-storage", "sp-timestamp", ] [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7110,7 +7987,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -7126,7 +8003,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "frame-system", @@ -7142,7 +8019,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", "pallet-transaction-payment-mangata-rpc-runtime-api", @@ -7158,7 +8035,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "pallet-transaction-payment-mangata", "parity-scale-codec", @@ -7170,7 +8047,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7186,7 +8063,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7198,7 +8075,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7215,7 +8092,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7231,7 +8108,7 @@ dependencies = [ [[package]] name = "pallet-utility-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7247,7 +8124,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7262,7 +8139,7 @@ dependencies = [ [[package]] name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7270,7 +8147,6 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "serde", "sp-runtime", "sp-std", ] @@ -7278,7 +8154,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7292,8 +8168,8 @@ dependencies = [ [[package]] name = "pallet-xcm" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -7307,14 +8183,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-executor", + "staging-xcm", + "staging-xcm-executor", ] [[package]] name = "pallet-xcm-benchmarks" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-benchmarking", "frame-support", @@ -7325,9 +8201,9 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", ] [[package]] @@ -7340,7 +8216,7 @@ dependencies = [ "frame-support", "frame-system", "frame-try-runtime", - "hex-literal", + "hex-literal 0.3.4", "lazy_static", "libm 0.2.1", "log", @@ -7369,21 +8245,22 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/mangata-finance//cumulus?branch=mangata-dev#9f92e89717bd5d4b87a3eb05400fcf3b54dc2b46" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "sp-runtime", + "sp-std", ] [[package]] name = "parachain-staking" version = "3.0.0" -source = "git+https://github.com/mangata-finance//moonbeam?branch=mangata-dev#2ac7a339be795ee58603e3cb68e65fedc1b1c295" dependencies = [ - "aquamarine", + "aquamarine 0.1.12", "frame-benchmarking", "frame-support", "frame-system", @@ -7392,24 +8269,65 @@ dependencies = [ "mangata-support", "mangata-types", "orml-tokens", + "orml-traits", "pallet-authorship", "pallet-collective-mangata", "pallet-issuance", "pallet-session", + "pallet-vesting-mangata", "parity-scale-codec", "scale-info", "serde", + "similar-asserts", "sp-arithmetic", + "sp-core", + "sp-io", "sp-runtime", "sp-staking", "sp-std", ] +[[package]] +name = "parachains-common" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "cumulus-primitives-core", + "cumulus-primitives-utility", + "frame-support", + "frame-system", + "kusama-runtime-constants", + "log", + "num-traits", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-primitives", + "polkadot-runtime-constants", + "rococo-runtime-constants", + "scale-info", + "smallvec", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "substrate-wasm-builder", + "westend-runtime-constants", +] + [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "59e9ab494af9e6e813c72170f0d3c1de1500990d62c97cc05cc7576f91aa402f" dependencies = [ "blake2", "crc32fast", @@ -7427,11 +8345,11 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.5.0" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -7442,9 +8360,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7491,9 +8409,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -7513,7 +8431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.9", ] [[package]] @@ -7532,22 +8450,28 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.4.1", "smallvec", - "windows-sys 0.45.0", + "windows-targets 0.48.5", ] +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -7567,6 +8491,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -7593,25 +8526,26 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.0" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.6.0" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -7619,56 +8553,56 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.0" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "pest_meta" -version = "2.6.0" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.1.0", ] [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -7679,9 +8613,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -7689,44 +8623,62 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkcs8" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "spki", + "der 0.6.1", + "spki 0.6.0", ] [[package]] -name = "pkg-config" -version = "0.3.27" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", +] [[package]] -name = "platforms" -version = "2.0.0" +name = "pkg-config" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" -version = "3.0.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "polkadot-approval-distribution" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", + "futures-timer", + "polkadot-node-jaeger", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-primitives", "polkadot-node-subsystem", + "polkadot-node-subsystem-util", "polkadot-primitives", "rand 0.8.5", "tracing-gum", @@ -7734,10 +8686,12 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "always-assert", "futures", + "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -7748,13 +8702,12 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "derive_more", "fatality", "futures", - "lru 0.9.0", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -7763,6 +8716,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "rand 0.8.5", + "schnellru", "sp-core", "sp-keystore", "thiserror", @@ -7771,12 +8725,11 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "fatality", "futures", - "lru 0.9.0", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -7786,88 +8739,43 @@ dependencies = [ "polkadot-primitives", "rand 0.8.5", "sc-network", + "schnellru", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-cli" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "clap", "frame-benchmarking-cli", "futures", "log", - "polkadot-client", - "polkadot-node-core-pvf", "polkadot-node-metrics", "polkadot-performance-test", "polkadot-service", "sc-cli", "sc-executor", "sc-service", - "sc-storage-monitor 0.1.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "sc-storage-monitor", "sc-sysinfo", "sc-tracing", "sp-core", "sp-io", "sp-keyring", + "sp-maybe-compressed-blob", "substrate-build-script-utils", "thiserror", "try-runtime-cli", ] -[[package]] -name = "polkadot-client" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "async-trait", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-system", - "frame-system-rpc-runtime-api", - "futures", - "kusama-runtime", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "polkadot-core-primitives", - "polkadot-node-core-parachains-inherent", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-common", - "rococo-runtime", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-service", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-storage", - "sp-timestamp", - "sp-transaction-pool", -] - [[package]] name = "polkadot-collator-protocol" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "always-assert", "bitvec", "fatality", "futures", @@ -7881,13 +8789,14 @@ dependencies = [ "sp-keystore", "sp-runtime", "thiserror", + "tokio-util", "tracing-gum", ] [[package]] name = "polkadot-core-primitives" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", @@ -7898,15 +8807,14 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "derive_more", "fatality", "futures", "futures-timer", - "indexmap", - "lru 0.9.0", + "indexmap 1.9.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -7915,6 +8823,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "sc-network", + "schnellru", "sp-application-crypto", "sp-keystore", "thiserror", @@ -7923,8 +8832,8 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -7937,8 +8846,8 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "futures-timer", @@ -7949,6 +8858,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "sc-network", + "sc-network-common", "sp-application-crypto", "sp-core", "sp-keystore", @@ -7957,8 +8867,8 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "always-assert", "async-trait", @@ -7980,8 +8890,8 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "parity-scale-codec", @@ -7998,16 +8908,15 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "derive_more", "futures", "futures-timer", "kvdb", - "lru 0.9.0", - "merlin", + "merlin 2.0.1", "parity-scale-codec", "polkadot-node-jaeger", "polkadot-node-primitives", @@ -8016,7 +8925,8 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "sc-keystore", - "schnorrkel", + "schnellru", + "schnorrkel 0.9.1", "sp-application-crypto", "sp-consensus", "sp-consensus-slots", @@ -8027,8 +8937,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "futures", @@ -8036,6 +8946,7 @@ dependencies = [ "kvdb", "parity-scale-codec", "polkadot-erasure-coding", + "polkadot-node-jaeger", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -8048,8 +8959,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "fatality", @@ -8067,8 +8978,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "polkadot-node-subsystem", @@ -8082,8 +8993,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -8094,7 +9005,8 @@ dependencies = [ "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", - "polkadot-parachain", + "polkadot-overseer", + "polkadot-parachain-primitives", "polkadot-primitives", "sp-maybe-compressed-blob", "tracing-gum", @@ -8102,8 +9014,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "polkadot-node-metrics", @@ -8117,8 +9029,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "futures-timer", @@ -8134,27 +9046,27 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "fatality", "futures", "kvdb", - "lru 0.9.0", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", "sc-keystore", + "schnellru", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-core-parachains-inherent" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -8168,10 +9080,27 @@ dependencies = [ "tracing-gum", ] +[[package]] +name = "polkadot-node-core-prospective-parachains" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "bitvec", + "fatality", + "futures", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "thiserror", + "tracing-gum", +] + [[package]] name = "polkadot-node-core-provisioner" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "fatality", @@ -8181,51 +9110,42 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand 0.8.5", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-core-pvf" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "always-assert", - "assert_matches", - "cpu-time", "futures", "futures-timer", "libc", "parity-scale-codec", "pin-project", "polkadot-core-primitives", + "polkadot-node-core-pvf-common", "polkadot-node-metrics", "polkadot-node-primitives", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "rand 0.8.5", - "rayon", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", "slotmap", "sp-core", - "sp-externalities", - "sp-io", "sp-maybe-compressed-blob", - "sp-tracing", "sp-wasm-interface", + "substrate-build-script-utils", "tempfile", - "tikv-jemalloc-ctl", "tokio", "tracing-gum", ] [[package]] name = "polkadot-node-core-pvf-checker" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "polkadot-node-primitives", @@ -8238,25 +9158,71 @@ dependencies = [ "tracing-gum", ] +[[package]] +name = "polkadot-node-core-pvf-common" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "cpu-time", + "futures", + "landlock", + "libc", + "parity-scale-codec", + "polkadot-parachain-primitives", + "polkadot-primitives", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-core", + "sp-externalities", + "sp-io", + "sp-tracing", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf-prepare-worker" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "futures", + "libc", + "parity-scale-codec", + "polkadot-node-core-pvf-common", + "polkadot-parachain-primitives", + "polkadot-primitives", + "rayon", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-io", + "sp-maybe-compressed-blob", + "sp-tracing", + "tikv-jemalloc-ctl", + "tokio", + "tracing-gum", +] + [[package]] name = "polkadot-node-core-runtime-api" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", - "lru 0.9.0", "polkadot-node-metrics", "polkadot-node-subsystem", "polkadot-node-subsystem-types", "polkadot-primitives", + "schnellru", "sp-consensus-babe", "tracing-gum", ] [[package]] name = "polkadot-node-jaeger" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "lazy_static", "log", @@ -8273,10 +9239,10 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "bs58", + "bs58 0.5.0", "futures", "futures-timer", "log", @@ -8292,10 +9258,12 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "async-channel", "async-trait", + "bitvec", "derive_more", "fatality", "futures", @@ -8307,38 +9275,37 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-primitives" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bounded-vec", "futures", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", - "schnorrkel", + "schnorrkel 0.9.1", "serde", "sp-application-crypto", "sp-consensus-babe", - "sp-consensus-vrf", "sp-core", "sp-keystore", "sp-maybe-compressed-blob", "sp-runtime", "thiserror", - "zstd", + "zstd 0.12.4", ] [[package]] name = "polkadot-node-subsystem" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -8347,8 +9314,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "derive_more", @@ -8360,6 +9327,7 @@ dependencies = [ "polkadot-primitives", "polkadot-statement-table", "sc-network", + "sc-transaction-pool-api", "smallvec", "sp-api", "sp-authority-discovery", @@ -8370,8 +9338,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "derive_more", @@ -8380,7 +9348,6 @@ dependencies = [ "futures-channel", "itertools 0.10.5", "kvdb", - "lru 0.9.0", "parity-db", "parity-scale-codec", "parking_lot 0.11.2", @@ -8394,6 +9361,7 @@ dependencies = [ "polkadot-primitives", "prioritized-metered-channel", "rand 0.8.5", + "schnellru", "sp-application-crypto", "sp-core", "sp-keystore", @@ -8403,13 +9371,12 @@ dependencies = [ [[package]] name = "polkadot-overseer" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", "futures-timer", - "lru 0.9.0", "orchestra", "parking_lot 0.12.1", "polkadot-node-metrics", @@ -8418,6 +9385,7 @@ dependencies = [ "polkadot-node-subsystem-types", "polkadot-primitives", "sc-client-api", + "schnellru", "sp-api", "sp-core", "tikv-jemalloc-ctl", @@ -8425,9 +9393,9 @@ dependencies = [ ] [[package]] -name = "polkadot-parachain" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +name = "polkadot-parachain-primitives" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bounded-collections", "derive_more", @@ -8443,30 +9411,32 @@ dependencies = [ [[package]] name = "polkadot-performance-test" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "env_logger 0.9.3", - "kusama-runtime", "log", "polkadot-erasure-coding", - "polkadot-node-core-pvf", + "polkadot-node-core-pvf-prepare-worker", "polkadot-node-primitives", "polkadot-primitives", "quote", + "sc-executor-common", + "sp-maybe-compressed-blob", + "staging-kusama-runtime", "thiserror", ] [[package]] name = "polkadot-primitives" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", - "hex-literal", + "hex-literal 0.4.1", "parity-scale-codec", "polkadot-core-primitives", - "polkadot-parachain", + "polkadot-parachain-primitives", "scale-info", "serde", "sp-api", @@ -8485,8 +9455,8 @@ dependencies = [ [[package]] name = "polkadot-rpc" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -8499,7 +9469,7 @@ dependencies = [ "sc-consensus-beefy", "sc-consensus-beefy-rpc", "sc-consensus-epochs", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-rpc", "sc-sync-state-rpc", @@ -8517,8 +9487,8 @@ dependencies = [ [[package]] name = "polkadot-runtime" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "frame-benchmarking", @@ -8526,10 +9496,10 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", @@ -8539,9 +9509,10 @@ dependencies = [ "pallet-bounties", "pallet-child-bounties", "pallet-collective", + "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -8549,6 +9520,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", @@ -8557,6 +9529,7 @@ dependencies = [ "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", + "pallet-referenda", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -8570,7 +9543,9 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-common", @@ -8582,6 +9557,7 @@ dependencies = [ "serde_derive", "smallvec", "sp-api", + "sp-arithmetic", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", @@ -8596,19 +9572,20 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", ] [[package]] name = "polkadot-runtime-common" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bitvec", "frame-benchmarking", @@ -8647,14 +9624,14 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "staging-xcm", "static_assertions", - "xcm", ] [[package]] name = "polkadot-runtime-constants" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "polkadot-primitives", @@ -8667,10 +9644,11 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "bs58", + "bs58 0.5.0", + "frame-benchmarking", "parity-scale-codec", "polkadot-primitives", "sp-std", @@ -8679,26 +9657,28 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bitvec", "derive_more", "frame-benchmarking", "frame-support", "frame-system", + "impl-trait-for-tuples", "log", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", "pallet-balances", + "pallet-message-queue", "pallet-session", "pallet-staking", "pallet-timestamp", "pallet-vesting", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-metrics", "rand 0.8.5", @@ -8716,40 +9696,43 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "staging-xcm", + "staging-xcm-executor", "static_assertions", - "xcm", - "xcm-executor", ] [[package]] name = "polkadot-service" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", + "frame-benchmarking", "frame-benchmarking-cli", "frame-support", + "frame-system", "frame-system-rpc-runtime-api", "futures", - "hex-literal", - "kusama-runtime", + "hex-literal 0.4.1", + "is_executable", "kusama-runtime-constants", "kvdb", "kvdb-rocksdb", "log", - "lru 0.9.0", "mmr-gadget", "pallet-babe", "pallet-im-online", "pallet-staking", + "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "parity-db", + "parity-scale-codec", "polkadot-approval-distribution", "polkadot-availability-bitfield-distribution", "polkadot-availability-distribution", "polkadot-availability-recovery", - "polkadot-client", "polkadot-collator-protocol", + "polkadot-core-primitives", "polkadot-dispute-distribution", "polkadot-gossip-support", "polkadot-network-bridge", @@ -8763,7 +9746,9 @@ dependencies = [ "polkadot-node-core-chain-selection", "polkadot-node-core-dispute-coordinator", "polkadot-node-core-parachains-inherent", + "polkadot-node-core-prospective-parachains", "polkadot-node-core-provisioner", + "polkadot-node-core-pvf", "polkadot-node-core-pvf-checker", "polkadot-node-core-runtime-api", "polkadot-node-network-protocol", @@ -8772,11 +9757,11 @@ dependencies = [ "polkadot-node-subsystem-types", "polkadot-node-subsystem-util", "polkadot-overseer", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-rpc", "polkadot-runtime", - "polkadot-runtime-constants", + "polkadot-runtime-common", "polkadot-runtime-parachains", "polkadot-statement-distribution", "rococo-runtime", @@ -8790,7 +9775,7 @@ dependencies = [ "sc-consensus", "sc-consensus-babe", "sc-consensus-beefy", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-consensus-slots", "sc-executor", "sc-keystore", @@ -8803,180 +9788,74 @@ dependencies = [ "sc-sysinfo", "sc-telemetry", "sc-transaction-pool", + "sc-transaction-pool-api", + "schnellru", "serde", "serde_json", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-state-machine", - "sp-storage", - "sp-timestamp", - "sp-transaction-pool", - "sp-trie", - "substrate-prometheus-endpoint", - "thiserror", - "tracing-gum", - "westend-runtime", -] - -[[package]] -name = "polkadot-statement-distribution" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "arrayvec 0.5.2", - "fatality", - "futures", - "indexmap", - "parity-scale-codec", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-keystore", - "sp-staking", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-statement-table" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "parity-scale-codec", - "polkadot-primitives", - "sp-core", -] - -[[package]] -name = "polkadot-test-runtime" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "frame-benchmarking", - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", - "sc-executor", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", + "sp-api", "sp-authority-discovery", + "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-consensus-babe", + "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", "sp-inherents", + "sp-io", "sp-keyring", + "sp-keystore", + "sp-mmr-primitives", + "sp-offchain", "sp-runtime", + "sp-session", "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", + "sp-storage", + "sp-timestamp", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "staging-kusama-runtime", + "substrate-prometheus-endpoint", + "thiserror", + "tracing-gum", + "westend-runtime", +] + +[[package]] +name = "polkadot-statement-distribution" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "arrayvec 0.7.4", + "bitvec", + "fatality", + "futures", + "futures-timer", + "indexmap 1.9.3", + "parity-scale-codec", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-keystore", + "sp-staking", + "thiserror", "tracing-gum", ] +[[package]] +name = "polkadot-statement-table" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "parity-scale-codec", + "polkadot-primitives", + "sp-core", +] + [[package]] name = "polling" version = "2.8.0" @@ -8984,12 +9863,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite 0.2.13", + "rustix 0.38.21", + "tracing", "windows-sys 0.48.0", ] @@ -9004,6 +9897,17 @@ dependencies = [ "universal-hash 0.4.1", ] +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.5.1", +] + [[package]] name = "polyval" version = "0.5.3" @@ -9018,9 +9922,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", @@ -9028,6 +9932,18 @@ dependencies = [ "universal-hash 0.5.1", ] +[[package]] +name = "portable-atomic" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -9074,11 +9990,21 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.39", +] + [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -9089,11 +10015,10 @@ dependencies = [ [[package]] name = "prioritized-metered-channel" -version = "0.4.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3caef72a78ca8e77cbdfa87dd516ebb79d4cbe5b42e3b8435b463a8261339ff" +checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" dependencies = [ - "async-channel", "coarsetime", "crossbeam-queue", "derive_more", @@ -9138,11 +10063,22 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-warning" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "proc-macro2" -version = "1.0.58" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -9163,25 +10099,25 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" +checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" dependencies = [ "dtoa", "itoa", "parking_lot 0.12.1", - "prometheus-client-derive-text-encode", + "prometheus-client-derive-encode", ] [[package]] -name = "prometheus-client-derive-text-encode" -version = "0.3.0" +name = "prometheus-client-derive-encode" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -9207,7 +10143,7 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease", + "prettyplease 0.1.25", "prost", "prost-types", "regex", @@ -9216,19 +10152,6 @@ dependencies = [ "which", ] -[[package]] -name = "prost-codec" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0" -dependencies = [ - "asynchronous-codec", - "bytes", - "prost", - "thiserror", - "unsigned-varint", -] - [[package]] name = "prost-derive" version = "0.11.9" @@ -9275,6 +10198,19 @@ dependencies = [ "byteorder", ] +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quicksink" version = "0.1.2" @@ -9288,27 +10224,27 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" +checksum = "94b0b33c13a79f669c85defaf4c275dc86a0c0372807d0ca3d78e0bb87274863" dependencies = [ "bytes", "rand 0.8.5", - "ring", + "ring 0.16.20", "rustc-hash", - "rustls 0.20.8", + "rustls 0.20.9", "slab", "thiserror", "tinyvec", "tracing", - "webpki 0.22.0", + "webpki 0.22.4", ] [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -9378,7 +10314,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.11", ] [[package]] @@ -9407,9 +10343,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -9417,14 +10353,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -9434,8 +10368,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", - "ring", - "time 0.3.21", + "ring 0.16.20", + "time", "x509-parser 0.13.2", "yasna", ] @@ -9447,8 +10381,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", - "ring", - "time 0.3.21", + "ring 0.16.20", + "time", "yasna", ] @@ -9458,7 +10392,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -9467,58 +10401,67 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.9", - "redox_syscall 0.2.16", + "getrandom 0.2.11", + "libredox", "thiserror", ] [[package]] name = "reed-solomon-novelpoly" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd8f48b2066e9f69ab192797d66da804d1935bf22763204ed3675740cb0f221" +checksum = "58130877ca403ab42c864fbac74bb319a0746c07a634a92a5cfc7f54af272582" dependencies = [ "derive_more", "fs-err", - "itertools 0.10.5", - "static_init 0.5.2", + "itertools 0.11.0", + "static_init", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "regalloc2" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" dependencies = [ "fxhash", "log", @@ -9528,13 +10471,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.3" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -9547,28 +10491,27 @@ dependencies = [ ] [[package]] -name = "regex-syntax" -version = "0.6.29" +name = "regex-automata" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "region" -version = "3.0.0" +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "resolv-conf" @@ -9586,11 +10529,36 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ - "crypto-bigint", + "crypto-bigint 0.4.9", "hmac 0.12.1", "zeroize", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + +[[package]] +name = "ring" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "common", + "fflonk", + "merlin 3.0.0", +] + [[package]] name = "ring" version = "0.16.20" @@ -9600,17 +10568,31 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom 0.2.11", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "rocksdb" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" +checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" dependencies = [ "libc", "librocksdb-sys", @@ -9618,18 +10600,18 @@ dependencies = [ [[package]] name = "rococo-runtime" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "binary-merkle-tree 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "binary-merkle-tree", "frame-benchmarking", "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", @@ -9647,6 +10629,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-mmr", "pallet-multisig", "pallet-nis", @@ -9670,7 +10653,7 @@ dependencies = [ "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", "polkadot-runtime-parachains", @@ -9693,19 +10676,20 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "static_assertions", "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", ] [[package]] name = "rococo-runtime-constants" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "polkadot-primitives", @@ -9787,7 +10771,6 @@ dependencies = [ "env_logger 0.9.3", "frame-support", "frame-system", - "kusama-runtime", "kusama-runtime-constants", "log", "mangata-kusama-runtime", @@ -9813,15 +10796,17 @@ dependencies = [ "pallet-xyk", "parachain-info", "parachain-staking", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-parachains", "sp-io", "sp-runtime", - "xcm", - "xcm-builder", + "sp-storage", + "staging-kusama-runtime", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "xcm-emulator", - "xcm-executor", "xyk-runtime-api", ] @@ -9849,7 +10834,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.17", + "semver 1.0.20", ] [[package]] @@ -9863,11 +10848,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -9877,11 +10862,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -9889,6 +10874,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys 0.4.11", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -9897,28 +10895,40 @@ checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ "base64 0.13.1", "log", - "ring", + "ring 0.16.20", "sct 0.6.1", "webpki 0.21.4", ] [[package]] name = "rustls" -version = "0.20.8" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring 0.16.20", + "sct 0.7.1", + "webpki 0.22.4", +] + +[[package]] +name = "rustls" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", ] [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -9928,18 +10938,39 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.5", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "base64 0.21.2", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ruzstd" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "ac3ffab8f9715a0d455df4bbb9d21e91135aab3cd3ca187af0cd0c3c3f868fdc" +dependencies = [ + "byteorder", + "thiserror-core", + "twox-hash", +] [[package]] name = "rw-stream-sink" @@ -9954,15 +10985,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe_arch" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" dependencies = [ "bytemuck", ] @@ -9979,7 +11010,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "log", "sp-core", @@ -9990,7 +11021,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -9998,13 +11029,13 @@ dependencies = [ "ip_network", "libp2p", "log", + "multihash", "parity-scale-codec", "prost", "prost-build", "rand 0.8.5", "sc-client-api", "sc-network", - "sc-network-common", "sp-api", "sp-authority-discovery", "sp-blockchain", @@ -10018,7 +11049,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "futures-timer", @@ -10041,9 +11072,9 @@ dependencies = [ [[package]] name = "sc-basic-authorship-ver" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "aquamarine", + "aquamarine 0.3.2", "futures", "futures-timer", "log", @@ -10067,7 +11098,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -10082,9 +11113,9 @@ dependencies = [ [[package]] name = "sc-block-builder-ver" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "aquamarine", + "aquamarine 0.1.12", "extrinsic-shuffler", "log", "parity-scale-codec", @@ -10095,7 +11126,6 @@ dependencies = [ "sp-core", "sp-inherents", "sp-runtime", - "sp-state-machine", "sp-ver", "ver-api", ] @@ -10103,7 +11133,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -10122,25 +11152,25 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "chrono", "clap", "fdlimit", "futures", - "libp2p", + "libp2p-identity", "log", "names", "parity-scale-codec", @@ -10151,7 +11181,6 @@ dependencies = [ "sc-client-db", "sc-keystore", "sc-network", - "sc-network-common", "sc-service", "sc-telemetry", "sc-tracing", @@ -10173,7 +11202,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "fnv", "futures", @@ -10189,9 +11218,9 @@ dependencies = [ "sp-core", "sp-database", "sp-externalities", - "sp-keystore", "sp-runtime", "sp-state-machine", + "sp-statement-store", "sp-storage", "substrate-prometheus-endpoint", ] @@ -10199,9 +11228,9 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "hash-db 0.16.0", + "hash-db", "kvdb", "kvdb-memorydb", "kvdb-rocksdb", @@ -10225,12 +11254,12 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "mockall", "parking_lot 0.12.1", @@ -10250,7 +11279,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -10279,13 +11308,12 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "fork-tree", "futures", "log", - "merlin", "num-bigint", "num-rational", "num-traits", @@ -10295,10 +11323,9 @@ dependencies = [ "sc-consensus", "sc-consensus-epochs", "sc-consensus-slots", - "sc-keystore", "sc-telemetry", + "sc-transaction-pool-api", "scale-info", - "schnorrkel", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -10306,13 +11333,10 @@ dependencies = [ "sp-consensus", "sp-consensus-babe", "sp-consensus-slots", - "sp-consensus-vrf", "sp-core", "sp-inherents", - "sp-io", "sp-keystore", "sp-runtime", - "sp-version", "substrate-prometheus-endpoint", "thiserror", ] @@ -10320,7 +11344,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "jsonrpsee", @@ -10342,9 +11366,10 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", + "async-channel", "async-trait", "fnv", "futures", @@ -10353,9 +11378,7 @@ dependencies = [ "parking_lot 0.12.1", "sc-client-api", "sc-consensus", - "sc-keystore", "sc-network", - "sc-network-common", "sc-network-gossip", "sc-network-sync", "sc-utils", @@ -10377,7 +11400,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "jsonrpsee", @@ -10396,63 +11419,23 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "fork-tree", - "parity-scale-codec", - "sc-client-api", - "sc-consensus", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "sc-consensus-grandpa" -version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "ahash 0.8.3", - "array-bytes 4.2.0", - "async-trait", - "dyn-clone", - "finality-grandpa", "fork-tree", - "futures", - "futures-timer", - "log", "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "sc-block-builder", - "sc-chain-spec", "sc-client-api", "sc-consensus", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-telemetry", - "sc-utils", - "serde_json", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-core", - "sp-keystore", "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", ] [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "ahash 0.8.3", - "array-bytes 4.2.0", + "ahash 0.8.6", + "array-bytes", "async-trait", "dyn-clone", "finality-grandpa", @@ -10471,6 +11454,7 @@ dependencies = [ "sc-network-common", "sc-network-gossip", "sc-telemetry", + "sc-transaction-pool-api", "sc-utils", "serde_json", "sp-api", @@ -10489,7 +11473,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "finality-grandpa", "futures", @@ -10497,7 +11481,7 @@ dependencies = [ "log", "parity-scale-codec", "sc-client-api", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-rpc", "serde", "sp-blockchain", @@ -10509,7 +11493,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -10534,14 +11518,13 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "lru 0.8.1", "parity-scale-codec", "parking_lot 0.12.1", "sc-executor-common", - "sc-executor-wasmi", "sc-executor-wasmtime", + "schnellru", "sp-api", "sp-core", "sp-externalities", @@ -10552,46 +11535,30 @@ dependencies = [ "sp-version", "sp-wasm-interface", "tracing", - "wasmi", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface", "thiserror", "wasm-instrument", - "wasmi", -] - -[[package]] -name = "sc-executor-wasmi" -version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "log", - "sc-allocator", - "sc-executor-common", - "sp-runtime-interface", - "sp-wasm-interface", - "wasmi", ] [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "anyhow", "cfg-if", "libc", "log", - "once_cell", - "rustix 0.36.14", + "rustix 0.36.17", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -10602,7 +11569,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "ansi_term", "futures", @@ -10618,10 +11585,9 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", - "async-trait", + "array-bytes", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -10633,9 +11599,9 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "async-channel", "async-trait", "asynchronous-codec", @@ -10648,46 +11614,43 @@ dependencies = [ "libp2p", "linked_hash_set", "log", - "lru 0.8.1", "mockall", "parity-scale-codec", "parking_lot 0.12.1", + "partial_sort", "pin-project", "rand 0.8.5", - "sc-block-builder", "sc-client-api", - "sc-consensus", "sc-network-common", - "sc-peerset", "sc-utils", "serde", "serde_json", "smallvec", "sp-arithmetic", "sp-blockchain", - "sp-consensus", "sp-core", "sp-runtime", "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", + "wasm-timer", "zeroize", ] [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "async-channel", "cid", "futures", - "libp2p", + "libp2p-identity", "log", "prost", "prost-build", "sc-client-api", "sc-network", - "sc-network-common", "sp-blockchain", "sp-runtime", "thiserror", @@ -10697,45 +11660,33 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", "async-trait", - "bitflags", - "bytes", + "bitflags 1.3.2", "futures", - "futures-timer", - "libp2p", + "libp2p-identity", "parity-scale-codec", "prost-build", "sc-consensus", - "sc-peerset", - "sc-utils", - "serde", - "smallvec", - "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "zeroize", ] [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "futures", "futures-timer", "libp2p", "log", - "lru 0.8.1", "sc-network", "sc-network-common", - "sc-peerset", + "schnellru", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -10744,19 +11695,18 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", + "async-channel", "futures", - "libp2p", + "libp2p-identity", "log", "parity-scale-codec", "prost", "prost-build", "sc-client-api", "sc-network", - "sc-network-common", - "sc-peerset", "sp-blockchain", "sp-core", "sp-runtime", @@ -10766,16 +11716,16 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", + "async-channel", "async-trait", "fork-tree", "futures", "futures-timer", "libp2p", "log", - "lru 0.8.1", "mockall", "parity-scale-codec", "prost", @@ -10784,8 +11734,8 @@ dependencies = [ "sc-consensus", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", + "schnellru", "smallvec", "sp-arithmetic", "sp-blockchain", @@ -10800,17 +11750,15 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "futures", "libp2p", "log", "parity-scale-codec", - "pin-project", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", "sp-consensus", "sp-runtime", @@ -10820,9 +11768,9 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "bytes", "fnv", "futures", @@ -10830,6 +11778,7 @@ dependencies = [ "hyper", "hyper-rustls", "libp2p", + "log", "num_cpus", "once_cell", "parity-scale-codec", @@ -10838,33 +11787,22 @@ dependencies = [ "sc-client-api", "sc-network", "sc-network-common", - "sc-peerset", + "sc-transaction-pool-api", "sc-utils", "sp-api", "sp-core", + "sp-externalities", + "sp-keystore", "sp-offchain", "sp-runtime", "threadpool", "tracing", ] -[[package]] -name = "sc-peerset" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "futures", - "libp2p", - "log", - "sc-utils", - "serde_json", - "wasm-timer", -] - [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10873,10 +11811,9 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", - "hash-db 0.15.2", "jsonrpsee", "log", "parity-scale-codec", @@ -10897,6 +11834,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-session", + "sp-statement-store", "sp-version", "tokio", ] @@ -10904,7 +11842,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10916,7 +11854,6 @@ dependencies = [ "sp-core", "sp-rpc", "sp-runtime", - "sp-tracing", "sp-version", "thiserror", ] @@ -10924,9 +11861,8 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "futures", "http", "jsonrpsee", "log", @@ -10940,9 +11876,9 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", + "array-bytes", "futures", "futures-util", "hex", @@ -10953,6 +11889,7 @@ dependencies = [ "sc-chain-spec", "sc-client-api", "sc-transaction-pool-api", + "sc-utils", "serde", "sp-api", "sp-blockchain", @@ -10960,13 +11897,14 @@ dependencies = [ "sp-runtime", "sp-version", "thiserror", + "tokio", "tokio-stream", ] [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "directories", @@ -10994,11 +11932,9 @@ dependencies = [ "sc-network-light", "sc-network-sync", "sc-network-transactions", - "sc-offchain", "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", - "sc-storage-monitor 0.1.0 (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -11008,24 +11944,20 @@ dependencies = [ "serde", "serde_json", "sp-api", - "sp-application-crypto", - "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-core", "sp-externalities", - "sp-inherents", "sp-keystore", "sp-runtime", "sp-session", "sp-state-machine", "sp-storage", - "sp-tracing", "sp-transaction-pool", "sp-transaction-storage-proof", "sp-trie", "sp-version", - "static_init 1.0.3", + "static_init", "substrate-prometheus-endpoint", "tempfile", "thiserror", @@ -11038,7 +11970,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "log", "parity-scale-codec", @@ -11049,30 +11981,12 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "clap", - "fs4", - "futures", - "log", - "sc-client-db", - "sc-utils", - "sp-core", - "thiserror", - "tokio", -] - -[[package]] -name = "sc-storage-monitor" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "clap", "fs4", - "futures", "log", "sc-client-db", - "sc-utils", "sp-core", "thiserror", "tokio", @@ -11081,7 +11995,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11089,7 +12003,7 @@ dependencies = [ "sc-client-api", "sc-consensus-babe", "sc-consensus-epochs", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "serde", "serde_json", "sp-blockchain", @@ -11100,7 +12014,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "libc", @@ -11119,7 +12033,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "chrono", "futures", @@ -11138,7 +12052,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "ansi_term", "atty", @@ -11146,12 +12060,10 @@ dependencies = [ "lazy_static", "libc", "log", - "once_cell", "parking_lot 0.12.1", "regex", "rustc-hash", "sc-client-api", - "sc-rpc-server", "sc-tracing-proc-macro", "serde", "sp-api", @@ -11169,25 +12081,24 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", "futures-timer", "linked-hash-map", "log", - "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "sc-client-api", @@ -11207,13 +12118,15 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", "log", + "parity-scale-codec", "serde", "sp-blockchain", + "sp-core", "sp-runtime", "thiserror", ] @@ -11221,7 +12134,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-channel", "futures", @@ -11235,9 +12148,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -11249,9 +12162,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11261,11 +12174,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -11274,7 +12187,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "cfg-if", "hashbrown 0.13.2", ] @@ -11289,7 +12202,7 @@ dependencies = [ "arrayvec 0.5.2", "curve25519-dalek 2.1.3", "getrandom 0.1.16", - "merlin", + "merlin 2.0.1", "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", @@ -11297,17 +12210,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "schnorrkel" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "844b7645371e6ecdf61ff246ba1958c29e802881a749ae3fb1993675d210d28d" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "curve25519-dalek-ng", + "merlin 3.0.0", + "rand_core 0.6.4", + "sha2 0.9.9", + "subtle-ng", + "zeroize", +] + [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -11315,18 +12244,18 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -11347,10 +12276,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "base16ct", - "der", + "base16ct 0.1.1", + "der 0.6.1", + "generic-array 0.14.7", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.8", "generic-array 0.14.7", - "pkcs8", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -11384,11 +12327,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -11397,9 +12340,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -11416,9 +12359,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" dependencies = [ "serde", ] @@ -11429,43 +12372,46 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "separator" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" - [[package]] name = "serde" -version = "1.0.163" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +dependencies = [ + "serde", +] + [[package]] name = "serial_test" version = "0.6.0" @@ -11505,9 +12451,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -11541,9 +12487,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -11562,18 +12508,18 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook-registry" @@ -11594,6 +12540,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "simba" version = "0.8.1" @@ -11609,9 +12565,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" dependencies = [ "bstr 0.2.17", "unicode-segmentation", @@ -11619,9 +12575,9 @@ dependencies = [ [[package]] name = "similar-asserts" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf644ad016b75129f01a34a355dcb8d66a5bc803e417c7a77cc5d5ee9fa0f18" +checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" dependencies = [ "console", "similar", @@ -11629,15 +12585,15 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -11650,8 +12606,8 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "enumn", "parity-scale-codec", @@ -11671,9 +12627,116 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "smol" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13f2b548cd8447f8de0fdf1c592929f70f4fc7039a05e47404b0d096ec6987a1" +dependencies = [ + "async-channel", + "async-executor", + "async-fs", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-net", + "async-process", + "blocking", + "futures-lite 1.13.0", +] + +[[package]] +name = "smoldot" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "c0bb30cf57b7b5f6109ce17c3164445e2d6f270af2cb48f6e4d31c2967c9a9f5" +dependencies = [ + "arrayvec 0.7.4", + "async-lock 2.8.0", + "atomic-take", + "base64 0.21.5", + "bip39", + "blake2-rfc", + "bs58 0.5.0", + "chacha20 0.9.1", + "crossbeam-queue", + "derive_more", + "ed25519-zebra 4.0.3", + "either", + "event-listener 2.5.3", + "fnv", + "futures-lite 1.13.0", + "futures-util", + "hashbrown 0.14.2", + "hex", + "hmac 0.12.1", + "itertools 0.11.0", + "libsecp256k1", + "merlin 3.0.0", + "no-std-net", + "nom", + "num-bigint", + "num-rational", + "num-traits", + "pbkdf2 0.12.2", + "pin-project", + "poly1305 0.8.0", + "rand 0.8.5", + "rand_chacha 0.3.1", + "ruzstd", + "schnorrkel 0.10.2", + "serde", + "serde_json", + "sha2 0.10.8", + "sha3", + "siphasher", + "slab", + "smallvec", + "soketto", + "twox-hash", + "wasmi", + "x25519-dalek 2.0.0", + "zeroize", +] + +[[package]] +name = "smoldot-light" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256b5bad1d6b49045e95fe87492ce73d5af81545d8b4d8318a872d2007024c33" +dependencies = [ + "async-channel", + "async-lock 2.8.0", + "base64 0.21.5", + "blake2-rfc", + "derive_more", + "either", + "event-listener 2.5.3", + "fnv", + "futures-channel", + "futures-lite 1.13.0", + "futures-util", + "hashbrown 0.14.2", + "hex", + "itertools 0.11.0", + "log", + "lru 0.11.1", + "no-std-net", + "parking_lot 0.12.1", + "pin-project", + "rand 0.8.5", + "rand_chacha 0.3.1", + "serde", + "serde_json", + "siphasher", + "slab", + "smol", + "smoldot", + "zeroize", +] [[package]] name = "snap" @@ -11683,31 +12746,41 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.4", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.1.1", "rand_core 0.6.4", - "ring", + "ring 0.16.20", "rustc_version", - "sha2 0.10.6", + "sha2 0.10.8", "subtle", ] [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", ] +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -11728,13 +12801,16 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", + "scale-info", "sp-api-proc-macro", "sp-core", + "sp-externalities", + "sp-metadata-ir", "sp-runtime", "sp-state-machine", "sp-std", @@ -11746,21 +12822,21 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "Inflector", "blake2", - "expander 1.0.0", + "expander 2.0.0", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "23.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", @@ -11772,8 +12848,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "16.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "integer-sqrt", "num-traits", @@ -11787,7 +12863,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", @@ -11800,9 +12876,8 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "parity-scale-codec", "sp-api", "sp-inherents", "sp-runtime", @@ -11812,13 +12887,13 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "futures", "log", - "lru 0.8.1", "parity-scale-codec", "parking_lot 0.12.1", + "schnellru", "sp-api", "sp-consensus", "sp-database", @@ -11830,7 +12905,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "futures", @@ -11845,14 +12920,13 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "parity-scale-codec", "scale-info", "sp-api", "sp-application-crypto", - "sp-consensus", "sp-consensus-slots", "sp-inherents", "sp-runtime", @@ -11863,21 +12937,17 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", - "merlin", "parity-scale-codec", "scale-info", "serde", "sp-api", "sp-application-crypto", - "sp-consensus", "sp-consensus-slots", - "sp-consensus-vrf", "sp-core", "sp-inherents", - "sp-keystore", "sp-runtime", "sp-std", "sp-timestamp", @@ -11886,7 +12956,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "lazy_static", "parity-scale-codec", @@ -11899,13 +12969,13 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "finality-grandpa", "log", @@ -11923,58 +12993,45 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic", - "sp-runtime", "sp-std", "sp-timestamp", ] -[[package]] -name = "sp-consensus-vrf" -version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "parity-scale-codec", - "scale-info", - "schnorrkel", - "sp-core", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "21.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "array-bytes 4.2.0", - "base58", - "bitflags", + "array-bytes", + "arrayvec 0.7.4", + "bandersnatch_vrfs", + "bitflags 1.3.2", "blake2", "bounded-collections", + "bs58 0.5.0", "dyn-clonable", - "ed25519-zebra", + "ed25519-zebra 3.1.0", "futures", - "hash-db 0.16.0", + "hash-db", "hash256-std-hasher", "impl-serde", "lazy_static", "libsecp256k1", "log", - "merlin", + "merlin 2.0.1", "parity-scale-codec", - "parity-util-mem", "parking_lot 0.12.1", + "paste", "primitive-types", "rand 0.8.5", "regex", "scale-info", - "schnorrkel", + "schnorrkel 0.9.1", "secp256k1", "secrecy", "serde", @@ -11988,38 +13045,37 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", + "tracing", "zeroize", ] [[package]] name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "9.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.8", "sha3", - "sp-std", "twox-hash", ] [[package]] name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "9.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "proc-macro2", "quote", "sp-core-hashing", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -12027,18 +13083,18 @@ dependencies = [ [[package]] name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "8.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "0.19.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "environmental", "parity-scale-codec", @@ -12046,16 +13102,26 @@ dependencies = [ "sp-storage", ] +[[package]] +name = "sp-genesis-builder" +version = "0.1.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "serde_json", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-core", "sp-runtime", "sp-std", "thiserror", @@ -12063,16 +13129,15 @@ dependencies = [ [[package]] name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "23.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bytes", - "ed25519", - "ed25519-dalek", - "futures", + "ed25519-dalek 2.0.0", "libsecp256k1", "log", "parity-scale-codec", + "rustversion", "secp256k1", "sp-core", "sp-externalities", @@ -12088,27 +13153,22 @@ dependencies = [ [[package]] name = "sp-keyring" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "24.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "0.27.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "async-trait", - "futures", - "merlin", "parity-scale-codec", "parking_lot 0.12.1", - "schnorrkel", - "serde", "sp-core", "sp-externalities", "thiserror", @@ -12117,16 +13177,27 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "thiserror", - "zstd", + "zstd 0.12.4", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.1.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "frame-metadata", + "parity-scale-codec", + "scale-info", + "sp-std", ] [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -12144,7 +13215,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", @@ -12158,7 +13229,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "sp-api", "sp-core", @@ -12167,8 +13238,8 @@ dependencies = [ [[package]] name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "8.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "backtrace", "lazy_static", @@ -12178,7 +13249,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "rustc-hash", "serde", @@ -12187,8 +13258,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "24.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "either", "hash256-std-hasher", @@ -12210,8 +13281,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "17.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12228,25 +13299,26 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "11.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "Inflector", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "scale-info", "sp-api", "sp-core", + "sp-keystore", "sp-runtime", "sp-staking", "sp-std", @@ -12255,10 +13327,12 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "impl-trait-for-tuples", "parity-scale-codec", "scale-info", + "serde", "sp-core", "sp-runtime", "sp-std", @@ -12266,10 +13340,10 @@ dependencies = [ [[package]] name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "0.28.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -12282,17 +13356,42 @@ dependencies = [ "sp-trie", "thiserror", "tracing", + "trie-db", +] + +[[package]] +name = "sp-statement-store" +version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "aes-gcm 0.10.3", + "curve25519-dalek 4.1.1", + "ed25519-dalek 2.0.0", + "hkdf", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sha2 0.10.8", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "thiserror", + "x25519-dalek 2.0.0", ] [[package]] name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "8.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" [[package]] name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "13.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12305,11 +13404,9 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", - "futures-timer", - "log", "parity-scale-codec", "sp-inherents", "sp-runtime", @@ -12319,8 +13416,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "10.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "parity-scale-codec", "sp-std", @@ -12332,7 +13429,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "sp-api", "sp-runtime", @@ -12341,10 +13438,9 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", - "log", "parity-scale-codec", "scale-info", "sp-core", @@ -12356,12 +13452,12 @@ dependencies = [ [[package]] name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +version = "22.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "ahash 0.8.3", - "hash-db 0.16.0", - "hashbrown 0.12.3", + "ahash 0.8.6", + "hash-db", + "hashbrown 0.13.2", "lazy_static", "memory-db", "nohash-hasher", @@ -12380,161 +13476,326 @@ dependencies = [ [[package]] name = "sp-ver" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", + "parity-scale-codec", + "scale-info", + "schnorrkel 0.9.1", + "serde", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-version" +version = "22.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "8.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sp-wasm-interface" +version = "14.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "20.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spinners" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" +dependencies = [ + "lazy_static", + "maplit", + "strum 0.24.1", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.8", +] + +[[package]] +name = "ss58-registry" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "staging-kusama-runtime" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" +dependencies = [ + "binary-merkle-tree", + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "kusama-runtime-constants", "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-beefy", + "pallet-beefy-mmr", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-conviction-voting", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", + "pallet-elections-phragmen", + "pallet-fast-unstake", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-mmr", + "pallet-multisig", + "pallet-nis", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-proxy", + "pallet-ranked-collective", + "pallet-recovery", + "pallet-referenda", + "pallet-scheduler", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-runtime-api", + "pallet-state-trie-migration", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-whitelist", + "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", "scale-info", - "schnorrkel", "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", "sp-core", "sp-inherents", - "sp-keystore", + "sp-io", + "sp-mmr-primitives", + "sp-npos-elections", + "sp-offchain", "sp-runtime", + "sp-session", + "sp-staking", "sp-std", + "sp-storage", + "sp-transaction-pool", + "sp-version", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", + "static_assertions", + "substrate-wasm-builder", ] [[package]] -name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +name = "staging-xcm" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "impl-serde", + "bounded-collections", + "derivative", + "environmental", + "impl-trait-for-tuples", + "log", "parity-scale-codec", - "parity-wasm", "scale-info", "serde", - "sp-core-hashing-proc-macro", - "sp-runtime", - "sp-std", - "sp-version-proc-macro", - "thiserror", -] - -[[package]] -name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "parity-scale-codec", - "proc-macro2", - "quote", - "syn 1.0.109", + "sp-weights", + "xcm-procedural", ] [[package]] -name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +name = "staging-xcm-builder" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "anyhow", + "frame-support", + "frame-system", "impl-trait-for-tuples", "log", + "pallet-transaction-payment", "parity-scale-codec", + "polkadot-parachain-primitives", + "scale-info", + "sp-arithmetic", + "sp-io", + "sp-runtime", "sp-std", - "wasmi", - "wasmtime", + "sp-weights", + "staging-xcm", + "staging-xcm-executor", ] [[package]] -name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +name = "staging-xcm-executor" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "environmental", + "frame-benchmarking", + "frame-support", + "impl-trait-for-tuples", + "log", "parity-scale-codec", - "scale-info", - "serde", - "smallvec", "sp-arithmetic", "sp-core", - "sp-debug-derive", + "sp-io", + "sp-runtime", "sp-std", + "sp-weights", + "staging-xcm", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "ss58-registry" -version = "1.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" -dependencies = [ - "Inflector", - "num-format", - "proc-macro2", - "quote", - "serde", - "serde_json", - "unicode-xid", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "static_init" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b73400442027c4adedda20a9f9b7945234a5bd8d5f7e86da22bd5d0622369c" -dependencies = [ - "cfg_aliases", - "libc", - "parking_lot 0.11.2", - "static_init_macro 0.5.0", -] - [[package]] name = "static_init" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", "parking_lot_core 0.8.6", - "static_init_macro 1.0.2", + "static_init_macro", "winapi", ] -[[package]] -name = "static_init_macro" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2261c91034a1edc3fc4d1b80e89d82714faede0515c14a75da10cb941546bbf" -dependencies = [ - "cfg_aliases", - "memchr", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "static_init_macro" version = "1.0.2" @@ -12560,9 +13821,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -12576,6 +13843,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.39", +] + [[package]] name = "stun" version = "0.4.4" @@ -12587,7 +13867,7 @@ dependencies = [ "lazy_static", "md-5", "rand 0.8.5", - "ring", + "ring 0.16.20", "subtle", "thiserror", "tokio", @@ -12595,23 +13875,15 @@ dependencies = [ "webrtc-util", ] -[[package]] -name = "sub-tokens" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate-debug-kit?branch=master#e12503ab781e913735dc389865a3b8b4a6c6399d" -dependencies = [ - "separator", -] - [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", - "schnorrkel", + "schnorrkel 0.9.1", "sha2 0.9.9", "zeroize", ] @@ -12619,15 +13891,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "platforms 2.0.0", -] +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -12646,7 +13915,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "hyper", "log", @@ -12658,7 +13927,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "jsonrpsee", @@ -12671,14 +13940,12 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "jsonrpsee", - "log", "parity-scale-codec", "sc-client-api", "sc-rpc-api", - "scale-info", "serde", "sp-core", "sp-runtime", @@ -12687,45 +13954,20 @@ dependencies = [ "trie-db", ] -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "array-bytes 4.2.0", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "ansi_term", "build-helper", "cargo_metadata", "filetime", + "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", - "toml", + "toml 0.7.8", "walkdir", "wasm-opt", ] @@ -12745,6 +13987,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + [[package]] name = "syn" version = "1.0.109" @@ -12758,9 +14006,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -12785,7 +14033,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -12808,28 +14056,28 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand", - "redox_syscall 0.3.5", - "rustix 0.37.19", - "windows-sys 0.45.0", + "fastrand 2.0.1", + "redox_syscall 0.4.1", + "rustix 0.38.21", + "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -12863,37 +14111,43 @@ dependencies = [ ] [[package]] -name = "test-runtime-constants" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", + "thiserror-impl", ] [[package]] -name = "thiserror" -version = "1.0.40" +name = "thiserror-core" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" dependencies = [ - "thiserror-impl", + "thiserror-core-impl", +] + +[[package]] +name = "thiserror-core-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -12936,9 +14190,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-ctl" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37706572f4b151dff7a0146e040804e9c26fe3a3118591112f05cf12a4216c1" +checksum = "619bfed27d807b54f7f776b9430d4f8060e66ee138a28632ca898584d462c31c" dependencies = [ "libc", "paste", @@ -12947,9 +14201,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -12957,22 +14211,13 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ + "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -12980,15 +14225,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] @@ -13005,13 +14250,22 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", "unicode-normalization", "wasm-bindgen", "zeroize", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -13039,19 +14293,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.1" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ - "autocfg", + "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] @@ -13064,18 +14318,28 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", +] + +[[package]] +name = "tokio-retry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" +dependencies = [ + "pin-project", + "rand 0.8.5", + "tokio", ] [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.20.8", + "rustls 0.21.8", "tokio", - "webpki 0.22.0", ] [[package]] @@ -13085,22 +14349,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tokio-util", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tracing", ] @@ -13114,19 +14378,36 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.1.0", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -13144,18 +14425,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.3.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags", + "bitflags 2.4.1", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tower-layer", "tower-service", ] @@ -13174,33 +14455,32 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -13218,9 +14498,10 @@ dependencies = [ [[package]] name = "tracing-gum" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "coarsetime", "polkadot-node-jaeger", "polkadot-primitives", "tracing", @@ -13229,24 +14510,24 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "expander 0.0.6", + "expander 2.0.0", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -13289,7 +14570,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ - "hash-db 0.16.0", + "hash-db", "hashbrown 0.13.2", "log", "rustc-hex", @@ -13302,7 +14583,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ - "hash-db 0.16.0", + "hash-db", ] [[package]] @@ -13323,7 +14604,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.10", "thiserror", "tinyvec", "tokio", @@ -13360,7 +14641,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "async-trait", "clap", @@ -13371,7 +14652,6 @@ dependencies = [ "parity-scale-codec", "sc-cli", "sc-executor", - "sc-service", "serde", "serde_json", "sp-api", @@ -13391,7 +14671,7 @@ dependencies = [ "sp-version", "sp-weights", "substrate-rpc-client", - "zstd", + "zstd 0.12.4", ] [[package]] @@ -13412,7 +14692,7 @@ dependencies = [ "log", "md-5", "rand 0.8.5", - "ring", + "ring 0.16.20", "stun", "thiserror", "tokio", @@ -13433,15 +14713,15 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -13463,9 +14743,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -13484,9 +14764,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -13516,9 +14796,9 @@ dependencies = [ [[package]] name = "unsigned-varint" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" dependencies = [ "asynchronous-codec", "bytes", @@ -13532,14 +14812,20 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna 0.4.0", "percent-encoding", ] @@ -13551,11 +14837,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.11", ] [[package]] @@ -13573,7 +14859,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "ver-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "derive_more", "futures", @@ -13611,15 +14897,15 @@ dependencies = [ [[package]] name = "waker-fn" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -13627,11 +14913,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -13641,12 +14926,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -13655,9 +14934,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -13665,24 +14944,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.36" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -13692,9 +14971,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -13702,22 +14981,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wasm-instrument" @@ -13730,14 +15009,14 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a303793cbc01fb96551badfc7367db6007396bba6bac97936b3c8b6f7fdb41" +checksum = "effbef3bd1dde18acb401f73e740a6f3d4a1bc651e9773bddc512fe4d8d68f67" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -13746,9 +15025,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c9deb56f8a9f2ec177b3bd642a8205621835944ed5da55f2388ef216aca5a4" +checksum = "c09e24eb283919ace2ed5733bda4842a59ce4c8de110ef5c6d98859513d17047" dependencies = [ "anyhow", "cxx", @@ -13758,15 +15037,14 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.111.0" +version = "0.114.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4432e28b542738a9776cedf92e8a99d8991c7b4667ee2c7ccddfb479dd2856a7" +checksum = "36f2f817bed2e8d65eb779fa37317e74de15585751f903c9118342d1970703a4" dependencies = [ "anyhow", "cc", "cxx", "cxx-build", - "regex", ] [[package]] @@ -13786,61 +15064,67 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.13.2" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" +checksum = "1f341edb80021141d4ae6468cbeefc50798716a347d4085c3811900049ea8945" dependencies = [ - "parity-wasm", - "wasmi-validation", + "smallvec", + "spin 0.9.8", + "wasmi_arena", "wasmi_core", + "wasmparser-nostd", ] [[package]] -name = "wasmi-validation" -version = "0.5.0" +name = "wasmi_arena" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] +checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" [[package]] name = "wasmi_core" -version = "0.2.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" dependencies = [ "downcast-rs", - "libm 0.2.7", - "memory_units", - "num-rational", + "libm 0.2.8", "num-traits", - "region", + "paste", ] [[package]] name = "wasmparser" -version = "0.100.0" +version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] +[[package]] +name = "wasmparser-nostd" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9157cab83003221bfd385833ab587a039f5d6fa7304854042ba358a3b09e0724" +dependencies = [ + "indexmap-nostd", +] + [[package]] name = "wasmtime" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" +checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", - "object 0.29.0", + "object 0.30.4", "once_cell", "paste", "psm", @@ -13853,43 +15137,43 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-asm-macros" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" +checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ceb3adf61d654be0be67fffdce42447b0880481348785be5fe40b5dd7663a4c" +checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.13.1", + "base64 0.21.5", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.17", "serde", - "sha2 0.10.6", - "toml", - "windows-sys 0.42.0", - "zstd", + "sha2 0.10.8", + "toml 0.5.11", + "windows-sys 0.45.0", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] name = "wasmtime-cranelift" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c366bb8647e01fd08cb5589976284b00abfded5529b33d7e7f3f086c68304a4" +checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" dependencies = [ "anyhow", "cranelift-codegen", @@ -13897,27 +15181,43 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.26.2", + "gimli 0.27.3", "log", - "object 0.29.0", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli 0.27.3", + "object 0.30.4", + "target-lexicon", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" +checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli 0.26.2", - "indexmap", + "gimli 0.27.3", + "indexmap 1.9.3", "log", - "object 0.29.0", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -13927,18 +15227,18 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" +checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line 0.17.0", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli 0.26.2", + "gimli 0.27.3", "log", - "object 0.29.0", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -13946,60 +15246,60 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-jit-debug" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" +checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object 0.29.0", + "object 0.30.4", "once_cell", - "rustix 0.36.14", + "rustix 0.36.17", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" +checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" dependencies = [ "cfg-if", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-runtime" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" +checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", "mach", "memfd", - "memoffset 0.6.5", + "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-types" -version = "6.0.2" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" +checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", @@ -14009,9 +15309,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -14023,18 +15323,18 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -14043,9 +15343,15 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki 0.22.4", ] +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "webrtc" version = "0.6.0" @@ -14062,17 +15368,17 @@ dependencies = [ "rand 0.8.5", "rcgen 0.9.3", "regex", - "ring", + "ring 0.16.20", "rtcp", "rtp", "rustls 0.19.1", "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.8", "stun", "thiserror", - "time 0.3.21", + "time", "tokio", "turn", "url", @@ -14104,12 +15410,12 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" dependencies = [ "aes 0.6.0", - "aes-gcm 0.10.2", + "aes-gcm 0.10.3", "async-trait", "bincode", "block-modes", @@ -14117,29 +15423,28 @@ dependencies = [ "ccm", "curve25519-dalek 3.2.0", "der-parser 8.2.0", - "elliptic-curve", + "elliptic-curve 0.12.3", "hkdf", "hmac 0.12.1", "log", - "oid-registry 0.6.1", "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", + "rcgen 0.10.0", + "ring 0.16.20", "rustls 0.19.1", - "sec1", + "sec1 0.3.0", "serde", "sha1", - "sha2 0.10.6", - "signature", + "sha2 0.10.8", + "signature 1.6.4", "subtle", "thiserror", "tokio", "webpki 0.21.4", "webrtc-util", - "x25519-dalek 2.0.0-pre.1", + "x25519-dalek 2.0.0", "x509-parser 0.13.2", ] @@ -14174,7 +15479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.10", "thiserror", "tokio", "webrtc-util", @@ -14241,7 +15546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -14257,29 +15562,32 @@ dependencies = [ [[package]] name = "westend-runtime" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ + "binary-merkle-tree", "bitvec", "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", + "hex-literal 0.4.1", "log", "pallet-authority-discovery", "pallet-authorship", "pallet-babe", "pallet-bags-list", "pallet-balances", + "pallet-beefy", + "pallet-beefy-mmr", "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -14287,6 +15595,8 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", + "pallet-mmr", "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", @@ -14314,7 +15624,7 @@ dependencies = [ "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", - "polkadot-parachain", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-common", "polkadot-runtime-parachains", @@ -14324,6 +15634,7 @@ dependencies = [ "serde_derive", "smallvec", "sp-api", + "sp-application-crypto", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", @@ -14338,19 +15649,20 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", + "staging-xcm", + "staging-xcm-builder", + "staging-xcm-executor", "substrate-wasm-builder", "westend-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", ] [[package]] name = "westend-runtime-constants" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "frame-support", "polkadot-primitives", @@ -14363,20 +15675,21 @@ dependencies = [ [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix 0.38.21", ] [[package]] name = "wide" -version = "0.7.9" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" +checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" dependencies = [ "bytemuck", "safe_arch", @@ -14384,9 +15697,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -14406,9 +15719,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -14421,39 +15734,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" -dependencies = [ - "windows_aarch64_msvc 0.34.0", - "windows_i686_gnu 0.34.0", - "windows_i686_msvc 0.34.0", - "windows_x86_64_gnu 0.34.0", - "windows_x86_64_msvc 0.34.0", -] - -[[package]] -name = "windows" -version = "0.48.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-targets 0.48.0", + "windows-core", + "windows-targets 0.48.5", ] [[package]] -name = "windows-sys" -version = "0.42.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets 0.48.5", ] [[package]] @@ -14471,7 +15766,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -14491,17 +15786,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -14512,15 +15807,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.34.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -14530,15 +15819,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.34.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -14548,15 +15831,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.34.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -14566,15 +15843,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.34.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -14584,9 +15855,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -14596,15 +15867,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.34.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -14614,26 +15879,27 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -14658,12 +15924,13 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.1.1", "rand_core 0.6.4", + "serde", "zeroize", ] @@ -14680,10 +15947,10 @@ dependencies = [ "lazy_static", "nom", "oid-registry 0.4.0", - "ring", + "ring 0.16.20", "rusticata-macros", "thiserror", - "time 0.3.21", + "time", ] [[package]] @@ -14701,101 +15968,50 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.21", -] - -[[package]] -name = "xcm" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "bounded-collections", - "derivative", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-weights", - "xcm-procedural", -] - -[[package]] -name = "xcm-builder" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "pallet-transaction-payment", - "parity-scale-codec", - "polkadot-parachain", - "scale-info", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-executor", + "time", ] [[package]] name = "xcm-emulator" version = "0.1.0" -source = "git+https://github.com/shaunxw/xcm-simulator?rev=bea35c799d725a4233db6b9108ee2ed5bbfc1aed#bea35c799d725a4233db6b9108ee2ed5bbfc1aed" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-test-relay-sproof-builder", "frame-support", "frame-system", - "parachain-info", + "impl-trait-for-tuples", + "lazy_static", + "log", + "pallet-balances", + "pallet-message-queue", + "parachains-common", "parity-scale-codec", "paste", + "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-io", - "sp-std", - "xcm", - "xcm-executor", -] - -[[package]] -name = "xcm-executor" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" -dependencies = [ - "environmental", - "frame-benchmarking", - "frame-support", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", "sp-std", - "sp-weights", - "xcm", + "sp-tracing", + "staging-xcm", + "staging-xcm-executor", ] [[package]] name = "xcm-procedural" -version = "0.9.40" -source = "git+https://github.com/mangata-finance//polkadot?branch=mangata-dev#c484ce03b879191739e1de2333ab04667a2ffb44" +version = "1.0.0" +source = "git+https://github.com/mangata-finance//polkadot-sdk?branch=develop#2efab3ddc56a2ed1cec346cd6f79e85e895e8444" dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.39", ] [[package]] @@ -14821,6 +16037,7 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", + "scale-info", "serde", "serde_json", "sp-api", @@ -14849,7 +16066,27 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.21", + "time", +] + +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] @@ -14869,7 +16106,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.39", ] [[package]] @@ -14878,7 +16115,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", ] [[package]] @@ -14891,28 +16137,22 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] - -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" - -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" - -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" diff --git a/Cargo.toml b/Cargo.toml index aeae1a639f..b3d6632527 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,8 @@ +[workspace.package] +authors = ["Mangata Team"] +edition = "2018" +repository = "https://github.com/mangata-finance/mangata-node.git" + [profile.dev] split-debuginfo = "unpacked" @@ -21,1498 +26,284 @@ members = [ 'runtime/integration-test', ] -# patch generated by ./scripts/dev_manifest.sh -[patch."https://github.com/mangata-finance/mangata-node"] -pallet-sudo-origin = { path = "./pallets/sudo-origin" } -xyk-runtime-api = { path = "./pallets/xyk/runtime-api" } -xyk-rpc = { path = "./pallets/xyk/rpc" } -mangata-node = { path = "./node" } -mangata-rpc-nonce = { path = "./rpc/nonce" } -runtime-integration-test = { path = "./runtime/integration-test" } -mangata-kusama-runtime = { path = "./runtime/mangata-kusama" } -mangata-rococo-runtime = { path = "./runtime/mangata-rococo" } -pallet-issuance = { path = "./pallets/issuance" } - -# patch generated by ./scripts/dev-0.9.29_manifest.sh -[patch."https://github.com/mangata-finance/open-runtime-module-library"] -orml-unknown-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-xtokens = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-asset-registry = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-xcm-support = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-utilities = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-xcm = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-traits = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -orml-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-library", branch = "mangata-dev" } -# orml-unknown-tokens = { path = "../open-runtime-module-library/unknown-tokens" } -# orml-xtokens = { path = "../open-runtime-module-library/xtokens" } -# orml-asset-registry = { path = "../open-runtime-module-library/asset-registry" } -# orml-xcm-support = { path = "../open-runtime-module-library/xcm-support" } -# orml-utilities = { path = "../open-runtime-module-library/utilities" } -# orml-xcm = { path = "../open-runtime-module-library/xcm" } -# orml-traits = { path = "../open-runtime-module-library/traits" } -# orml-tokens = { path = "../open-runtime-module-library/tokens" } - -# patch generated by ./scripts/dev_manifest.sh -[patch."https://github.com/mangata-finance/moonbeam"] -# parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/update-staking-benchmarks" } -parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } -# parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } - -[patch."https://github.com/mangata-finance/crowdloan-rewards"] -pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "mangata-dev" } -# pallet-crowdloan-rewards = { path = "../crowdloan-rewards" } - -# patch generated by ./scripts/dev_manifest.sh -[patch."https://github.com/paritytech/cumulus"] -cumulus-relay-chain-minimal-node = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-collator = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-consensus-common = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-consensus-aura = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-cli = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-pov-recovery = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-network = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-service = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-aura-ext = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-parachain-system = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-xcm = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-dmp-queue = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -parachain-info = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-utility = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-timestamp = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-core = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } - -# patch generated by ./scripts/dev-0.9.29_manifest.sh -[patch."https://github.com/mangata-finance/cumulus"] -cumulus-relay-chain-minimal-node = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-collator = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-consensus-common = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-consensus-aura = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-cli = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-pov-recovery = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-network = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-client-service = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-relay-chain-interface = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-aura-ext = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-parachain-system = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-xcm = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-pallet-dmp-queue = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -parachain-info = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-utility = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-timestamp = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-core = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/mangata-finance//cumulus", branch = "mangata-dev" } - -# patch generated by ./scripts/dev_manifest.sh -[patch."https://github.com/mangata-finance/polkadot"] -polkadot-core-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-statement-table = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-cli = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-overseer = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-client = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -tracing-gum-proc-macro = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -tracing-gum = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-jaeger = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-collation-generation = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem-util = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-candidate-validation = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-approval-voting = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-av-store = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-provisioner = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-parachains-inherent = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-backing = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-chain-api = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-bitfield-signing = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-pvf-checker = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-dispute-coordinator = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-pvf = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-runtime-api = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-chain-selection = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-performance-test = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-test-service = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem-types = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-bitfield-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-gossip-support = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-statement-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-dispute-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-collator-protocol = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-approval-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-network-bridge = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-recovery = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-network-protocol = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-metrics = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-service = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-rpc = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-erasure-coding = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -kusama-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -kusama-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -rococo-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -rococo-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -test-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-test-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-parachains = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -slot-range-helper = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-common = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-metrics = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -pallet-xcm = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-executor = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-procedural = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } - -# patch generated by ./scripts/dev_manifest.sh -[patch."https://github.com/paritytech/polkadot"] -polkadot-core-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-statement-table = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-cli = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-overseer = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-client = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -tracing-gum-proc-macro = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -tracing-gum = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-jaeger = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-collation-generation = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem-util = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-candidate-validation = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-approval-voting = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-av-store = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-provisioner = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-parachains-inherent = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-backing = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-chain-api = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-bitfield-signing = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-pvf-checker = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-dispute-coordinator = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-pvf = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-runtime-api = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-core-chain-selection = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-performance-test = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-test-service = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-subsystem-types = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-bitfield-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-gossip-support = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-statement-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-dispute-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-collator-protocol = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-approval-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-network-bridge = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-recovery = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-network-protocol = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-availability-distribution = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-node-metrics = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-service = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-rpc = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-erasure-coding = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-primitives = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -kusama-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -kusama-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -rococo-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -rococo-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -test-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-test-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-constants = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-parachains = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -slot-range-helper = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-common = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -polkadot-runtime-metrics = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -pallet-xcm = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-executor = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } -xcm-procedural = { git = "https://github.com/mangata-finance//polkadot", branch = "mangata-dev" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/mangata-finance/polkadot"] -# polkadot-core-primitives = { path = "../polkadot/core-primitives" } -# polkadot-statement-table = { path = "../polkadot/statement-table" } -# polkadot-cli = { path = "../polkadot/cli" } -# polkadot-overseer = { path = "../polkadot/node/overseer" } -# polkadot-client = { path = "../polkadot/node/client" } -# tracing-gum-proc-macro = { path = "../polkadot/node/gum/proc-macro" } -# tracing-gum = { path = "../polkadot/node/gum" } -# polkadot-node-jaeger = { path = "../polkadot/node/jaeger" } -# polkadot-node-collation-generation = { path = "../polkadot/node/collation-generation" } -# polkadot-node-subsystem-util = { path = "../polkadot/node/subsystem-util" } -# polkadot-node-core-candidate-validation = { path = "../polkadot/node/core/candidate-validation" } -# polkadot-node-core-approval-voting = { path = "../polkadot/node/core/approval-voting" } -# polkadot-node-core-av-store = { path = "../polkadot/node/core/av-store" } -# polkadot-node-core-provisioner = { path = "../polkadot/node/core/provisioner" } -# polkadot-node-core-parachains-inherent = { path = "../polkadot/node/core/parachains-inherent" } -# polkadot-node-core-backing = { path = "../polkadot/node/core/backing" } -# polkadot-node-core-chain-api = { path = "../polkadot/node/core/chain-api" } -# polkadot-node-core-bitfield-signing = { path = "../polkadot/node/core/bitfield-signing" } -# polkadot-node-core-pvf-checker = { path = "../polkadot/node/core/pvf-checker" } -# polkadot-node-core-dispute-coordinator = { path = "../polkadot/node/core/dispute-coordinator" } -# polkadot-node-core-pvf = { path = "../polkadot/node/core/pvf" } -# polkadot-node-core-runtime-api = { path = "../polkadot/node/core/runtime-api" } -# polkadot-node-core-chain-selection = { path = "../polkadot/node/core/chain-selection" } -# polkadot-performance-test = { path = "../polkadot/node/test/performance-test" } -# polkadot-test-service = { path = "../polkadot/node/test/service" } -# polkadot-node-subsystem = { path = "../polkadot/node/subsystem" } -# polkadot-node-primitives = { path = "../polkadot/node/primitives" } -# polkadot-node-subsystem-types = { path = "../polkadot/node/subsystem-types" } -# polkadot-availability-bitfield-distribution = { path = "../polkadot/node/network/bitfield-distribution" } -# polkadot-gossip-support = { path = "../polkadot/node/network/gossip-support" } -# polkadot-statement-distribution = { path = "../polkadot/node/network/statement-distribution" } -# polkadot-dispute-distribution = { path = "../polkadot/node/network/dispute-distribution" } -# polkadot-collator-protocol = { path = "../polkadot/node/network/collator-protocol" } -# polkadot-approval-distribution = { path = "../polkadot/node/network/approval-distribution" } -# polkadot-network-bridge = { path = "../polkadot/node/network/bridge" } -# polkadot-availability-recovery = { path = "../polkadot/node/network/availability-recovery" } -# polkadot-node-network-protocol = { path = "../polkadot/node/network/protocol" } -# polkadot-availability-distribution = { path = "../polkadot/node/network/availability-distribution" } -# polkadot-node-metrics = { path = "../polkadot/node/metrics" } -# polkadot-service = { path = "../polkadot/node/service" } -# polkadot-rpc = { path = "../polkadot/rpc" } -# polkadot-erasure-coding = { path = "../polkadot/erasure-coding" } -# polkadot-parachain = { path = "../polkadot/parachain" } -# polkadot-primitives = { path = "../polkadot/primitives" } -# kusama-runtime-constants = { path = "../polkadot/runtime/kusama/constants" } -# kusama-runtime = { path = "../polkadot/runtime/kusama" } -# rococo-runtime-constants = { path = "../polkadot/runtime/rococo/constants" } -# rococo-runtime = { path = "../polkadot/runtime/rococo" } -# test-runtime-constants = { path = "../polkadot/runtime/test-runtime/constants" } -# polkadot-test-runtime = { path = "../polkadot/runtime/test-runtime" } -# polkadot-runtime-constants = { path = "../polkadot/runtime/polkadot/constants" } -# polkadot-runtime = { path = "../polkadot/runtime/polkadot" } -# polkadot-runtime-parachains = { path = "../polkadot/runtime/parachains" } -# slot-range-helper = { path = "../polkadot/runtime/common/slot_range_helper" } -# polkadot-runtime-common = { path = "../polkadot/runtime/common" } -# polkadot-runtime-metrics = { path = "../polkadot/runtime/metrics" } -# xcm-builder = { path = "../polkadot/xcm/xcm-builder" } -# pallet-xcm = { path = "../polkadot/xcm/pallet-xcm" } -# xcm-executor = { path = "../polkadot/xcm/xcm-executor" } -# xcm = { path = "../polkadot/xcm" } -# xcm-procedural = { path = "../polkadot/xcm/procedural" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/paritytech/polkadot"] -# polkadot-core-primitives = { path = "../polkadot/core-primitives" } -# polkadot-statement-table = { path = "../polkadot/statement-table" } -# polkadot-cli = { path = "../polkadot/cli" } -# polkadot-overseer = { path = "../polkadot/node/overseer" } -# polkadot-client = { path = "../polkadot/node/client" } -# tracing-gum-proc-macro = { path = "../polkadot/node/gum/proc-macro" } -# tracing-gum = { path = "../polkadot/node/gum" } -# polkadot-node-jaeger = { path = "../polkadot/node/jaeger" } -# polkadot-node-collation-generation = { path = "../polkadot/node/collation-generation" } -# polkadot-node-subsystem-util = { path = "../polkadot/node/subsystem-util" } -# polkadot-node-core-candidate-validation = { path = "../polkadot/node/core/candidate-validation" } -# polkadot-node-core-approval-voting = { path = "../polkadot/node/core/approval-voting" } -# polkadot-node-core-av-store = { path = "../polkadot/node/core/av-store" } -# polkadot-node-core-provisioner = { path = "../polkadot/node/core/provisioner" } -# polkadot-node-core-parachains-inherent = { path = "../polkadot/node/core/parachains-inherent" } -# polkadot-node-core-backing = { path = "../polkadot/node/core/backing" } -# polkadot-node-core-chain-api = { path = "../polkadot/node/core/chain-api" } -# polkadot-node-core-bitfield-signing = { path = "../polkadot/node/core/bitfield-signing" } -# polkadot-node-core-pvf-checker = { path = "../polkadot/node/core/pvf-checker" } -# polkadot-node-core-dispute-coordinator = { path = "../polkadot/node/core/dispute-coordinator" } -# polkadot-node-core-pvf = { path = "../polkadot/node/core/pvf" } -# polkadot-node-core-runtime-api = { path = "../polkadot/node/core/runtime-api" } -# polkadot-node-core-chain-selection = { path = "../polkadot/node/core/chain-selection" } -# polkadot-performance-test = { path = "../polkadot/node/test/performance-test" } -# polkadot-test-service = { path = "../polkadot/node/test/service" } -# polkadot-node-subsystem = { path = "../polkadot/node/subsystem" } -# polkadot-node-primitives = { path = "../polkadot/node/primitives" } -# polkadot-node-subsystem-types = { path = "../polkadot/node/subsystem-types" } -# polkadot-availability-bitfield-distribution = { path = "../polkadot/node/network/bitfield-distribution" } -# polkadot-gossip-support = { path = "../polkadot/node/network/gossip-support" } -# polkadot-statement-distribution = { path = "../polkadot/node/network/statement-distribution" } -# polkadot-dispute-distribution = { path = "../polkadot/node/network/dispute-distribution" } -# polkadot-collator-protocol = { path = "../polkadot/node/network/collator-protocol" } -# polkadot-approval-distribution = { path = "../polkadot/node/network/approval-distribution" } -# polkadot-network-bridge = { path = "../polkadot/node/network/bridge" } -# polkadot-availability-recovery = { path = "../polkadot/node/network/availability-recovery" } -# polkadot-node-network-protocol = { path = "../polkadot/node/network/protocol" } -# polkadot-availability-distribution = { path = "../polkadot/node/network/availability-distribution" } -# polkadot-node-metrics = { path = "../polkadot/node/metrics" } -# polkadot-service = { path = "../polkadot/node/service" } -# polkadot-rpc = { path = "../polkadot/rpc" } -# polkadot-erasure-coding = { path = "../polkadot/erasure-coding" } -# polkadot-parachain = { path = "../polkadot/parachain" } -# polkadot-primitives = { path = "../polkadot/primitives" } -# kusama-runtime-constants = { path = "../polkadot/runtime/kusama/constants" } -# kusama-runtime = { path = "../polkadot/runtime/kusama" } -# rococo-runtime-constants = { path = "../polkadot/runtime/rococo/constants" } -# rococo-runtime = { path = "../polkadot/runtime/rococo" } -# test-runtime-constants = { path = "../polkadot/runtime/test-runtime/constants" } -# polkadot-test-runtime = { path = "../polkadot/runtime/test-runtime" } -# polkadot-runtime-constants = { path = "../polkadot/runtime/polkadot/constants" } -# polkadot-runtime = { path = "../polkadot/runtime/polkadot" } -# polkadot-runtime-parachains = { path = "../polkadot/runtime/parachains" } -# slot-range-helper = { path = "../polkadot/runtime/common/slot_range_helper" } -# polkadot-runtime-common = { path = "../polkadot/runtime/common" } -# polkadot-runtime-metrics = { path = "../polkadot/runtime/metrics" } -# xcm-builder = { path = "../polkadot/xcm/xcm-builder" } -# pallet-xcm = { path = "../polkadot/xcm/pallet-xcm" } -# xcm-executor = { path = "../polkadot/xcm/xcm-executor" } -# xcm = { path = "../polkadot/xcm" } -# xcm-procedural = { path = "../polkadot/xcm/procedural" } - - # patch generated by ./scripts/dev-0.9.29_manifest.sh -[patch."https://github.com/mangata-finance/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - -# patch generated by ./scripts/dev-0.9.29_manifest.sh -[patch."https://github.com/paritytech/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - -# patch generated by ./scripts/dev-0.9.29_manifest.sh -[patch."https://github.com/PureStake/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/mangata-finance/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } - -# # # patch generated by ./scripts/dev_manifest.sh -# # [patch."https://github.com/paritytech/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/PureStake/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/mangata-finance/cumulus"] -# cumulus-relay-chain-minimal-node = { path = "../cumulus/client/relay-chain-minimal-node" } -# cumulus-client-collator = { path = "../cumulus/client/collator" } -# cumulus-relay-chain-rpc-interface = { path = "../cumulus/client/relay-chain-rpc-interface" } -# cumulus-relay-chain-inprocess-interface = { path = "../cumulus/client/relay-chain-inprocess-interface" } -# cumulus-client-consensus-common = { path = "../cumulus/client/consensus/common" } -# cumulus-client-consensus-aura = { path = "../cumulus/client/consensus/aura" } -# cumulus-client-cli = { path = "../cumulus/client/cli" } -# cumulus-client-pov-recovery = { path = "../cumulus/client/pov-recovery" } -# cumulus-client-network = { path = "../cumulus/client/network" } -# cumulus-client-service = { path = "../cumulus/client/service" } -# cumulus-relay-chain-interface = { path = "../cumulus/client/relay-chain-interface" } -# cumulus-pallet-xcmp-queue = { path = "../cumulus/pallets/xcmp-queue" } -# cumulus-pallet-aura-ext = { path = "../cumulus/pallets/aura-ext" } -# cumulus-pallet-parachain-system-proc-macro = { path = "../cumulus/pallets/parachain-system/proc-macro" } -# cumulus-pallet-parachain-system = { path = "../cumulus/pallets/parachain-system" } -# cumulus-pallet-xcm = { path = "../cumulus/pallets/xcm" } -# cumulus-pallet-dmp-queue = { path = "../cumulus/pallets/dmp-queue" } -# cumulus-test-relay-sproof-builder = { path = "../cumulus/test/relay-sproof-builder" } -# parachain-info = { path = "../cumulus/parachains/pallets/parachain-info" } -# cumulus-primitives-utility = { path = "../cumulus/primitives/utility" } -# cumulus-primitives-timestamp = { path = "../cumulus/primitives/timestamp" } -# cumulus-primitives-core = { path = "../cumulus/primitives/core" } -# cumulus-primitives-parachain-inherent = { path = "../cumulus/primitives/parachain-inherent" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/paritytech/cumulus"] -# cumulus-relay-chain-minimal-node = { path = "../cumulus/client/relay-chain-minimal-node" } -# cumulus-client-collator = { path = "../cumulus/client/collator" } -# cumulus-relay-chain-rpc-interface = { path = "../cumulus/client/relay-chain-rpc-interface" } -# cumulus-relay-chain-inprocess-interface = { path = "../cumulus/client/relay-chain-inprocess-interface" } -# cumulus-client-consensus-common = { path = "../cumulus/client/consensus/common" } -# cumulus-client-consensus-aura = { path = "../cumulus/client/consensus/aura" } -# cumulus-client-cli = { path = "../cumulus/client/cli" } -# cumulus-client-pov-recovery = { path = "../cumulus/client/pov-recovery" } -# cumulus-client-network = { path = "../cumulus/client/network" } -# cumulus-client-service = { path = "../cumulus/client/service" } -# cumulus-relay-chain-interface = { path = "../cumulus/client/relay-chain-interface" } -# cumulus-pallet-xcmp-queue = { path = "../cumulus/pallets/xcmp-queue" } -# cumulus-pallet-aura-ext = { path = "../cumulus/pallets/aura-ext" } -# cumulus-pallet-parachain-system-proc-macro = { path = "../cumulus/pallets/parachain-system/proc-macro" } -# cumulus-pallet-parachain-system = { path = "../cumulus/pallets/parachain-system" } -# cumulus-pallet-xcm = { path = "../cumulus/pallets/xcm" } -# cumulus-pallet-dmp-queue = { path = "../cumulus/pallets/dmp-queue" } -# cumulus-test-relay-sproof-builder = { path = "../cumulus/test/relay-sproof-builder" } -# parachain-info = { path = "../cumulus/parachains/pallets/parachain-info" } -# cumulus-primitives-utility = { path = "../cumulus/primitives/utility" } -# cumulus-primitives-timestamp = { path = "../cumulus/primitives/timestamp" } -# cumulus-primitives-core = { path = "../cumulus/primitives/core" } -# cumulus-primitives-parachain-inherent = { path = "../cumulus/primitives/parachain-inherent" } +# `orml/develop` & `crowdloan/develop` points to versioned `polkadot-sdk/release-mangata-v*`, +# but mangata-node uses `polkadot-sdk/develop` so we need to patch to use the same refs +# patch generated by './scripts/dev_manifest.sh ../polkadot-sdk' & replaced local path with `develop` branch on polkadot-sdk +[patch."https://github.com/mangata-finance/polkadot-sdk"] +pallet-whitelist = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-referenda = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-indices = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-offences = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-asset-tx-payment = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-collective-mangata = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-proxy = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-identity = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-conviction-voting = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +mangata-support = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-child-bounties = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-beefy-mmr = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-collective = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-recovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-preimage = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-multisig = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-scheduler = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-nomination-pools = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-society = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-utility-mangata = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-authorship = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-bounties = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-fast-unstake = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-grandpa = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-ranked-collective = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-system = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-system-benchmarking = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-mmr = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-vesting = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-support = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-support-procedural = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-support-procedural-tools = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-authority-discovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-im-online = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-staking = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-staking-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-bags-list = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-election-provider-support = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-tips = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-balances = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-message-queue = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-nis = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-state-trie-migration = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-beefy = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-aura = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-sudo = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-benchmarking = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-treasury = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-try-runtime = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-timestamp = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-babe = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-elections-phragmen = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-assets = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-democracy = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-membership = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-root-testing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-utility = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-executive = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-session = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +fork-tree = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-build-script-utils = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-remote-externalities = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +frame-benchmarking-cli = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +try-runtime-cli = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-rpc-client = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +binary-merkle-tree = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-database = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-runtime-interface = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus-grandpa = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus-beefy = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus-aura = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus-babe = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-consensus-slots = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-tracing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-ver = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-core = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-core-hashing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-state-machine = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-keystore = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-metadata-ir = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-statement-store = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-weights = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-io = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-runtime = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-inherents = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-transaction-pool = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-std = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-storage = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-panic-handler = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-debug-derive = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-blockchain = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-externalities = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-trie = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-mmr-primitives = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +mangata-types = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-version = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-version-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-authority-discovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-block-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-keyring = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-staking = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-wasm-interface = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +extrinsic-shuffler = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-arithmetic = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-api-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-offchain = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-timestamp = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-application-crypto = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +ver-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-npos-elections = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-genesis-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sp-session = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-grandpa = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-grandpa-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-epochs = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-beefy = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-beefy-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-aura = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-babe = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-consensus-slots = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-tracing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-state-db = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-proposer-metrics = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-keystore = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-rpc-server = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-bitswap = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-transactions = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-light = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-sync = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-informant = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-transaction-pool = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-utils = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-cli = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-chain-spec = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-chain-spec-derive = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-sync-state-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-basic-authorship = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-block-builder-ver = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +mmr-gadget = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +mmr-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-storage-monitor = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-authority-discovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-block-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-allocator = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-network-gossip = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-client-db = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-client-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-sysinfo = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-executor = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-executor-wasmtime = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-executor-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-telemetry = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-offchain = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-service = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +sc-rpc-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +xcm-emulator = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-primitives-core = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-primitives-aura = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-primitives-timestamp = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-primitives-utility = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-xcm = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-dmp-queue = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-aura-ext = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-session-benchmarking = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-parachain-system = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-collator-selection = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-consensus-proposer = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-consensus-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-consensus-relay-chain = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-consensus-aura = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-relay-chain-interface = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-network = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-cli = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-pov-recovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-collator = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-client-service = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +parachains-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +parachain-info = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-parachain-primitives = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +staging-xcm = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +staging-xcm-executor = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +staging-xcm-builder = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +xcm-procedural = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +pallet-xcm = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-statement-table = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-erasure-coding = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-runtime-metrics = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +rococo-runtime = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +rococo-runtime-constants = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +staging-kusama-runtime = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +kusama-runtime-constants = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-runtime-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +slot-range-helper = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +westend-runtime-constants = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-runtime-constants = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-runtime-parachains = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-cli = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-primitives = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-metrics = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +tracing-gum = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +tracing-gum-proc-macro = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-candidate-validation = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-prospective-parachains = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-runtime-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-parachains-inherent = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-av-store = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-approval-voting = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-pvf = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-pvf-common = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-dispute-coordinator = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-chain-api = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-backing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-provisioner = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-chain-selection = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-bitfield-signing = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-core-pvf-checker = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-subsystem-types = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-collation-generation = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-jaeger = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-availability-bitfield-distribution = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-gossip-support = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-network-bridge = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-network-protocol = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-approval-distribution = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-statement-distribution = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-availability-distribution = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-availability-recovery = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-collator-protocol = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-dispute-distribution = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-primitives = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-subsystem = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-node-subsystem-util = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-service = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-overseer = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-rpc = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } +polkadot-core-primitives = { git = "https://github.com/mangata-finance//polkadot-sdk", branch = "develop" } diff --git a/README.md b/README.md index 45d9889ff6..1292bacf40 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Mangata operates as a cross-chain liquidity protocol, facilitating seamless tran [Mangata API Docs](https://mangata-finance.notion.site/Mangata-API-Docs-06f68bc6ba004416ae5c6686163b0468) ## Build mangata-node locally -- Install [docker](https://docs.docker.com/engine/install/ubuntu/) +- Install [docker](https://docs.docker.com/engine/install/ubuntu/) ### Compilie mangata-node binary and wasms artifacts - use docker wrapper for cargo to build `mangata-node` @@ -45,7 +45,7 @@ cargo test Run unit tests and generat code coverage report in html format: ```bash cargo install cargo-tarpaulin -cargo tarpaulin --timeout 120 --workspace -e runtime-integration-test mangata-node common-runtime mangata-kusama-runtime mangata-rococo-runtime --exclude-files **/mock.rs **/weights.rs **/weights/* --out Html +cargo tarpaulin --timeout 120 --workspace -e runtime-integration-test mangata-node common-runtime mangata-kusama-runtime mangata-rococo-runtime --exclude-files **/mock.rs **/weights.rs **/weights/* --out Html ``` ### Generate docker image @@ -75,7 +75,7 @@ Because of number of parameters is quite troublesome thats why we came up with d Dockerized setup requires you to build development docker image [mangatasolutions/mangata-node:dev](#generate-docker-image). -Start docker environment using, you need to +Start docker environment using, you need to ```bash cd ./launch @@ -90,7 +90,7 @@ once started, you can access nodes using port forwards - [127.0.0.1:9946](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9946#/explorer) - parachain 1st collator - [127.0.0.1:9947](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9946#/explorer) - parachain 2nd collator -Docker setup can be stopped using +Docker setup can be stopped using ```bash cd ./launch @@ -106,8 +106,8 @@ There is number of chain configurations available for both development and produ | chainspec (`--chain`) | Sudo | Description | |-------------------------------|----------------|----------------------------------| -| `kusama` | ******* | production kusama public mainnet | -| `kusama-local` | Alice | development kusama local testnet | -| `rococo` | ******* | production rococo public testnet | -| `rococo-local` | Alice | development rococo local testnet | +| `mangata-kusama` | ******* | production kusama public mainnet | +| `mangata-kusama-local` | Alice | development kusama local testnet | +| `mangata-rococo` | ******* | production rococo public testnet | +| `mangata-rococo-local` | Alice | development rococo local testnet | diff --git a/devops/helmfiles/config/fungible.yaml b/devops/helmfiles/config/fungible.yaml index b235d7f68f..f69bc65258 100644 --- a/devops/helmfiles/config/fungible.yaml +++ b/devops/helmfiles/config/fungible.yaml @@ -1,4 +1,4 @@ -nodeChain: rococo-local +nodeChain: mangata-rococo-local node01: accountKeySeed: '0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a' diff --git a/devops/parachain-launch/config.yml b/devops/parachain-launch/config.yml index 5f733fcd56..28bb4d80b9 100644 --- a/devops/parachain-launch/config.yml +++ b/devops/parachain-launch/config.yml @@ -1,5 +1,5 @@ relaychain: - image: parity/polkadot:v0.9.31 + image: --platform=linux/amd64 parity/polkadot:v1.1.0@sha256:cacf6f2f18f65d4d2ae4dd75b77ea655972d31e8f9c000bd393b70734c376d89 chain: rococo-local runtimeGenesisConfig: configuration: @@ -17,9 +17,9 @@ relaychain: - name: bob parachains: -- image: mangatasolutions/mangata-node:develop +- image: mangatasolutions/mangata-node:dev chain: - base: rococo-local + base: mangata-rococo-local collators: - alice - bob diff --git a/devops/parachain-launch/kusama-fast-oak.yml b/devops/parachain-launch/kusama-fast-oak.yml index f82aaf80a3..1b37727d54 100644 --- a/devops/parachain-launch/kusama-fast-oak.yml +++ b/devops/parachain-launch/kusama-fast-oak.yml @@ -28,7 +28,7 @@ relaychain: parachains: - image: mangatasolutions/mangata-node:develop-fast chain: - base: kusama-local + base: mangata-kusama-local collators: - alice - bob diff --git a/devops/parachain-launch/kusama-fast.yml b/devops/parachain-launch/kusama-fast.yml index 75b22e27ad..cea8a609c4 100644 --- a/devops/parachain-launch/kusama-fast.yml +++ b/devops/parachain-launch/kusama-fast.yml @@ -19,7 +19,7 @@ relaychain: parachains: - image: mangatasolutions/mangata-node:develop-fast chain: - base: kusama-local + base: mangata-kusama-local collators: - alice - bob diff --git a/devops/parachain-launch/mangata-karura.yml b/devops/parachain-launch/mangata-karura.yml index bfdd0dbcfa..d556e5097c 100644 --- a/devops/parachain-launch/mangata-karura.yml +++ b/devops/parachain-launch/mangata-karura.yml @@ -54,7 +54,7 @@ parachains: - image: mangatasolutions/mangata-node:dev chain: - base: rococo-local + base: mangata-rococo-local collators: - alice - bob diff --git a/devops/parachain-launch/mangata-oak.yml b/devops/parachain-launch/mangata-oak.yml index 2d179c039a..ede1753295 100644 --- a/devops/parachain-launch/mangata-oak.yml +++ b/devops/parachain-launch/mangata-oak.yml @@ -28,7 +28,7 @@ relaychain: parachains: - image: mangatasolutions/mangata-node:dev chain: - base: rococo-local + base: mangata-rococo-local collators: - alice - bob diff --git a/devops/parachain-launch/multichain.yml b/devops/parachain-launch/multichain.yml index b8bb4f0e14..4429c77cef 100644 --- a/devops/parachain-launch/multichain.yml +++ b/devops/parachain-launch/multichain.yml @@ -32,7 +32,7 @@ relaychain: parachains: - image: mangatasolutions/mangata-node:dev chain: - base: rococo-local + base: mangata-rococo-local collators: - alice - bob diff --git a/devops/zombienet/mangata-local.toml b/devops/zombienet/mangata-local.toml index c1d48b8135..6051f75fcf 100644 --- a/devops/zombienet/mangata-local.toml +++ b/devops/zombienet/mangata-local.toml @@ -3,28 +3,32 @@ provider = "native" timeout = 1000 [relaychain] -default_command = "../parity/polkadot/target/release/polkadot" -# chain = "westend-local" +default_command = "../../parity/polkadot-sdk/target/release/polkadot" +default_args = [ "-lparachain=trace" ] chain = "rococo-local" [[relaychain.nodes]] - name = "alice" + name = "one" ws_port = 9944 + args = ["-lparachain=trace,block_builder=trace,basic-authorship=trace,slots=trace,aura=trace,cumulus=trace,relay=trace,runtime=trace"] [[relaychain.nodes]] - name = "bob" + name = "two" [[parachains]] id = 2110 cumulus_based = true -chain = "mangata-rococo-local-testnet" +chain = "mangata-rococo-local" [[parachains.collators]] name = "alice" command = "./target/release/mangata-node" + args = ["-lparachain=trace,block_builder=trace,basic-authorship=trace,slots=trace,aura=trace,cumulus=trace,relay=trace,runtime=trace"] + validator = true ws_port = 9946 - rpc_port = 8866 [[parachains.collators]] name = "bob" - command = "./target/release/mangata-node" \ No newline at end of file + command = "./target/release/mangata-node" + args = [""] + validator = true diff --git a/devops/zombienet/oak-mangata-rococo.toml b/devops/zombienet/oak-mangata-rococo.toml index 9a633195cb..8d246d9535 100644 --- a/devops/zombienet/oak-mangata-rococo.toml +++ b/devops/zombienet/oak-mangata-rococo.toml @@ -31,7 +31,7 @@ chain = "turing-dev" [[parachains]] id = 2110 cumulus_based = true -chain = "mangata-rococo-local-testnet" +chain = "mangata-rococo-local" [[parachains.collators]] name = "alice" diff --git a/devops/zombienet/statemine_managata_rococo_local.toml b/devops/zombienet/statemine_managata_rococo_local.toml index 95fb363b63..8f170f5674 100644 --- a/devops/zombienet/statemine_managata_rococo_local.toml +++ b/devops/zombienet/statemine_managata_rococo_local.toml @@ -37,7 +37,7 @@ cumulus_based = true [[parachains]] id = 2110 -chain = "mangata-rococo-local-testnet" +chain = "mangata-rococo-local" cumulus_based = true [[parachains.collators]] diff --git a/docker-cargo.sh b/docker-cargo.sh index c7639f3936..54cb447f7c 100755 --- a/docker-cargo.sh +++ b/docker-cargo.sh @@ -4,7 +4,7 @@ CODE_ROOT=${CODE_ROOT:-${REPO_ROOT}} OUTPUT_DIR=docker-cargo/ CARGO_HOME=${CARGO_HOME:-$HOME/.cargo} -DOCKER_BUILDER_IMAGE=${DOCKER_BUILDER_IMAGE:-mangatasolutions/node-builder:multi} +DOCKER_BUILDER_IMAGE=${DOCKER_BUILDER_IMAGE:-mangatasolutions/node-builder:multi-nightly-2023-05-22} DOCKER_USER="$(id -u):$(id -g)" DOCKER_JOB_NAME=cargo-wrapper if [ -n "${DISABLE_TTY}" ]; then diff --git a/node/Cargo.toml b/node/Cargo.toml index 000f3df6aa..98c49b867e 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,168 +1,123 @@ [package] name = "mangata-node" -version = "0.1.0" +version = "0.32.0" authors = ["Mangata Team"] -edition = "2018" license = "Unlicense" +repository.workspace = true +edition.workspace = true build = "build.rs" +publish = false -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] +[dependencies] +clap = { version = "4.4.2", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0" } +futures = "0.3.28" +hex = "0.4.0" +jsonrpsee = { version = "0.16.2", features = ["server"] } +log = "0.4.20" +serde = { version = "1.0.188", features = ["derive"] } +serde_json = "1.0.105" + +# Local +common-runtime = { path = "../runtime/common"} +mangata-kusama-runtime = { path = "../runtime/mangata-kusama"} +mangata-rococo-runtime = { path = "../runtime/mangata-rococo"} +xyk-rpc = { path = "../pallets/xyk/rpc" } +xyk-runtime-api = { path = "../pallets/xyk/runtime-api" } + +# Substrate +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +frame-benchmarking-cli = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-basic-authorship-ver = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-chain-spec = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-cli = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-client-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-consensus = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-executor = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-network = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-network-sync = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-offchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-rpc = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-service = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-sysinfo = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-telemetry = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-tracing = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-transaction-pool = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-block-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-blockchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-consensus-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-inherents = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-keyring = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-keystore = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-offchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-transaction-pool = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-ver = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", features = ["helpers"] } +substrate-frame-rpc-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +ver-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } + +# Polkadot +polkadot-cli = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +xcm = { package = "staging-xcm", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } + +# Cumulus +cumulus-client-cli = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-collator = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-consensus-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-consensus-common = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-consensus-proposer = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-consensus-relay-chain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-client-service = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-primitives-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-relay-chain-interface = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +color-print = "0.3.4" -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +[dev-dependencies] +tempfile = "3.8.0" -[[bin]] -name = "mangata-node" -path = "bin/main.rs" +[build-dependencies] +substrate-build-script-utils = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } [features] -default = ['mangata-kusama', 'mangata-rococo'] +# default = [] +default = ["mangata-kusama", "mangata-rococo"] mangata-kusama = [ - "mangata-kusama-runtime/std", - "xyk-rpc/std", - "polkadot-cli/kusama-native", + "mangata-kusama-runtime/std", + "xyk-rpc/std", + "polkadot-cli/kusama-native", ] mangata-rococo = [ - "mangata-rococo-runtime/std", - "xyk-rpc/std", - "polkadot-cli/rococo-native", + "mangata-rococo-runtime/std", + "xyk-rpc/std", + "polkadot-cli/rococo-native", +] +runtime-benchmarks = [ + "frame-benchmarking-cli/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "mangata-kusama-runtime/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "sc-service/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] -#disable-execution = ['mangata-kusama-runtime/disable-execution'] -runtime-benchmarks = ["mangata-kusama-runtime/runtime-benchmarks", "polkadot-cli/runtime-benchmarks", "polkadot-test-service/runtime-benchmarks"] -fast-runtime = ["common-runtime/fast-runtime", "mangata-kusama-runtime/fast-runtime", "mangata-kusama-runtime/fast-runtime"] try-runtime = [ "mangata-kusama-runtime/try-runtime", - "mangata-rococo-runtime/try-runtime", - "try-runtime-cli/try-runtime", "polkadot-cli/try-runtime", - "polkadot-service/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", +] +network-protocol-staging = [ + "cumulus-client-service/network-protocol-staging", + "polkadot-cli/network-protocol-staging", ] - -[dependencies] -derive_more = "0.99.2" -futures = "0.3.9" -log = "0.4.17" -codec = { package = "parity-scale-codec", version = "3.0.0" } -clap = { version = "4.0.29", features = ["derive"] } -serde = { version = "1.0.137", features = ["derive"] } -hex-literal = "0.3.4" -hex = "0.4.0" - -# RPC related Dependencies -jsonrpsee = { version = "0.16.2", features = ["server"] } - -# Local Dependencies -common-runtime = { path = '../runtime/common', default-features = false, version = '4.0.0' } -mangata-kusama-runtime = { path = "../runtime/mangata-kusama", optional = true } -mangata-rococo-runtime = { path = "../runtime/mangata-rococo", optional = true } - -# Substrate Dependencies -mangata-types = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance/substrate", optional = true, branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -substrate-frame-rpc-system = { package = "mangata-rpc-nonce", path = "../rpc/nonce" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -## Substrate Client Dependencies -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-consensus-grandpa = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -## Substrate Primitive Dependencies -sp-io = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev", features = ["helpers"]} - - -# Cumulus dependencies -cumulus-client-cli = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -# cumulus-client-collator = { git = 'https://github.com/mangata-finance/cumulus', branch = mangata-dev' } -cumulus-client-consensus-aura = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-client-consensus-common = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-client-network = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-client-service = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-primitives-core = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-primitives-parachain-inherent = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-relay-chain-inprocess-interface = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-relay-chain-interface = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-relay-chain-rpc-interface = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } -cumulus-relay-chain-minimal-node = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev" } - - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-service = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-test-service = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } - - -# Mangata dependencies -xyk-rpc = { default-features = false, version = '2.0.0', path = '../pallets/xyk/rpc' } -xyk-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/xyk/runtime-api' } - - -[dev-dependencies] -sub-tokens = { git = "https://github.com/paritytech/substrate-debug-kit", branch = "master" } -sc-block-builder = { package="sc-block-builder-ver", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -tokio = { version = "1.15", features = ["macros", "time"] } -pallet-timestamp = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -cumulus-pallet-parachain-system = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev"} -cumulus-test-relay-sproof-builder = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev"} -polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -futures = "0.3.21" -schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false} -sp-core = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev", features = ["full_crypto"]} -extrinsic-shuffler = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev"} -cfg-if = "1.0.0" - diff --git a/node/bin/main.rs b/node/bin/main.rs deleted file mode 100644 index 3794aba827..0000000000 --- a/node/bin/main.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Substrate Parachain Mangata Node CLI - -#![warn(missing_docs)] - -fn main() -> sc_cli::Result<()> { - mangata_node::command::run() -} diff --git a/node/src/command_helper.rs b/node/src/benchmarking.rs similarity index 83% rename from node/src/command_helper.rs rename to node/src/benchmarking.rs index faddb6a40f..ce1ded7f04 100644 --- a/node/src/command_helper.rs +++ b/node/src/benchmarking.rs @@ -1,6 +1,4 @@ -// use crate::service::{create_extrinsic, FullClient}; - -// use node_runtime::SystemCall; +use crate::service::ParachainClient; use codec::Encode; use sc_cli::Result; use sc_client_api::BlockBackend; @@ -8,20 +6,15 @@ use sp_api::ProvideRuntimeApi; use sp_core::{crypto::key_types::AURA, Pair}; use sp_inherents::{InherentData, InherentDataProvider}; use sp_keyring::Sr25519Keyring; -use sp_keystore::SyncCryptoStore; +use sp_keystore::Keystore; use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion}; -use substrate_frame_rpc_system::AccountNonceApi; - use std::{cell::RefCell, rc::Rc, time::Duration}; +use substrate_frame_rpc_system::AccountNonceApi; -#[cfg(feature = "mangata-kusama")] -pub type KusamaFullClient = crate::service::FullClient< - mangata_kusama_runtime::RuntimeApi, - crate::service::MangataKusamaRuntimeExecutor, ->; +type Runtime = mangata_kusama_runtime::RuntimeApi; +type Client = ParachainClient; -#[cfg(feature = "mangata-kusama")] -pub fn fetch_nonce(client: &KusamaFullClient, account: sp_core::sr25519::Pair) -> u32 { +pub fn fetch_nonce(client: &Client, account: sp_core::sr25519::Pair) -> u32 { let best_hash = client.chain_info().best_hash; client .runtime_api() @@ -29,9 +22,8 @@ pub fn fetch_nonce(client: &KusamaFullClient, account: sp_core::sr25519::Pair) - .expect("Fetching account nonce works; qed") } -#[cfg(feature = "mangata-kusama")] pub fn create_extrinsic( - client: &KusamaFullClient, + client: &Client, sender: sp_core::sr25519::Pair, function: impl Into, nonce: Option, @@ -85,21 +77,17 @@ pub fn create_extrinsic( ) } -/// Generates extrinsics for the `benchmark overhead` command. -#[cfg(feature = "mangata-kusama")] pub struct BenchmarkExtrinsicBuilder { - client: Rc>, + client: Rc>, } -#[cfg(feature = "mangata-kusama")] impl BenchmarkExtrinsicBuilder { /// Creates a new [`Self`] from the given client. - pub fn new(client: Rc>) -> Self { + pub fn new(client: Rc>) -> Self { Self { client } } } -#[cfg(feature = "mangata-kusama")] impl frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder { fn pallet(&self) -> &str { "system" @@ -128,12 +116,12 @@ pub async fn inherent_benchmark_data( prev_seed: [u8; 32], duration: Duration, ) -> Result { - let keystore = sp_keystore::testing::KeyStore::new(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); let secret_uri = "//Alice"; let key_pair = sp_core::sr25519::Pair::from_string(secret_uri, None).expect("Generates key pair"); keystore - .insert_unknown(AURA, secret_uri, key_pair.public().as_ref()) + .insert(AURA, secret_uri, key_pair.public().as_ref()) .expect("Inserts unknown key"); let seed = diff --git a/node/src/chain_spec/mangata_kusama.rs b/node/src/chain_spec/mangata_kusama.rs index 8f2184dae1..5bfa96675e 100644 --- a/node/src/chain_spec/mangata_kusama.rs +++ b/node/src/chain_spec/mangata_kusama.rs @@ -1,7 +1,6 @@ -use crate::chain_spec::Extensions; -use codec::Encode; -use cumulus_primitives_core::ParaId; -use hex::FromHex; +use crate::chain_spec::{ + get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION, +}; use common_runtime::{ config::orml_asset_registry::AssetMetadataOf, @@ -9,28 +8,15 @@ use common_runtime::{ ksm_per_second, tokens::{KAR_TOKEN_ID, MGX_TOKEN_ID, RELAY_TOKEN_ID, TUR_TOKEN_ID}, xcm_config::general_key, + AccountId, AuraId, CustomMetadata, XcmMetadata, }; - -use mangata_kusama_runtime::{ - AccountId, AuraId, CustomMetadata, MultiLocation, Parachain, Signature, XcmMetadata, X1, X2, -}; - +use cumulus_primitives_core::ParaId; use sc_service::ChainType; -use sp_core::{sr25519, ByteArray, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_core::{sr25519, ByteArray, Encode}; +use sp_runtime::BoundedVec; +use xcm::prelude::{MultiLocation, Parachain, X1, X2}; -pub mod public_testnet_keys { - pub const ALICE_SR25519: &str = - "0x76e810a1f116b779fea0962f4102e9acb3d22ba603999ecb08ad163582de192c"; - pub const BOB_SR25519: &str = - "0x2eec12f5af27c95fd5661323e544dc857155ea50689eaccdfd580af7c1be921c"; - pub const CHARLIE_SR25519: &str = - "0xbc443b4f7023de2d868f74f9e51159961482dc46f76aa90a1c6ce58efff4be6a"; - pub const SUDO_SR25519: &str = - "0x249af97c2ab99f229cdf18cc966833b894ae7c4d94c13fa86341209c64c8ec18"; - pub const RELAY_SR25519: &str = - "0x7481b06f37b3500bb6ec8d569d2cede4ffcb151daee75f7de20c5bda2e22bb13"; -} +use hex::FromHex; pub mod kusama_mainnet_keys { pub const ALICE_SR25519: &str = @@ -47,31 +33,7 @@ pub mod kusama_mainnet_keys { /// Specialized `ChainSpec` for the normal parachain runtime. pub type ChainSpec = - sc_service::GenericChainSpec; - -/// Helper function to generate a crypto pair from seed -pub fn get_public_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -type AccountPublic = ::Signer; - -/// Generate collator keys from seed. -/// -/// This function's return type must always match the session keys of the chain in tuple format. -pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { - get_public_from_seed::(seed) -} - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_public_from_seed::(seed)).into_account() -} + sc_service::GenericChainSpec; /// Generate the session keys from individual elements. /// @@ -198,8 +160,8 @@ pub fn mangata_kusama_prod_config() -> ChainSpec { MGX_TOKEN_ID, AssetMetadataOf { decimals: 18, - name: b"Mangata".to_vec(), - symbol: b"MGR".to_vec(), + name: BoundedVec::truncate_from(b"Mangata".to_vec()), + symbol: BoundedVec::truncate_from(b"MGX".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -209,8 +171,8 @@ pub fn mangata_kusama_prod_config() -> ChainSpec { 1, AssetMetadataOf { decimals: 18, - name: b"Ether".to_vec(), - symbol: b"ETH".to_vec(), + name: BoundedVec::truncate_from(b"Ether".to_vec()), + symbol: BoundedVec::truncate_from(b"ETH".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -220,8 +182,8 @@ pub fn mangata_kusama_prod_config() -> ChainSpec { RELAY_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Kusama Native".to_vec(), - symbol: b"KSM".to_vec(), + name: BoundedVec::truncate_from(b"Kusama Native".to_vec()), + symbol: BoundedVec::truncate_from(b"KSM".to_vec()), additional: CustomMetadata { // 10_000:1 MGX:KSM xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -253,7 +215,7 @@ pub fn mangata_kusama_prod_config() -> ChainSpec { pub fn mangata_kusama_local_config() -> ChainSpec { // Give your base currency a unit name and decimal places let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "MGAL".into()); + properties.insert("tokenSymbol".into(), "MGXL".into()); properties.insert("tokenDecimals".into(), 18u32.into()); properties.insert("ss58Format".into(), 42u32.into()); @@ -347,8 +309,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { MGX_TOKEN_ID, AssetMetadataOf { decimals: 18, - name: b"Mangata".to_vec(), - symbol: b"MGR".to_vec(), + name: BoundedVec::truncate_from(b"Mangata".to_vec()), + symbol: BoundedVec::truncate_from(b"MGXL".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -358,8 +320,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { 1, AssetMetadataOf { decimals: 18, - name: b"Ether".to_vec(), - symbol: b"ETH".to_vec(), + name: BoundedVec::truncate_from(b"Ether".to_vec()), + symbol: BoundedVec::truncate_from(b"ETH".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -369,8 +331,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { RELAY_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Kusama Native".to_vec(), - symbol: b"KSM".to_vec(), + name: BoundedVec::truncate_from(b"Kusama Native".to_vec()), + symbol: BoundedVec::truncate_from(b"KSM".to_vec()), additional: CustomMetadata { // 10_000:1 MGX:KSM xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -385,8 +347,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { 5, AssetMetadataOf { decimals: 0, - name: vec![], - symbol: vec![], + name: BoundedVec::new(), + symbol: BoundedVec::new(), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -396,8 +358,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { KAR_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Karura".to_vec(), - symbol: b"KAR".to_vec(), + name: BoundedVec::truncate_from(b"Karura".to_vec()), + symbol: BoundedVec::truncate_from(b"KAR".to_vec()), additional: CustomMetadata { // 100:1 MGR:KAR xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() * 100 }), @@ -420,8 +382,8 @@ pub fn mangata_kusama_local_config() -> ChainSpec { TUR_TOKEN_ID, AssetMetadataOf { decimals: 10, - name: b"Turing native token".to_vec(), - symbol: b"TUR".to_vec(), + name: BoundedVec::truncate_from(b"Turing native token".to_vec()), + symbol: BoundedVec::truncate_from(b"TUR".to_vec()), additional: CustomMetadata { // 100:1 TUR:ROC, 10/12 decimals xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -457,18 +419,19 @@ pub fn mangata_kusama_local_config() -> ChainSpec { fn mangata_genesis( initial_authorities: Vec<(AccountId, AuraId)>, - relay_key: AccountId, + _relay_key: AccountId, root_key: AccountId, tokens_endowment: Vec<(u32, u128, AccountId)>, staking_accounts: Vec<(AccountId, u32, u128, u32, u128, u32, u128)>, register_assets: Vec<(u32, AssetMetadataOf)>, id: ParaId, -) -> mangata_kusama_runtime::GenesisConfig { - mangata_kusama_runtime::GenesisConfig { +) -> mangata_kusama_runtime::RuntimeGenesisConfig { + mangata_kusama_runtime::RuntimeGenesisConfig { system: mangata_kusama_runtime::SystemConfig { code: mangata_kusama_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), + ..Default::default() }, tokens: mangata_kusama_runtime::TokensConfig { tokens_endowment: tokens_endowment @@ -500,7 +463,10 @@ fn mangata_genesis( }, }, treasury: Default::default(), - parachain_info: mangata_kusama_runtime::ParachainInfoConfig { parachain_id: id }, + parachain_info: mangata_kusama_runtime::ParachainInfoConfig { + parachain_id: id, + ..Default::default() + }, parachain_staking: mangata_kusama_runtime::ParachainStakingConfig { candidates: staking_accounts .iter() @@ -528,6 +494,10 @@ fn mangata_genesis( aura: Default::default(), aura_ext: Default::default(), parachain_system: Default::default(), + polkadot_xcm: mangata_kusama_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, xyk: mangata_kusama_runtime::XykConfig { created_pools_for_staking: staking_accounts .iter() @@ -559,11 +529,11 @@ fn mangata_genesis( whitelisted_tokens: Default::default(), }, council: Default::default(), + transaction_payment: Default::default(), sudo: mangata_kusama_runtime::SudoConfig { // Assign network admin rights. key: Some(root_key), }, - polkadot_xcm: mangata_kusama_runtime::PolkadotXcmConfig { safe_xcm_version: Some(2) }, asset_registry: mangata_kusama_runtime::AssetRegistryConfig { assets: register_assets .iter() @@ -574,5 +544,6 @@ fn mangata_genesis( }) .collect(), }, + vesting: Default::default(), } } diff --git a/node/src/chain_spec/mangata_rococo.rs b/node/src/chain_spec/mangata_rococo.rs index abb9b3a68a..2550a02a8d 100644 --- a/node/src/chain_spec/mangata_rococo.rs +++ b/node/src/chain_spec/mangata_rococo.rs @@ -1,21 +1,22 @@ -use crate::chain_spec::Extensions; -use codec::Encode; +use crate::chain_spec::{ + get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION, +}; + use common_runtime::{ config::orml_asset_registry::AssetMetadataOf, constants::parachains, ksm_per_second, tokens::{KAR_TOKEN_ID, MGX_TOKEN_ID, RELAY_TOKEN_ID, TUR_TOKEN_ID}, xcm_config::general_key, + AccountId, AuraId, CustomMetadata, XcmMetadata, }; use cumulus_primitives_core::ParaId; -use hex::FromHex; -use mangata_rococo_runtime::{ - AccountId, AuraId, CustomMetadata, MultiLocation, Parachain, Signature, XcmMetadata, X1, X2, -}; - use sc_service::ChainType; -use sp_core::{sr25519, ByteArray, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_core::{sr25519, ByteArray, Encode}; +use sp_runtime::BoundedVec; +use xcm::prelude::{MultiLocation, Parachain, X1, X2}; + +use hex::FromHex; pub mod public_testnet_keys { pub const ALICE_SR25519: &str = @@ -32,31 +33,7 @@ pub mod public_testnet_keys { /// Specialized `ChainSpec` for the normal parachain runtime. pub type ChainSpec = - sc_service::GenericChainSpec; - -/// Helper function to generate a crypto pair from seed -pub fn get_public_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -type AccountPublic = ::Signer; - -/// Generate collator keys from seed. -/// -/// This function's return type must always match the session keys of the chain in tuple format. -pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { - get_public_from_seed::(seed) -} - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_public_from_seed::(seed)).into_account() -} + sc_service::GenericChainSpec; /// Generate the session keys from individual elements. /// @@ -68,7 +45,7 @@ pub fn mangata_session_keys(keys: AuraId) -> mangata_rococo_runtime::SessionKeys pub fn mangata_rococo_prod_config() -> ChainSpec { // Give your base currency a unit name and decimal places let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "MGAT".into()); + properties.insert("tokenSymbol".into(), "MGR".into()); properties.insert("tokenDecimals".into(), 18.into()); properties.insert("ss58Format".into(), 42.into()); @@ -183,8 +160,8 @@ pub fn mangata_rococo_prod_config() -> ChainSpec { MGX_TOKEN_ID, AssetMetadataOf { decimals: 18, - name: b"Mangata".to_vec(), - symbol: b"MGR".to_vec(), + name: BoundedVec::truncate_from(b"Mangata".to_vec()), + symbol: BoundedVec::truncate_from(b"MGR".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -194,8 +171,8 @@ pub fn mangata_rococo_prod_config() -> ChainSpec { 1, AssetMetadataOf { decimals: 18, - name: b"Ether".to_vec(), - symbol: b"ETH".to_vec(), + name: BoundedVec::truncate_from(b"Ether".to_vec()), + symbol: BoundedVec::truncate_from(b"ETH".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -205,8 +182,8 @@ pub fn mangata_rococo_prod_config() -> ChainSpec { RELAY_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Rococo Native".to_vec(), - symbol: b"ROC".to_vec(), + name: BoundedVec::truncate_from(b"Rococo Native".to_vec()), + symbol: BoundedVec::truncate_from(b"ROC".to_vec()), additional: CustomMetadata { // 10_000:1 MGR:ROC xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -329,11 +306,11 @@ pub fn mangata_rococo_local_config() -> ChainSpec { ], vec![ ( - 0, + MGX_TOKEN_ID, AssetMetadataOf { decimals: 18, - name: b"Mangata".to_vec(), - symbol: b"MGR".to_vec(), + name: BoundedVec::truncate_from(b"Mangata".to_vec()), + symbol: BoundedVec::truncate_from(b"MGRL".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -343,8 +320,8 @@ pub fn mangata_rococo_local_config() -> ChainSpec { 1, AssetMetadataOf { decimals: 18, - name: b"Ether".to_vec(), - symbol: b"ETH".to_vec(), + name: BoundedVec::truncate_from(b"Ether".to_vec()), + symbol: BoundedVec::truncate_from(b"ETH".to_vec()), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -354,8 +331,8 @@ pub fn mangata_rococo_local_config() -> ChainSpec { RELAY_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Rococo Native".to_vec(), - symbol: b"ROC".to_vec(), + name: BoundedVec::truncate_from(b"Rococo Native".to_vec()), + symbol: BoundedVec::truncate_from(b"ROC".to_vec()), additional: CustomMetadata { // 10_000:1 MGR:ROC xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -370,8 +347,8 @@ pub fn mangata_rococo_local_config() -> ChainSpec { 5, AssetMetadataOf { decimals: 0, - name: vec![], - symbol: vec![], + name: BoundedVec::new(), + symbol: BoundedVec::new(), additional: Default::default(), existential_deposit: Default::default(), location: None, @@ -381,8 +358,8 @@ pub fn mangata_rococo_local_config() -> ChainSpec { KAR_TOKEN_ID, AssetMetadataOf { decimals: 12, - name: b"Karura".to_vec(), - symbol: b"KAR".to_vec(), + name: BoundedVec::truncate_from(b"Karura".to_vec()), + symbol: BoundedVec::truncate_from(b"KAR".to_vec()), additional: CustomMetadata { // 100:1 MGR:KAR xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() * 100 }), @@ -405,8 +382,8 @@ pub fn mangata_rococo_local_config() -> ChainSpec { TUR_TOKEN_ID, AssetMetadataOf { decimals: 10, - name: b"Turing native token".to_vec(), - symbol: b"TUR".to_vec(), + name: BoundedVec::truncate_from(b"Turing native token".to_vec()), + symbol: BoundedVec::truncate_from(b"TUR".to_vec()), additional: CustomMetadata { // 100:1 TUR:ROC, 10/12 decimals xcm: Some(XcmMetadata { fee_per_second: ksm_per_second() }), @@ -440,20 +417,21 @@ pub fn mangata_rococo_local_config() -> ChainSpec { ) } -fn mangata_genesis( +pub(crate) fn mangata_genesis( initial_authorities: Vec<(AccountId, AuraId)>, - relay_key: AccountId, + _relay_key: AccountId, root_key: AccountId, tokens_endowment: Vec<(u32, u128, AccountId)>, staking_accounts: Vec<(AccountId, u32, u128, u32, u128, u32, u128)>, register_assets: Vec<(u32, AssetMetadataOf)>, id: ParaId, -) -> mangata_rococo_runtime::GenesisConfig { - mangata_rococo_runtime::GenesisConfig { +) -> mangata_rococo_runtime::RuntimeGenesisConfig { + mangata_rococo_runtime::RuntimeGenesisConfig { system: mangata_rococo_runtime::SystemConfig { code: mangata_rococo_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), + ..Default::default() }, tokens: mangata_rococo_runtime::TokensConfig { tokens_endowment: tokens_endowment @@ -485,7 +463,10 @@ fn mangata_genesis( }, }, treasury: Default::default(), - parachain_info: mangata_rococo_runtime::ParachainInfoConfig { parachain_id: id }, + parachain_info: mangata_rococo_runtime::ParachainInfoConfig { + parachain_id: id, + ..Default::default() + }, parachain_staking: mangata_rococo_runtime::ParachainStakingConfig { candidates: staking_accounts .iter() @@ -513,6 +494,10 @@ fn mangata_genesis( aura: Default::default(), aura_ext: Default::default(), parachain_system: Default::default(), + polkadot_xcm: mangata_rococo_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + ..Default::default() + }, xyk: mangata_rococo_runtime::XykConfig { created_pools_for_staking: staking_accounts .iter() @@ -544,11 +529,11 @@ fn mangata_genesis( whitelisted_tokens: Default::default(), }, council: Default::default(), + transaction_payment: Default::default(), sudo: mangata_rococo_runtime::SudoConfig { // Assign network admin rights. key: Some(root_key), }, - polkadot_xcm: mangata_rococo_runtime::PolkadotXcmConfig { safe_xcm_version: Some(2) }, asset_registry: mangata_rococo_runtime::AssetRegistryConfig { assets: register_assets .iter() @@ -559,5 +544,6 @@ fn mangata_genesis( }) .collect(), }, + vesting: Default::default(), } } diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 92694adac9..96834c7056 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -1,12 +1,32 @@ -#[cfg(feature = "mangata-kusama")] -pub mod mangata_kusama; -#[cfg(feature = "mangata-rococo")] -pub mod mangata_rococo; +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use common_runtime::{AccountId, AuraId, Signature}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use serde::{Deserialize, Serialize}; +use sp_core::{Pair, Public}; +use sp_runtime::traits::{IdentifyAccount, Verify}; + +pub mod mangata_kusama; +pub mod mangata_rococo; -/// The extensions for the [`ChainSpec`]. +/// The default XCM version to set in genesis config. +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; + +/// Generic extensions for Parachain ChainSpecs. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] #[serde(deny_unknown_fields)] pub struct Extensions { @@ -23,4 +43,26 @@ impl Extensions { } } -pub type DummyChainSpec = sc_service::GenericChainSpec<(), Extensions>; +/// Helper function to generate a crypto pair from seed +pub fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +type AccountPublic = ::Signer; + +/// Helper function to generate an account ID from seed +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +/// Generate collator keys from seed. +/// +/// This function's return type must always match the session keys of the chain in tuple format. +pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { + get_from_seed::(seed) +} diff --git a/node/src/cli.rs b/node/src/cli.rs index f1f2468f4a..50ad961074 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -1,15 +1,27 @@ -use crate::chain_spec; -use clap::Parser; +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + use std::path::PathBuf; /// Sub-commands supported by the collator. #[derive(Debug, clap::Subcommand)] pub enum Subcommand { - /// Export the genesis state of the parachain. - ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand), - - /// Export the genesis wasm of the parachain. - ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand), + /// Key management CLI utilities + #[command(subcommand)] + Key(sc_cli::KeySubcommand), /// Build a chain specification. BuildSpec(sc_cli::BuildSpecCmd), @@ -26,87 +38,67 @@ pub enum Subcommand { /// Import blocks. ImportBlocks(sc_cli::ImportBlocksCmd), + /// Revert the chain to a previous state. + Revert(sc_cli::RevertCmd), + /// Remove the whole chain. PurgeChain(cumulus_client_cli::PurgeChainCmd), - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), + /// Export the genesis state of the parachain. + ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand), - /// Key management CLI utilities - #[clap(subcommand)] - Key(sc_cli::KeySubcommand), + /// Export the genesis wasm of the parachain. + ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand), /// Sub-commands concerned with benchmarking. /// The pallet benchmarking moved to the `pallet` sub-command. - #[clap(subcommand)] + #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), - /// Try some command against runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Try some command against runtime state. Note: `try-runtime` feature must be enabled. - #[cfg(not(feature = "try-runtime"))] + /// Try-runtime has migrated to a standalone + /// [CLI](). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after January 2024. TryRuntime, } -/// Command for exporting the genesis state of the parachain -#[derive(Debug, Parser)] -pub struct ExportGenesisStateCommand { - /// Output file name or stdout if unspecified. - #[clap(value_parser)] - pub output: Option, - - /// Write output in binary. Default is to write in hex. - #[clap(short, long)] - pub raw: bool, - - /// The name of the chain for that the genesis state should be exported. - #[clap(long)] - pub chain: Option, -} - -/// Command for exporting the genesis wasm file. -#[derive(Debug, Parser)] -pub struct ExportGenesisWasmCommand { - /// Output file name or stdout if unspecified. - #[clap(value_parser)] - pub output: Option, - - /// Write output in binary. Default is to write in hex. - #[clap(short, long)] - pub raw: bool, - - /// The name of the chain for that the genesis wasm file should be exported. - #[clap(long)] - pub chain: Option, -} - -#[derive(Debug, Parser)] -#[clap( +const AFTER_HELP_EXAMPLE: &str = color_print::cstr!( + r#"Examples: + parachain-template-node build-spec --disable-default-bootnode > plain-parachain-chainspec.json + Export a chainspec for a local testnet in json format. + parachain-template-node --chain plain-parachain-chainspec.json --tmp -- --chain rococo-local + Launch a full node with chain specification loaded from plain-parachain-chainspec.json. + parachain-template-node + Launch a full node with default parachain local-testnet and relay chain rococo-local. + parachain-template-node --collator + Launch a collator with default parachain local-testnet and relay chain rococo-local. + "# +); +#[derive(Debug, clap::Parser)] +#[command( propagate_version = true, args_conflicts_with_subcommands = true, subcommand_negates_reqs = true )] +#[clap(after_help = AFTER_HELP_EXAMPLE)] pub struct Cli { - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, - #[clap(flatten)] + #[command(flatten)] pub run: cumulus_client_cli::RunCmd, - // Disable automatic hardware benchmarks. + /// Disable automatic hardware benchmarks. /// /// By default these benchmarks are automatically ran at startup and measure /// the CPU speed, the memory bandwidth and the disk speed. /// /// The results are then printed out in the logs, and also sent as part of /// telemetry, if telemetry is enabled. - #[clap(long)] + #[arg(long)] pub no_hardware_benchmarks: bool, /// Relay chain arguments - #[clap(raw = true)] + #[arg(raw = true)] pub relay_chain_args: Vec, } @@ -128,9 +120,13 @@ impl RelayChainCli { para_config: &sc_service::Configuration, relay_chain_args: impl Iterator, ) -> Self { - let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec); + let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec); let chain_id = extension.map(|e| e.relay_chain.clone()); - let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot")); - Self { base_path, chain_id, base: polkadot_cli::RunCmd::parse_from(relay_chain_args) } + let base_path = para_config.base_path.path().join("polkadot"); + Self { + base_path: Some(base_path), + chain_id, + base: clap::Parser::parse_from(relay_chain_args), + } } } diff --git a/node/src/client.rs b/node/src/client.rs deleted file mode 100644 index 3bc1d0b4bd..0000000000 --- a/node/src/client.rs +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright 2019-2022 PureStake Inc. -// This file is part of Moonbeam. - -// Moonbeam is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Moonbeam is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Moonbeam. If not, see . -use crate::service::AuraId; -pub use mangata_types::{ - AccountId, Balance, Block, BlockNumber, Hash, Header, Index as Nonce, TokenId, -}; -use sc_client_api::{Backend as BackendT, BlockchainEvents, KeysIter, PairsIter}; -use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi}; -use sp_blockchain::HeaderBackend; -use sp_consensus::BlockStatus; -use sp_core::H256; -use sp_runtime::{ - generic::SignedBlock, - traits::{BlakeTwo256, Block as BlockT}, - Justifications, -}; -use sp_storage::{ChildInfo, StorageData, StorageKey}; -use std::sync::Arc; - -/// A set of APIs that polkadot-like runtimes must implement. -/// -/// This trait has no methods or associated type. It is a concise marker for all the trait bounds -/// that it contains. -pub trait RuntimeApiCollection: - sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi - + substrate_frame_rpc_system::AccountNonceApi - + ver_api::VerNonceApi - + xyk_rpc::XykRuntimeApi - + sp_consensus_aura::AuraApi -where - >::StateBackend: sp_api::StateBackend, -{ -} - -impl RuntimeApiCollection for Api -where - Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi - + substrate_frame_rpc_system::AccountNonceApi - + ver_api::VerNonceApi - + xyk_rpc::XykRuntimeApi - + sp_consensus_aura::AuraApi, - >::StateBackend: sp_api::StateBackend, -{ -} - -/// Config that abstracts over all available client implementations. -/// -/// For a concrete type there exists [`Client`]. -pub trait AbstractClient: - BlockchainEvents - + Sized - + Send - + Sync - + ProvideRuntimeApi - + HeaderBackend - + CallApiAt -where - Block: BlockT, - Backend: BackendT, - Backend::State: sp_api::StateBackend, - Self::Api: RuntimeApiCollection, -{ -} - -impl AbstractClient for Client -where - Block: BlockT, - Backend: BackendT, - Backend::State: sp_api::StateBackend, - Client: BlockchainEvents - + ProvideRuntimeApi - + HeaderBackend - + Sized - + Send - + Sync - + CallApiAt, - Client::Api: RuntimeApiCollection, -{ -} - -/// Execute something with the client instance. -/// -/// As there exist multiple chains inside Moonbeam, like Moonbeam itself, Moonbase, -/// Moonriver etc, there can exist different kinds of client types. As these -/// client types differ in the generics that are being used, we can not easily -/// return them from a function. For returning them from a function there exists -/// [`Client`]. However, the problem on how to use this client instance still -/// exists. This trait "solves" it in a dirty way. It requires a type to -/// implement this trait and than the [`execute_with_client`](ExecuteWithClient: -/// :execute_with_client) function can be called with any possible client -/// instance. -/// -/// In a perfect world, we could make a closure work in this way. -pub trait ExecuteWithClient { - /// The return type when calling this instance. - type Output; - - /// Execute whatever should be executed with the given client instance. - fn execute_with_client(self, client: Arc) -> Self::Output - where - >::StateBackend: sp_api::StateBackend, - Backend: sc_client_api::Backend, - Backend::State: sp_api::StateBackend, - Api: RuntimeApiCollection, - Client: AbstractClient + 'static; -} - -/// A handle to a Moonbeam client instance. -/// -/// The Moonbeam service supports multiple different runtimes (Moonbase, Moonbeam -/// itself, etc). As each runtime has a specialized client, we need to hide them -/// behind a trait. This is this trait. -/// -/// When wanting to work with the inner client, you need to use `execute_with`. -pub trait ClientHandle { - /// Execute the given something with the client. - fn execute_with(&self, t: T) -> T::Output; -} - -/// A client instance of Moonbeam. -#[derive(Clone)] -pub enum Client { - #[cfg(feature = "mangata-kusama")] - MangataKusama( - Arc< - crate::service::FullClient< - crate::service::mangata_kusama_runtime::RuntimeApi, - crate::service::MangataKusamaRuntimeExecutor, - >, - >, - ), - #[cfg(feature = "mangata-rococo")] - MangataRococo( - Arc< - crate::service::FullClient< - crate::service::mangata_rococo_runtime::RuntimeApi, - crate::service::MangataRococoRuntimeExecutor, - >, - >, - ), -} - -#[cfg(feature = "mangata-kusama")] -impl - From< - Arc< - crate::service::FullClient< - crate::service::mangata_kusama_runtime::RuntimeApi, - crate::service::MangataKusamaRuntimeExecutor, - >, - >, - > for Client -{ - fn from( - client: Arc< - crate::service::FullClient< - mangata_kusama_runtime::RuntimeApi, - crate::service::MangataKusamaRuntimeExecutor, - >, - >, - ) -> Self { - Self::MangataKusama(client) - } -} - -#[cfg(feature = "mangata-rococo")] -impl - From< - Arc< - crate::service::FullClient< - crate::service::mangata_rococo_runtime::RuntimeApi, - crate::service::MangataRococoRuntimeExecutor, - >, - >, - > for Client -{ - fn from( - client: Arc< - crate::service::FullClient< - mangata_rococo_runtime::RuntimeApi, - crate::service::MangataRococoRuntimeExecutor, - >, - >, - ) -> Self { - Self::MangataRococo(client) - } -} - -impl ClientHandle for Client { - fn execute_with(&self, t: T) -> T::Output { - match self { - #[cfg(feature = "mangata-kusama")] - Self::MangataKusama(client) => - T::execute_with_client::<_, _, crate::service::FullBackend>(t, client.clone()), - #[cfg(feature = "mangata-rococo")] - Self::MangataRococo(client) => - T::execute_with_client::<_, _, crate::service::FullBackend>(t, client.clone()), - } - } -} - -macro_rules! match_client { - ($self:ident, $method:ident($($param:ident),*)) => { - match $self { - #[cfg(feature = "mangata-kusama")] - Self::MangataKusama(client) => client.$method($($param),*), - #[cfg(feature = "mangata-rococo")] - Self::MangataRococo(client) => client.$method($($param),*), - } - }; -} - -impl sc_client_api::UsageProvider for Client { - fn usage_info(&self) -> sc_client_api::ClientInfo { - match_client!(self, usage_info()) - } -} - -impl sc_client_api::BlockBackend for Client { - fn block_body( - &self, - hash: ::Hash, - ) -> sp_blockchain::Result::Extrinsic>>> { - match_client!(self, block_body(hash)) - } - - fn block_indexed_body(&self, id: H256) -> sp_blockchain::Result>>> { - match_client!(self, block_indexed_body(id)) - } - - fn block( - &self, - hash: ::Hash, - ) -> sp_blockchain::Result>> { - match_client!(self, block(hash)) - } - - fn block_status(&self, hash: ::Hash) -> sp_blockchain::Result { - match_client!(self, block_status(hash)) - } - - fn justifications(&self, id: H256) -> sp_blockchain::Result> { - match_client!(self, justifications(id)) - } - - fn block_hash( - &self, - number: NumberFor, - ) -> sp_blockchain::Result::Hash>> { - match_client!(self, block_hash(number)) - } - - fn indexed_transaction( - &self, - hash: ::Hash, - ) -> sp_blockchain::Result>> { - match_client!(self, indexed_transaction(hash)) - } - - fn has_indexed_transaction( - &self, - hash: ::Hash, - ) -> sp_blockchain::Result { - match_client!(self, has_indexed_transaction(hash)) - } - - fn requires_full_sync(&self) -> bool { - match_client!(self, requires_full_sync()) - } -} - -impl sc_client_api::StorageProvider for Client { - fn storage( - &self, - hash: ::Hash, - key: &StorageKey, - ) -> sp_blockchain::Result> { - match_client!(self, storage(hash, key)) - } - - fn storage_keys( - &self, - hash: ::Hash, - key_prefix: Option<&StorageKey>, - start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result< - KeysIter<>::State, Block>, - > { - match_client!(self, storage_keys(hash, key_prefix, start_key)) - } - - fn storage_hash( - &self, - hash: ::Hash, - key: &StorageKey, - ) -> sp_blockchain::Result::Hash>> { - match_client!(self, storage_hash(hash, key)) - } - - fn storage_pairs( - &self, - hash: ::Hash, - key_prefix: Option<&StorageKey>, - start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result< - PairsIter<>::State, Block>, - > { - match_client!(self, storage_pairs(hash, key_prefix, start_key)) - } - - fn child_storage( - &self, - hash: ::Hash, - child_info: &ChildInfo, - key: &StorageKey, - ) -> sp_blockchain::Result> { - match_client!(self, child_storage(hash, child_info, key)) - } - - fn child_storage_keys( - &self, - hash: ::Hash, - child_info: ChildInfo, - key_prefix: Option<&StorageKey>, - start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result< - KeysIter<>::State, Block>, - > { - match_client!(self, child_storage_keys(hash, child_info, key_prefix, start_key)) - } - - fn child_storage_hash( - &self, - hash: ::Hash, - child_info: &ChildInfo, - key: &StorageKey, - ) -> sp_blockchain::Result::Hash>> { - match_client!(self, child_storage_hash(hash, child_info, key)) - } -} - -impl sp_blockchain::HeaderBackend for Client { - fn header(&self, id: H256) -> sp_blockchain::Result> { - match_client!(self, header(id)) - } - - fn info(&self) -> sp_blockchain::Info { - match_client!(self, info()) - } - - fn status(&self, id: H256) -> sp_blockchain::Result { - match_client!(self, status(id)) - } - - fn number(&self, hash: Hash) -> sp_blockchain::Result> { - match_client!(self, number(hash)) - } - - fn hash(&self, number: BlockNumber) -> sp_blockchain::Result> { - match_client!(self, hash(number)) - } -} diff --git a/node/src/command.rs b/node/src/command.rs index 882412c573..449f277fde 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -1,66 +1,118 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + use crate::{ + benchmarking::{inherent_benchmark_data, BenchmarkExtrinsicBuilder}, chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - command_helper::{inherent_benchmark_data, BenchmarkExtrinsicBuilder}, - service, - service::new_partial, + service::{new_partial, Block}, }; -use codec::Encode; -use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use futures::executor::block_on; use log::info; -pub use mangata_types::Block; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, + NetworkParams, Result, SharedParams, SubstrateCli, }; +use sc_executor::{WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; use sc_service::config::{BasePath, PrometheusConfig}; -use std::{cell::RefCell, rc::Rc}; +use sp_runtime::traits::AccountIdConversion; +use std::{ + cell::RefCell, convert::TryInto, net::SocketAddr, path::PathBuf, rc::Rc, time::Duration, +}; -use sp_core::hexdisplay::HexDisplay; +/// Helper enum that is used for better distinction of different parachain/runtime configuration +/// (it is based/calculated on ChainSpec's ID attribute) +#[derive(Debug, PartialEq, Default)] +enum Runtime { + /// This is the default runtime (actually based on rococo) + #[default] + Default, + Rococo, + Kusama, +} -use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; -use std::{convert::TryInto, io::Write, net::SocketAddr, time::Duration}; -#[cfg(feature = "try-runtime")] -use try_runtime_cli::block_building_info::substrate_info; +trait RuntimeResolver { + fn runtime(&self) -> Runtime; +} -fn load_spec(id: &str) -> std::result::Result, String> { - Ok(match id { - #[cfg(feature = "mangata-kusama")] - "kusama" => Box::new(chain_spec::mangata_kusama::mangata_kusama_prod_config()), - #[cfg(feature = "mangata-kusama")] - "kusama-local" => Box::new(chain_spec::mangata_kusama::mangata_kusama_local_config()), - #[cfg(feature = "mangata-rococo")] - "rococo" => Box::new(chain_spec::mangata_rococo::mangata_rococo_prod_config()), - #[cfg(feature = "mangata-rococo")] - "rococo-local" => Box::new(chain_spec::mangata_rococo::mangata_rococo_local_config()), +impl RuntimeResolver for dyn ChainSpec { + fn runtime(&self) -> Runtime { + runtime(self.id()) + } +} - path => { - let path = std::path::PathBuf::from(path); +/// Implementation, that can resolve [`Runtime`] from any json configuration file +impl RuntimeResolver for PathBuf { + fn runtime(&self) -> Runtime { + #[derive(Debug, serde::Deserialize)] + struct EmptyChainSpecWithId { + id: String, + } - let chain_spec = - Box::new(crate::chain_spec::DummyChainSpec::from_json_file(path.clone())?) - as Box; + let file = std::fs::File::open(self).expect("Failed to open file"); + let reader = std::io::BufReader::new(file); + let chain_spec: EmptyChainSpecWithId = serde_json::from_reader(reader) + .expect("Failed to read 'json' file with ChainSpec configuration"); - if chain_spec.is_mangata_kusama() { - #[cfg(feature = "mangata-kusama")] - { - Box::new(chain_spec::mangata_kusama::ChainSpec::from_json_file(path)?) - } + runtime(&chain_spec.id) + } +} - #[cfg(not(feature = "mangata-kusama"))] - return Err(service::MANGATA_KUSAMA_RUNTIME_NOT_AVAILABLE.into()) - } else if chain_spec.is_mangata_rococo() { - #[cfg(feature = "mangata-rococo")] - { - Box::new(chain_spec::mangata_rococo::ChainSpec::from_json_file(path)?) - } - #[cfg(not(feature = "mangata-rococo"))] - return Err(service::MANGATA_ROCOCO_RUNTIME_NOT_AVAILABLE.into()) - } else { - return Err("The id of the chainspec does not match the enabled feature".into()) +fn runtime(id: &str) -> Runtime { + let id = id.replace('_', "-"); + + if id.contains("rococo") || id.contains("testnet") { + Runtime::Rococo + } else if id.contains("kusama") { + Runtime::Kusama + } else { + log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id); + Runtime::default() + } +} + +fn load_spec(id: &str) -> std::result::Result, String> { + Ok(match id { + // - Rococo based + "mangata-rococo-local" => + Box::new(chain_spec::mangata_rococo::mangata_rococo_local_config()), + "mangata-rococo" => Box::new(chain_spec::mangata_rococo::mangata_rococo_prod_config()), + // - Kusama based + "mangata-kusama-local" => + Box::new(chain_spec::mangata_kusama::mangata_kusama_local_config()), + "mangata-kusama" => Box::new(chain_spec::mangata_kusama::mangata_kusama_prod_config()), + + // -- Fallback (generic chainspec) + "" => { + log::warn!("No ChainSpec.id specified, so using default one, based on rococo-parachain runtime"); + Box::new(chain_spec::mangata_rococo::mangata_rococo_local_config()) + }, + + // -- Loading a specific spec from disk + path => { + let path: PathBuf = path.into(); + match path.runtime() { + Runtime::Rococo => + Box::new(chain_spec::mangata_rococo::ChainSpec::from_json_file(path)?), + Runtime::Kusama => + Box::new(chain_spec::mangata_kusama::ChainSpec::from_json_file(path)?), + Runtime::Default => + Box::new(chain_spec::mangata_rococo::ChainSpec::from_json_file(path)?), } }, }) @@ -68,7 +120,7 @@ fn load_spec(id: &str) -> std::result::Result, St impl SubstrateCli for Cli { fn impl_name() -> String { - "Mangata Parachain Collator".into() + "Mangata Parachain".into() } fn impl_version() -> String { @@ -76,11 +128,13 @@ impl SubstrateCli for Cli { } fn description() -> String { - "Mangata Parachain Collator\n\nThe command-line arguments provided first will be \ + format!( + "Mangata Parachain Collator\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ to the relay chain node.\n\n\ - parachain-collator -- " - .into() + {} -- ", + Self::executable_name() + ) } fn author() -> String { @@ -88,31 +142,21 @@ impl SubstrateCli for Cli { } fn support_url() -> String { - "https://github.com/paritytech/cumulus/issues/new".into() + "https://github.com/managata-finance/mangata-node/issues/new".into() } fn copyright_start_year() -> i32 { 2020 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id) } - - fn native_runtime_version(spec: &Box) -> &'static RuntimeVersion { - match spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => return &service::mangata_kusama_runtime::VERSION, - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => return &service::mangata_rococo_runtime::VERSION, - _ => panic!("invalid chain spec"), - } - } } impl SubstrateCli for RelayChainCli { fn impl_name() -> String { - "Mangata Parachain Collator".into() + "Mangata Parachain".into() } fn impl_version() -> String { @@ -120,11 +164,13 @@ impl SubstrateCli for RelayChainCli { } fn description() -> String { - "Mangata Parachain Collator\n\nThe command-line arguments provided first will be \ + format!( + "Mangata Parachain\n\nThe command-line arguments provided first will be \ passed to the parachain node, while the arguments provided after -- will be passed \ to the relay chain node.\n\n\ - parachain-collator -- " - .into() + {} -- ", + Self::executable_name() + ) } fn author() -> String { @@ -139,45 +185,52 @@ impl SubstrateCli for RelayChainCli { 2020 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } - - fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { - polkadot_cli::Cli::native_runtime_version(chain_spec) - } } -#[allow(clippy::borrowed_box)] -fn extract_genesis_wasm(chain_spec: &Box) -> Result> { - let mut storage = chain_spec.build_storage()?; - - storage - .top - .remove(sp_core::storage::well_known_keys::CODE) - .ok_or_else(|| "Could not find wasm file in genesis state!".into()) -} - -/// Can be called for a `Configuration` to check if it is a configuration for -/// the `Mangata` network. -pub trait IdentifyVariant { - /// Returns `true` if this is a configuration for the `Moonbase` network. - fn is_mangata_kusama(&self) -> bool; - - /// Returns `true` if this is a configuration for the `Moonbeam` network. - fn is_mangata_rococo(&self) -> bool; +/// Creates partial components for the runtimes that are supported by the benchmarks. +macro_rules! construct_benchmark_partials { + ($config:expr, |$partials:ident| $code:expr) => { + match $config.chain_spec.runtime() { + Runtime::Rococo => { + let $partials = new_partial::(&$config)?; + $code + }, + Runtime::Kusama => { + let $partials = new_partial::(&$config)?; + $code + }, + _ => Err("The chain is not supported".into()), + } + }; } -impl IdentifyVariant for Box { - fn is_mangata_kusama(&self) -> bool { - !(self.id().starts_with("mangata_public_testnet") || - self.id().starts_with("mangata_rococo_local")) - } - - fn is_mangata_rococo(&self) -> bool { - self.id().starts_with("mangata_public_testnet") || - self.id().starts_with("mangata_rococo_local") - } +macro_rules! construct_async_run { + (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ + let runner = $cli.create_runner($cmd)?; + match runner.config().chain_spec.runtime() { + Runtime::Rococo | Runtime::Default => { + runner.async_run(|$config| { + let $components = new_partial::( + &$config, + )?; + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) + }, + Runtime::Kusama => { + runner.async_run(|$config| { + let $components = new_partial::( + &$config, + )?; + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) + }, + } + }} } /// Parse command line arguments into service configuration. @@ -190,33 +243,28 @@ pub fn run() -> Result<()> { runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) }, Some(Subcommand::CheckBlock(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config)?; - Ok((cmd.run(client, import_queue), task_manager)) + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, components.import_queue)) }) }, Some(Subcommand::ExportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, _, task_manager) = service::new_chain_ops(&mut config)?; - Ok((cmd.run(client, config.database), task_manager)) + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, config.database)) }) }, Some(Subcommand::ExportState(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, _, task_manager) = service::new_chain_ops(&mut config)?; - Ok((cmd.run(client, config.chain_spec), task_manager)) + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, config.chain_spec)) }) }, Some(Subcommand::ImportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config)?; - Ok((cmd.run(client, import_queue), task_manager)) + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, components.import_queue)) }) }, + Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, components.backend, None)) + }), Some(Subcommand::PurgeChain(cmd)) => { let runner = cli.create_runner(cmd)?; @@ -236,274 +284,133 @@ pub fn run() -> Result<()> { cmd.run(config, polkadot_config) }) }, - Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), - Some(Subcommand::Revert(cmd)) => { + Some(Subcommand::ExportGenesisState(cmd)) =>{ let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, backend, _, task_manager) = service::new_chain_ops(&mut config)?; - Ok((cmd.run(client, backend, None), task_manager)) - }) - }, - Some(Subcommand::ExportGenesisState(params)) => { - let mut builder = sc_cli::LoggerBuilder::new(""); - builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); - let _ = builder.init(); - - let spec = load_spec(¶ms.shared_params.chain.clone().unwrap_or_default())?; - - let output_buf = match spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => { - let state_version = Cli::native_runtime_version(&spec).state_version(); - let block: service::mangata_kusama_runtime::Block = - generate_genesis_block(&*spec, state_version)?; - let raw_header = block.header().encode(); - let output_buf = if params.raw { - raw_header - } else { - format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes() - }; - output_buf + match runner.config().chain_spec.runtime() { + Runtime::Rococo | Runtime::Default => { + runner.sync_run(|config| { + let components = new_partial::( + &config, + )?; + cmd.run(&*config.chain_spec, &*components.client) + }) }, - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => { - let state_version = Cli::native_runtime_version(&spec).state_version(); - let block: service::mangata_rococo_runtime::Block = - generate_genesis_block(&*spec, state_version)?; - let raw_header = block.header().encode(); - let output_buf = if params.raw { - raw_header - } else { - format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes() - }; - output_buf + Runtime::Kusama => { + runner.sync_run(|config| { + let components = new_partial::( + &config, + )?; + cmd.run(&*config.chain_spec, &*components.client) + }) }, - _ => panic!("invalid chain spec"), - }; - - if let Some(output) = ¶ms.output { - std::fs::write(output, output_buf)?; - } else { - std::io::stdout().write_all(&output_buf)?; } - - Ok(()) }, - Some(Subcommand::ExportGenesisWasm(params)) => { - let mut builder = sc_cli::LoggerBuilder::new(""); - builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); - let _ = builder.init(); - - let raw_wasm_blob = extract_genesis_wasm( - &cli.load_spec(¶ms.shared_params.chain.clone().unwrap_or_default())?, - )?; - let output_buf = if params.raw { - raw_wasm_blob - } else { - format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes() - }; - - if let Some(output) = ¶ms.output { - std::fs::write(output, output_buf)?; - } else { - std::io::stdout().write_all(&output_buf)?; - } - - Ok(()) + Some(Subcommand::ExportGenesisWasm(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|_config| { + let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; + cmd.run(&*spec) + }) }, Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd)?; - let chain_spec = &runner.config().chain_spec; - - match chain_spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| { - cmd.run::(config) - }) - } else { - Err("Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into()) - }, - BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { - let partials = new_partial::< - service::mangata_kusama_runtime::RuntimeApi, - service::MangataKusamaRuntimeExecutor, - >(&config)?; - cmd.run(partials.client) - }), - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ + + // Switch on the concrete benchmark sub-command- + match cmd { + BenchmarkCmd::Pallet(cmd) => + if cfg!(feature = "runtime-benchmarks") { + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + }, + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ to enable storage benchmarks." - .into(), - ) - .into()), - #[cfg(feature = "runtime-benchmarks")] - BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { - let partials = new_partial::< - service::mangata_kusama_runtime::RuntimeApi, - service::MangataKusamaRuntimeExecutor, - >(&config)?; + .into(), + ) + .into()), + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + construct_benchmark_partials!(config, |partials| { let db = partials.backend.expose_db(); let storage = partials.backend.expose_storage(); cmd.run(config, partials.client.clone(), db, storage) - }), - BenchmarkCmd::Extrinsic(_) => Err("Unsupported benchmarking command".into()), - BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| { - let executor = sc_executor::NativeElseWasmExecutor::< - service::MangataKusamaRuntimeExecutor, - >::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); - - let (c, _, _, _) = sc_service::new_full_parts::< - mangata_types::Block, - service::mangata_kusama_runtime::RuntimeApi, - _, - >(&config, None, executor)?; - - let client = Rc::new(RefCell::new(c)); - - let ext_builder = BenchmarkExtrinsicBuilder::new(client.clone()); - - let first_block_inherent = - block_on(inherent_benchmark_data([0u8; 32], Duration::from_millis(0))) + }) + }), + BenchmarkCmd::Machine(cmd) => + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), + BenchmarkCmd::Overhead(cmd) => runner.sync_run(|config| { + match config.chain_spec.runtime() { + Runtime::Rococo | Runtime::Default => Err("Benchmarking sub-command unsupported".into()), + Runtime::Kusama => { + let executor = WasmExecutor::builder() + .with_execution_method(config.wasm_method) + .with_onchain_heap_alloc_strategy(DEFAULT_HEAP_ALLOC_STRATEGY) + .with_offchain_heap_alloc_strategy(DEFAULT_HEAP_ALLOC_STRATEGY) + .with_max_runtime_instances(config.max_runtime_instances) + .with_runtime_cache_size(config.runtime_cache_size) + .build(); + + let (c, _, _, _) = sc_service::new_full_parts::( + &config, + None, + executor, + )?; + let client = Rc::new(RefCell::new(c)); + let ext_builder = BenchmarkExtrinsicBuilder::new(client.clone()); + + let first_block_inherent = + block_on(inherent_benchmark_data([0u8; 32], Duration::from_millis(0))) .unwrap(); - let first_block_seed = sp_ver::extract_inherent_data(&first_block_inherent) - .map_err(|_| { - sp_blockchain::Error::Backend(String::from( - "cannot read random seed from inherents data", - )) + let first_block_seed = sp_ver::extract_inherent_data(&first_block_inherent) + .map_err(|_| { + sp_blockchain::Error::Backend(String::from( + "cannot read random seed from inherents data", + )) })?; - let second_block_inherent = block_on(inherent_benchmark_data( - first_block_seed.seed.as_bytes().try_into().unwrap(), - Duration::from_millis(12000), - )) - .unwrap(); - - cmd.run_ver( - config, - client.clone(), - (first_block_inherent, second_block_inherent), - &ext_builder, - ) - }), - BenchmarkCmd::Machine(cmd) => runner - .sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), - }, - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| { - cmd.run::(config) - }) - } else { - Err("Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - .into()) - }, - BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { - let partials = new_partial::< - service::mangata_rococo_runtime::RuntimeApi, - service::MangataRococoRuntimeExecutor, - >(&config)?; - cmd.run(partials.client) - }), - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ - to enable storage benchmarks." - .into(), - ) - .into()), - #[cfg(feature = "runtime-benchmarks")] - BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { - let partials = new_partial::< - service::mangata_rococo_runtime::RuntimeApi, - service::MangataRococoRuntimeExecutor, - >(&config)?; - let db = partials.backend.expose_db(); - let storage = partials.backend.expose_storage(); + let second_block_inherent = block_on(inherent_benchmark_data( + first_block_seed.seed.as_bytes().try_into().unwrap(), + Duration::from_millis(12000), + )) + .unwrap(); - cmd.run(config, partials.client.clone(), db, storage) - }), - BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()), - BenchmarkCmd::Extrinsic(_) => Err("Unsupported benchmarking command".into()), - BenchmarkCmd::Machine(cmd) => runner - .sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), - }, - _ => panic!("invalid chain spec"), - } - }, - #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - let runner = cli.create_runner(cmd)?; - let chain_spec = &runner.config().chain_spec; - use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; - let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| format!("Error: {:?}", e))?; - - match chain_spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => runner.async_run(|_| { - let info_provider = substrate_info::(6000); - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) - }), - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => runner.async_run(|_| { - let info_provider = substrate_info::(6000); - Ok(( - cmd.run::::ExtendHostFunctions, - >, _>(Some(info_provider)), - task_manager, - )) + cmd.run_ver(config, client, (first_block_inherent, second_block_inherent), &ext_builder) + }, + } }), - _ => panic!("invalid chain spec"), + // NOTE: this allows the Client to leniently implement + // new benchmark commands without requiring a companion MR. + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), } }, - #[cfg(not(feature = "try-runtime"))] - Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ - You can enable it with `--features try-runtime`." - .into()), + Some(Subcommand::TryRuntime) => Err("The `try-runtime` subcommand has been migrated to a standalone CLI (https://github.com/paritytech/try-runtime-cli). It is no longer being maintained here and will be removed entirely some time after January 2024. Please remove this subcommand from your runtime and use the standalone CLI.".into()), + Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); runner.run_node_until_exit(|config| async move { - let hwbench = if !cli.no_hardware_benchmarks { + + let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) - }) - } else { - None - }; + })).flatten(); + let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; + .ok_or("Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -513,27 +420,7 @@ pub fn run() -> Result<()> { let id = ParaId::from(para_id); let parachain_account = - AccountIdConversion::::into_account_truncating(&id); - - let genesis_state = match &config.chain_spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => { - let state_version = Cli::native_runtime_version(&spec).state_version(); - let block: service::mangata_kusama_runtime::Block = - generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; - format!("0x{:?}", HexDisplay::from(&block.header().encode())) - }, - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => { - let state_version = Cli::native_runtime_version(&spec).state_version(); - let block: service::mangata_rococo_runtime::Block = - generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; - format!("0x{:?}", HexDisplay::from(&block.header().encode())) - }, - _ => panic!("invalid chain spec"), - }; + AccountIdConversion::::into_account_truncating(&id); let tokio_handle = config.tokio_handle.clone(); let polkadot_config = @@ -542,27 +429,21 @@ pub fn run() -> Result<()> { info!("Parachain id: {:?}", id); info!("Parachain Account: {}", parachain_account); - info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - match &config.chain_spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => crate::service::start_parachain_node::< - service::mangata_kusama_runtime::RuntimeApi, - service::MangataKusamaRuntimeExecutor, + match config.chain_spec.runtime() { + Runtime::Rococo | Runtime::Default => crate::service::start_parachain_node::< + mangata_rococo_runtime::RuntimeApi, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) .map_err(Into::into), - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => crate::service::start_parachain_node::< - service::mangata_rococo_runtime::RuntimeApi, - service::MangataRococoRuntimeExecutor, + Runtime::Kusama => crate::service::start_parachain_node::< + mangata_kusama_runtime::RuntimeApi, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) .map_err(Into::into), - _ => panic!("invalid chain spec"), } }) }, @@ -574,14 +455,10 @@ impl DefaultConfigurationValues for RelayChainCli { 30334 } - fn rpc_ws_listen_port() -> u16 { + fn rpc_listen_port() -> u16 { 9945 } - fn rpc_http_listen_port() -> u16 { - 9934 - } - fn prometheus_listen_port() -> u16 { 9616 } @@ -596,14 +473,14 @@ impl CliConfiguration for RelayChainCli { self.base.base.import_params() } - fn keystore_params(&self) -> Option<&KeystoreParams> { - self.base.base.keystore_params() - } - fn network_params(&self) -> Option<&NetworkParams> { self.base.base.network_params() } + fn keystore_params(&self) -> Option<&KeystoreParams> { + self.base.base.keystore_params() + } + fn base_path(&self) -> Result> { Ok(self .shared_params() @@ -611,12 +488,29 @@ impl CliConfiguration for RelayChainCli { .or_else(|| self.base_path.clone().map(Into::into))) } - fn role(&self, is_dev: bool) -> Result { - self.base.base.role(is_dev) + fn rpc_addr(&self, default_listen_port: u16) -> Result> { + self.base.base.rpc_addr(default_listen_port) } - fn transaction_pool(&self, is_dev: bool) -> Result { - self.base.base.transaction_pool(is_dev) + fn prometheus_config( + &self, + default_listen_port: u16, + chain_spec: &Box, + ) -> Result> { + self.base.base.prometheus_config(default_listen_port, chain_spec) + } + + fn init( + &self, + _support_url: &String, + _impl_version: &String, + _logger_hook: F, + _config: &sc_service::Configuration, + ) -> Result<()> + where + F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration), + { + unreachable!("PolkadotCli is never initialized; qed"); } fn chain_id(&self, is_dev: bool) -> Result { @@ -625,49 +519,30 @@ impl CliConfiguration for RelayChainCli { Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id }) } - fn node_name(&self) -> Result { - self.base.base.node_name() - } - - fn rpc_http(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_http(default_listen_port) + fn role(&self, is_dev: bool) -> Result { + self.base.base.role(is_dev) } - fn rpc_ipc(&self) -> Result> { - self.base.base.rpc_ipc() + fn transaction_pool(&self, is_dev: bool) -> Result { + self.base.base.transaction_pool(is_dev) } - fn rpc_ws(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_ws(default_listen_port) + fn trie_cache_maximum_size(&self) -> Result> { + self.base.base.trie_cache_maximum_size() } fn rpc_methods(&self) -> Result { self.base.base.rpc_methods() } - fn rpc_ws_max_connections(&self) -> Result> { - self.base.base.rpc_ws_max_connections() + fn rpc_max_connections(&self) -> Result { + self.base.base.rpc_max_connections() } fn rpc_cors(&self, is_dev: bool) -> Result>> { self.base.base.rpc_cors(is_dev) } - fn prometheus_config( - &self, - default_listen_port: u16, - chain_spec: &Box, - ) -> Result> { - self.base.base.prometheus_config(default_listen_port, chain_spec) - } - - fn telemetry_endpoints( - &self, - chain_spec: &Box, - ) -> Result> { - self.base.base.telemetry_endpoints(chain_spec) - } - fn default_heap_pages(&self) -> Result> { self.base.base.default_heap_pages() } @@ -688,16 +563,120 @@ impl CliConfiguration for RelayChainCli { self.base.base.announce_block() } - fn init( + fn telemetry_endpoints( &self, - _support_url: &String, - _impl_version: &String, - _logger_hook: F, - _config: &sc_service::Configuration, - ) -> Result<()> - where - F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration), - { - unreachable!("PolkadotCli is never initialized; qed"); + chain_spec: &Box, + ) -> Result> { + self.base.base.telemetry_endpoints(chain_spec) + } + + fn node_name(&self) -> Result { + self.base.base.node_name() + } +} + +#[cfg(test)] +mod tests { + use crate::{ + chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed}, + command::{Runtime, RuntimeResolver}, + }; + use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType, Extension}; + use serde::{Deserialize, Serialize}; + use sp_core::sr25519; + use std::path::PathBuf; + use tempfile::TempDir; + + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default, + )] + #[serde(deny_unknown_fields)] + pub struct Extensions1 { + pub attribute1: String, + pub attribute2: u32, + } + + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default, + )] + #[serde(deny_unknown_fields)] + pub struct Extensions2 { + pub attribute_x: String, + pub attribute_y: String, + pub attribute_z: u32, + } + + fn store_configuration(dir: &TempDir, spec: Box) -> PathBuf { + let raw_output = true; + let json = sc_service::chain_ops::build_spec(&*spec, raw_output) + .expect("Failed to build json string"); + let mut cfg_file_path = dir.path().to_path_buf(); + cfg_file_path.push(spec.id()); + cfg_file_path.set_extension("json"); + std::fs::write(&cfg_file_path, json).expect("Failed to write to json file"); + cfg_file_path + } + + pub type DummyChainSpec = + sc_service::GenericChainSpec; + + pub fn create_default_with_extensions( + id: &str, + extension: E, + ) -> DummyChainSpec { + DummyChainSpec::from_genesis( + "Dummy local testnet", + id, + ChainType::Local, + move || { + crate::chain_spec::mangata_rococo::mangata_genesis( + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed("Bob"), + ), + ], + get_account_id_from_seed::("Relay"), + get_account_id_from_seed::("Alice"), + vec![], + vec![], + vec![], + 1000.into(), + ) + }, + Vec::new(), + None, + None, + None, + None, + extension, + ) + } + + #[test] + fn test_resolve_runtime_for_different_configuration_files() { + let temp_dir = tempfile::tempdir().expect("Failed to access tempdir"); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("mangata-rococo-1", Extensions1::default())), + ); + assert_eq!(Runtime::Rococo, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("default", Extensions2::default())), + ); + assert_eq!(Runtime::Default, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(crate::chain_spec::mangata_kusama::mangata_kusama_local_config()), + ); + assert_eq!(Runtime::Kusama, path.runtime()); } } diff --git a/node/src/lib.rs b/node/src/lib.rs deleted file mode 100644 index 61ec88ad3f..0000000000 --- a/node/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![allow(missing_docs)] - -pub mod chain_spec; -#[macro_use] -pub mod service; -pub mod cli; -pub mod client; -pub mod command; -pub mod command_helper; -pub mod rpc; diff --git a/node/src/main.rs b/node/src/main.rs new file mode 100644 index 0000000000..22b2187c19 --- /dev/null +++ b/node/src/main.rs @@ -0,0 +1,32 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Cumulus test parachain collator + +#![warn(missing_docs)] +#![warn(unused_extern_crates)] + +mod chain_spec; +#[macro_use] +mod service; +mod benchmarking; +mod cli; +mod command; +mod rpc; + +fn main() -> sc_cli::Result<()> { + command::run() +} diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 3c8abbe28d..bb93e5a055 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -1,15 +1,31 @@ -//! A collection of node-specific RPC methods. -//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer -//! used by Substrate nodes. This file extends those RPC definitions with -//! capabilities that are specific to this project's runtime configuration. +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Parachain-specific RPCs implementation. #![warn(missing_docs)] use std::sync::Arc; -use mangata_types::{AccountId, Balance, Block, BlockNumber, Index as Nonce, TokenId}; +use common_runtime::{ + opaque::Block, + types::{AccountId, Balance, Nonce, TokenId}, +}; -use sc_client_api::{AuxStore, BlockBackend}; +use sc_client_api::AuxStore; pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; @@ -36,8 +52,8 @@ pub fn create_full( ) -> Result> where C: ProvideRuntimeApi + + sc_client_api::BlockBackend + HeaderBackend - + BlockBackend + AuxStore + HeaderMetadata + Send @@ -57,9 +73,9 @@ where let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; - module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; + module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(Xyk::new(client.clone()).into_rpc())?; + module.merge(Xyk::new(client).into_rpc())?; Ok(module) } diff --git a/node/src/service.rs b/node/src/service.rs index 5ebfe00e75..2adc007069 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,194 +1,152 @@ -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. -// std -use std::{sync::Arc, time::Duration}; +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. -// rpc -use jsonrpsee::RpcModule; +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. -use cumulus_client_cli::CollatorOptions; -// Local Runtime Types -use mangata_types::{AccountId, Balance, Block, BlockNumber, Index as Nonce, TokenId}; +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . -// Cumulus Imports -use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; -use cumulus_client_consensus_common::{ - ParachainBlockImport as TParachainBlockImport, ParachainConsensus, +use cumulus_client_cli::CollatorOptions; +use cumulus_client_collator::service::CollatorService; +use cumulus_client_consensus_aura::collators::basic::{ + self as basic_aura, Params as BasicAuraParams, }; +use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; +use cumulus_client_consensus_proposer::Proposer; +#[allow(deprecated)] use cumulus_client_service::{ - build_network, build_relay_chain_interface, prepare_node_config, start_collator, - start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams, + build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, + BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams, }; use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::RelayChainInterface; +use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; -// Substrate Imports -use crate::{ - client::{Client, RuntimeApiCollection}, - command::IdentifyVariant, +pub use common_runtime::{ + opaque::{Block, Header}, + AccountId, AuraId, Balance, BlockNumber, Hash, Nonce, TokenId, }; -use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; + +use sc_client_api::Backend; use sc_consensus::ImportQueue; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; use sc_network::NetworkBlock; use sc_network_sync::SyncingService; -pub use sc_service::ChainSpec; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; -use sp_keystore::SyncCryptoStorePtr; -use sp_runtime::traits::BlakeTwo256; -use sp_trie::PrefixedMemoryDB; +use sp_keystore::KeystorePtr; +use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; -pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use polkadot_primitives::CollatorPair; -#[cfg(feature = "mangata-kusama")] -pub use mangata_kusama_runtime; -#[cfg(feature = "mangata-rococo")] -pub use mangata_rococo_runtime; +#[cfg(not(feature = "runtime-benchmarks"))] +type HostFunctions = sp_io::SubstrateHostFunctions; -pub const MANGATA_KUSAMA_RUNTIME_NOT_AVAILABLE: &str = - "Mangata Kusama runtime is not available. Please compile the node with `--features mangata-kusama` to enable it."; -pub const MANGATA_ROCOCO_RUNTIME_NOT_AVAILABLE: &str = - "Mangata Rococo runtime is not available. Please compile the node with `--features mangata-rococo` to enable it."; +#[cfg(feature = "runtime-benchmarks")] +type HostFunctions = + (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); -#[cfg(feature = "mangata-kusama")] -/// Native executor instance. -pub struct MangataKusamaRuntimeExecutor; -#[cfg(feature = "mangata-kusama")] -impl sc_executor::NativeExecutionDispatch for MangataKusamaRuntimeExecutor { +pub type ParachainClient = TFullClient>; + +type ParachainBackend = TFullBackend; + +type ParachainBlockImport = + TParachainBlockImport>, ParachainBackend>; + +/// Rococo executor instance. +pub struct RococoRuntimeExecutor; + +impl sc_executor::NativeExecutionDispatch for RococoRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { - mangata_kusama_runtime::api::dispatch(method, data) + mangata_rococo_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - mangata_kusama_runtime::native_version() + mangata_rococo_runtime::native_version() } } -#[cfg(feature = "mangata-rococo")] -/// Native executor instance. -pub struct MangataRococoRuntimeExecutor; -#[cfg(feature = "mangata-rococo")] -impl sc_executor::NativeExecutionDispatch for MangataRococoRuntimeExecutor { +/// Rococo executor type. +pub struct KusamaRuntimeExecutor; + +impl sc_executor::NativeExecutionDispatch for KusamaRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { - mangata_rococo_runtime::api::dispatch(method, data) + mangata_kusama_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - mangata_rococo_runtime::native_version() + mangata_kusama_runtime::native_version() } } -pub type FullClient = - sc_service::TFullClient>; -pub type FullBackend = TFullBackend; - -pub type ParachainBlockImport = - TParachainBlockImport>, FullBackend>; - -/// Builds a new object suitable for chain operations. -#[allow(clippy::type_complexity)] -pub fn new_chain_ops( - config: &mut Configuration, -) -> Result< - ( - Arc, - Arc, - sc_consensus::BasicQueue>, - TaskManager, - ), - sc_service::Error, -> { - match &config.chain_spec { - #[cfg(feature = "mangata-kusama")] - spec if spec.is_mangata_kusama() => new_chain_ops_inner::< - mangata_kusama_runtime::RuntimeApi, - MangataKusamaRuntimeExecutor, - >(config), - #[cfg(feature = "mangata-rococo")] - spec if spec.is_mangata_rococo() => new_chain_ops_inner::< - mangata_rococo_runtime::RuntimeApi, - MangataRococoRuntimeExecutor, - >(config), - _ => panic!("invalid chain spec"), - } +pub trait RuntimeApiCollection: + sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt + + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + cumulus_primitives_core::CollectCollationInfo + + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi + + substrate_frame_rpc_system::AccountNonceApi + + sp_consensus_aura::AuraApi + + ver_api::VerApi + + ver_api::VerNonceApi + + xyk_rpc::XykRuntimeApi +{ } -#[allow(clippy::type_complexity)] -fn new_chain_ops_inner( - config: &mut Configuration, -) -> Result< - ( - Arc, - Arc, - sc_consensus::BasicQueue>, - TaskManager, - ), - sc_service::Error, -> -where - Client: From>>, - RuntimeApi: - ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: - RuntimeApiCollection>, - Executor: sc_executor::NativeExecutionDispatch + 'static, +impl RuntimeApiCollection for Api where + Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt + + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + cumulus_primitives_core::CollectCollationInfo + + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi + + substrate_frame_rpc_system::AccountNonceApi + + sp_consensus_aura::AuraApi + + ver_api::VerApi + + ver_api::VerNonceApi + + xyk_rpc::XykRuntimeApi { - let PartialComponents { client, backend, import_queue, task_manager, .. } = - new_partial::(config)?; - Ok((Arc::new(Client::from(client)), backend, import_queue, task_manager)) } /// Starts a `ServiceBuilder` for a full service. /// /// Use this macro if you don't actually need the full service, but just the builder in order to /// be able to perform chain operations. -#[allow(clippy::type_complexity)] -pub fn new_partial( +pub fn new_partial( config: &Configuration, ) -> Result< - sc_service::PartialComponents< - TFullClient>, - TFullBackend, + PartialComponents< + ParachainClient, + ParachainBackend, (), - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - ( - ParachainBlockImport, - Option, - Option, - ), + sc_consensus::DefaultImportQueue, + sc_transaction_pool::FullPool>, + (ParachainBlockImport, Option, Option), >, sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + sp_consensus_aura::AuraApi, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: RuntimeApiCollection, { let telemetry = config .telemetry_endpoints @@ -201,12 +159,17 @@ where }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); + let heap_pages = config + .default_heap_pages + .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ }); + + let executor = WasmExecutor::builder() + .with_execution_method(config.wasm_method) + .with_onchain_heap_alloc_strategy(heap_pages) + .with_offchain_heap_alloc_strategy(heap_pages) + .with_max_runtime_instances(config.max_runtime_instances) + .with_runtime_cache_size(config.runtime_cache_size) + .build(); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( @@ -231,36 +194,17 @@ where client.clone(), ); - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); - let import_queue = cumulus_client_consensus_aura::import_queue::< - sp_consensus_aura::sr25519::AuthorityPair, - _, - _, - _, - _, - _, - >(cumulus_client_consensus_aura::ImportQueueParams { - block_import: block_import.clone(), - client: client.clone(), - create_inherent_data_providers: move |_, _| async move { - let time = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, - slot_duration, - ); - - Ok((slot, time)) - }, - registry: config.prometheus_registry(), - spawner: &task_manager.spawn_essential_handle(), - telemetry: telemetry.as_ref().map(|telemetry| telemetry.handle()), - })?; + let import_queue = build_import_queue::( + client.clone(), + block_import.clone(), + config, + telemetry.as_ref().map(|telemetry| telemetry.handle()), + &task_manager, + )?; - let params = PartialComponents { + Ok(PartialComponents { backend, client, import_queue, @@ -269,81 +213,29 @@ where transaction_pool, select_chain: (), other: (block_import, telemetry, telemetry_worker_handle), - }; - - Ok(params) + }) } /// Start a node with the given parachain `Configuration` and relay chain `Configuration`. /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, - id: ParaId, - _rpc_ext_builder: RB, - build_consensus: BIC, + para_id: ParaId, hwbench: Option, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> +) -> sc_service::error::Result<(TaskManager, Arc>)> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi - + substrate_frame_rpc_system::AccountNonceApi - + ver_api::VerApi - + ver_api::VerNonceApi - + xyk_rpc::XykRuntimeApi - + sp_consensus_aura::AuraApi, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, - RB: Fn( - Arc>, - ) -> Result, sc_service::Error> - + Send - + 'static, - BIC: FnOnce( - Arc>>, - ParachainBlockImport, - Option<&Registry>, - Option, - &TaskManager, - Arc, - Arc< - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - >, - Arc>, - SyncCryptoStorePtr, - bool, - ParaId, - ) -> Result>, sc_service::Error>, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: RuntimeApiCollection, { let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config)?; - // let at = sp_runtime::generic::BlockId::Number(0u32.into()); - // let c = params.client.clone(); - // c.runtime_api().inherent_extrinsics(&at, InherentData::new()).unwrap(); - + let params = new_partial::(¶chain_config)?; let (block_import, mut telemetry, telemetry_worker_handle) = params.other; + let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network); let client = params.client.clone(); let backend = params.backend.clone(); @@ -360,29 +252,45 @@ where .await .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; - let force_authoring = parachain_config.force_authoring; let validator = parachain_config.role.is_authority(); let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); + let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), - para_id: id, + para_id, spawn_handle: task_manager.spawn_handle(), relay_chain_interface: relay_chain_interface.clone(), import_queue: params.import_queue, + sybil_resistance_level: CollatorSybilResistance::Resistant, // because of Aura }) .await?; if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), + use futures::FutureExt; + + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "offchain-work", + sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { + runtime_api_provider: client.clone(), + keystore: Some(params.keystore_container.keystore()), + offchain_db: backend.offchain_storage(), + transaction_pool: Some(OffchainTransactionPoolFactory::new( + transaction_pool.clone(), + )), + network_provider: network.clone(), + is_validator: parachain_config.role.is_authority(), + enable_http_requests: false, + custom_extensions: move |_| vec![], + }) + .run(client.clone(), task_manager.spawn_handle()) + .boxed(), ); } @@ -407,7 +315,7 @@ where transaction_pool: transaction_pool.clone(), task_manager: &mut task_manager, config: parachain_config, - keystore: params.keystore_container.sync_keystore(), + keystore: params.keystore_container.keystore(), backend, network: network.clone(), sync_service: sync_service.clone(), @@ -418,13 +326,8 @@ where if let Some(hwbench) = hwbench { sc_sysinfo::print_hwbench(&hwbench); - // Here you can check whether the hardware meets your chains' requirements. Putting a link - // in there and swapping out the requirements for your own are probably a good idea. The - // requirements for a para-chain are dictated by its relay-chain. - if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator { - log::warn!( - "⚠️ The hardware does not meet the minimal requirements for role 'Authority'." - ); + if validator { + warn_if_slow_hardware(&hwbench); } if let Some(ref mut telemetry) = telemetry { @@ -448,8 +351,25 @@ where .overseer_handle() .map_err(|e| sc_service::Error::Application(Box::new(e)))?; + start_relay_chain_tasks(StartRelayChainTasksParams { + client: client.clone(), + announce_block: announce_block.clone(), + para_id, + relay_chain_interface: relay_chain_interface.clone(), + task_manager: &mut task_manager, + da_recovery_profile: if validator { + DARecoveryProfile::Collator + } else { + DARecoveryProfile::FullNode + }, + import_queue: import_queue_service, + relay_chain_slot_duration, + recovery_handle: Box::new(overseer_handle.clone()), + sync_service: sync_service.clone(), + })?; + if validator { - let parachain_consensus = build_consensus( + start_consensus::( client.clone(), block_import, prometheus_registry.as_ref(), @@ -457,43 +377,14 @@ where &task_manager, relay_chain_interface.clone(), transaction_pool, - sync_service, - params.keystore_container.sync_keystore(), - force_authoring, - id, - )?; - - let spawner = task_manager.spawn_handle(); - - let params = StartCollatorParams { - para_id: id, - block_status: client.clone(), - announce_block, - client: client.clone(), - task_manager: &mut task_manager, - relay_chain_interface, - spawner, - parachain_consensus, - import_queue: import_queue_service, - collator_key: collator_key.expect("Command line arguments do not allow this. qed"), + sync_service.clone(), + params.keystore_container.keystore(), relay_chain_slot_duration, - recovery_handle: Box::new(overseer_handle), - }; - - start_collator(params).await?; - } else { - let params = StartFullNodeParams { - client: client.clone(), + para_id, + collator_key.expect("Command line arguments do not allow this. qed"), + overseer_handle, announce_block, - task_manager: &mut task_manager, - para_id: id, - relay_chain_interface, - relay_chain_slot_duration, - import_queue: import_queue_service, - recovery_handle: Box::new(overseer_handle), - }; - - start_full_node(params)?; + )?; } start_network.start_network(); @@ -501,114 +392,140 @@ where Ok((task_manager, client)) } +/// Build the import queue for the parachain runtime. +fn build_import_queue( + client: Arc>, + block_import: ParachainBlockImport, + config: &Configuration, + telemetry: Option, + task_manager: &TaskManager, +) -> Result, sc_service::Error> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: RuntimeApiCollection, +{ + let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; + + cumulus_client_consensus_aura::import_queue::< + sp_consensus_aura::sr25519::AuthorityPair, + _, + _, + _, + _, + _, + >(cumulus_client_consensus_aura::ImportQueueParams { + block_import, + client, + create_inherent_data_providers: move |_, _| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + Ok((slot, timestamp)) + }, + registry: config.prometheus_registry(), + spawner: &task_manager.spawn_essential_handle(), + telemetry, + }) + .map_err(Into::into) +} + +fn start_consensus( + client: Arc>, + block_import: ParachainBlockImport, + prometheus_registry: Option<&Registry>, + telemetry: Option, + task_manager: &TaskManager, + relay_chain_interface: Arc, + transaction_pool: Arc>>, + sync_oracle: Arc>, + keystore: KeystorePtr, + relay_chain_slot_duration: Duration, + para_id: ParaId, + collator_key: CollatorPair, + overseer_handle: OverseerHandle, + announce_block: Arc>) + Send + Sync>, +) -> Result<(), sc_service::Error> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: RuntimeApiCollection, +{ + // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant` + // when starting the network. + + let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; + + let proposer_factory = sc_basic_authorship_ver::ProposerFactory::with_proof_recording( + task_manager.spawn_handle(), + client.clone(), + transaction_pool, + prometheus_registry, + telemetry.clone(), + ); + + let proposer = Proposer::new(proposer_factory); + + let collator_service = CollatorService::new( + client.clone(), + Arc::new(task_manager.spawn_handle()), + announce_block, + client.clone(), + ); + + let params = BasicAuraParams { + create_inherent_data_providers: move |_, ()| async move { Ok(()) }, + block_import, + para_client: client, + relay_client: relay_chain_interface, + sync_oracle, + keystore, + collator_key, + para_id, + overseer_handle, + slot_duration, + relay_chain_slot_duration, + proposer, + collator_service, + // Very limited proposal time. + authoring_duration: Duration::from_millis(500), + }; + + let fut = + basic_aura::run::( + params, + ); + task_manager.spawn_essential_handle().spawn("aura", None, fut); + + Ok(()) +} + /// Start a parachain node. -pub async fn start_parachain_node( +pub async fn start_parachain_node( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, - id: ParaId, + para_id: ParaId, hwbench: Option, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> +) -> sc_service::error::Result<(TaskManager, Arc>)> where - Executor: sc_executor::NativeExecutionDispatch + 'static, - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi - + substrate_frame_rpc_system::AccountNonceApi - + ver_api::VerApi - + ver_api::VerNonceApi - + xyk_rpc::XykRuntimeApi - + sp_consensus_aura::AuraApi, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: RuntimeApiCollection, { - start_node_impl::( - parachain_config, - polkadot_config, - collator_options, - id, - |_| Ok(RpcModule::new(())), - |client, - block_import, - prometheus_registry, - telemetry, - task_manager, - relay_chain_interface, - transaction_pool, - sync_oracle, - keystore, - force_authoring, - id| { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - let proposer_factory = sc_basic_authorship_ver::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - let params = BuildAuraConsensusParams { - proposer_factory, - create_inherent_data_providers: move |_, (relay_parent, validation_data)| { - let relay_chain_interface = relay_chain_interface.clone(); - async move { - let parachain_inherent = - cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( - relay_parent, - &relay_chain_interface, - &validation_data, - id, - ) - .await; - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - let parachain_inherent = parachain_inherent.ok_or_else(|| { - Box::::from( - "Failed to create parachain inherent", - ) - })?; - Ok((slot, timestamp, parachain_inherent)) - } - }, - block_import, - para_client: client, - backoff_authoring_blocks: Option::<()>::None, - sync_oracle, - keystore, - force_authoring, - slot_duration, - // We got around 500ms for proposing - block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32), - // And a maximum of 750ms if slots are skipped - max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)), - telemetry, - }; + start_node_impl(parachain_config, polkadot_config, collator_options, para_id, hwbench).await +} - Ok(AuraConsensus::build::( - params, - )) - }, - hwbench, - ) - .await +/// Checks that the hardware meets the requirements and print a warning otherwise. +fn warn_if_slow_hardware(hwbench: &sc_sysinfo::HwBench) { + // Polkadot para-chains should generally use these requirements to ensure that the relay-chain + // will not take longer than expected to import its blocks. + if !frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE.check_hardware(hwbench) { + log::warn!( + "⚠️ The hardware does not meet the minimal requirements for role 'Authority' find out more at:\n\ + https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware" + ); + } } diff --git a/pallets/bootstrap/Cargo.toml b/pallets/bootstrap/Cargo.toml index d0b4466326..1f2084497a 100644 --- a/pallets/bootstrap/Cargo.toml +++ b/pallets/bootstrap/Cargo.toml @@ -2,70 +2,72 @@ authors = ["Mangata Team"] edition = "2018" license = "Unlicense" -name = 'pallet-bootstrap' -version = '0.1.0' +name = "pallet-bootstrap" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } +scale-info = { version = "2.0.0", features = ["derive"], default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } -orml-tokens = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { default-features = false, version = '5.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-arithmetic= { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-issuance = { path = "../issuance", default-features = false} -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } + +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", optional = true, branch = "develop", default-features = false } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -test-case = "2.0.2" -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -pallet-xyk = { path = "../xyk" } -pallet-proof-of-stake = { path = "../proof-of-stake" } -pallet-issuance = { path = "../issuance", default-features = false} +lazy_static = "1.1.1" mockall = "0.11.0" serial_test = "0.6.0" -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" +test-case = "2.0.2" + +pallet-issuance = { path = "../issuance", default-features = false } +pallet-proof-of-stake = { path = "../proof-of-stake" } +pallet-xyk = { path = "../xyk" } + +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [features] -default = ['std'] +default = ["std"] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] std = [ - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-runtime/std', - 'sp-io/std', - 'frame-support/std', - 'frame-system/std', - 'orml-tokens/std', + "codec/std", "frame-benchmarking/std", - 'pallet-vesting-mangata/std', - 'pallet-issuance/std', - "mangata-support/std" + "frame-support/std", + "frame-system/std", + "mangata-support/std", + "orml-tokens/std", + "pallet-vesting-mangata/std", + "serde", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "orml-tokens/try-runtime", "pallet-vesting-mangata/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/bootstrap/src/benchmarking.rs b/pallets/bootstrap/src/benchmarking.rs index a2c2abb009..5a49f5c81f 100644 --- a/pallets/bootstrap/src/benchmarking.rs +++ b/pallets/bootstrap/src/benchmarking.rs @@ -29,7 +29,11 @@ use orml_tokens::MultiTokenCurrencyExtended; use crate::Pallet as BootstrapPallet; const MILION: u128 = 1_000__000_000__000_000; -const DEFAULT_RATIO: (u128, u128) = (1_u128, 10_000_u128); +const DEFAULT_RATIO: (u32, u32) = (1_u32, 10_000_u32); + +fn default_ratio() -> (BalanceOf, BalanceOf) { + (DEFAULT_RATIO.0.into(), DEFAULT_RATIO.1.into()) +} benchmarks! { @@ -37,9 +41,9 @@ benchmarks! { frame_system::Pallet::::set_block_number(1_u32.into()); assert!(crate::BootstrapSchedule::::get().is_none()); let caller: T::AccountId = whitelisted_caller(); - let first_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let second_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - }: schedule_bootstrap(RawOrigin::Root, first_token_id, second_token_id, 123_456_789_u32.into(), Some(100_000_u32), 100_000_u32, Some(DEFAULT_RATIO), true) + let first_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let second_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + }: schedule_bootstrap(RawOrigin::Root, first_token_id, second_token_id, 123_456_789_u32.into(), Some(100_000_u32), 100_000_u32, Some(default_ratio::()), true) verify { assert!(crate::BootstrapSchedule::::get().is_some()); } @@ -47,26 +51,26 @@ benchmarks! { provision { frame_system::Pallet::::set_block_number(1_u32.into()); let caller: T::AccountId = whitelisted_caller(); - let first_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let second_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let ksm_provision_amount = 100_000_u128; + let first_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let second_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let ksm_provision_amount = 100_000_u32; let mga_provision_amount = ksm_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; - BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(DEFAULT_RATIO), false).unwrap(); + BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(default_ratio::()), false).unwrap(); // jump to public phase BootstrapPallet::::on_initialize(20_u32.into()); - BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount).unwrap(); + BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount.into()).unwrap(); - }: provision(RawOrigin::Signed(caller.clone().into()), first_token_id, ksm_provision_amount) + }: provision(RawOrigin::Signed(caller.clone().into()), first_token_id, ksm_provision_amount.into()) verify { - assert_eq!(BootstrapPallet::::provisions(caller, first_token_id), ksm_provision_amount); + assert_eq!(BootstrapPallet::::provisions(caller, first_token_id), ksm_provision_amount.into()); } // provision_vested { // frame_system::Pallet::::set_block_number(1_u32.into()); // let caller: T::AccountId = whitelisted_caller(); - // let first_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - // let second_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); + // let first_token_id = ::Currency::create(&caller, MILION.try_into().unwrap()).expect("Token creation failed").into(); + // let second_token_id = ::Currency::create(&caller, MILION.try_into().unwrap()).expect("Token creation failed").into(); // let ksm_provision_amount = 100_000_u128; // let mga_provision_amount = ksm_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; @@ -91,37 +95,37 @@ benchmarks! { claim_and_activate_liquidity_tokens { frame_system::Pallet::::set_block_number(1_u32.into()); let caller: T::AccountId = whitelisted_caller(); - let first_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let second_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let liquidity_asset_id = second_token_id + 1; + let first_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let second_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let liquidity_asset_id = second_token_id + 1_u32.into(); - let ksm_provision_amount = 100_000_u128; + let ksm_provision_amount = 100_000_u32; // let ksm_vested_provision_amount = 300_000_u128; - let ksm_vested_provision_amount = 0_u128; + let ksm_vested_provision_amount = 0_u32; let mga_provision_amount = ksm_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; let mga_vested_provision_amount = ksm_vested_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; - let total_ksm_provision = ksm_provision_amount + ksm_vested_provision_amount; - let total_mga_provision = mga_provision_amount + mga_vested_provision_amount; + let total_ksm_provision = (ksm_provision_amount + ksm_vested_provision_amount).into(); + let total_mga_provision = (mga_provision_amount + mga_vested_provision_amount).into(); let total_provision = total_ksm_provision + total_mga_provision; - let lock = 150_u128; + let lock = 150_u32; - ::VestingProvider::lock_tokens(&caller, first_token_id.into(), (ksm_provision_amount + ksm_vested_provision_amount).into(), None, lock.into()).unwrap(); - ::VestingProvider::lock_tokens(&caller, second_token_id.into(), (mga_provision_amount + mga_vested_provision_amount).into(), None, lock.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, first_token_id, (ksm_provision_amount + ksm_vested_provision_amount).into(), None, lock.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, second_token_id, (mga_provision_amount + mga_vested_provision_amount).into(), None, lock.into()).unwrap(); - BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(DEFAULT_RATIO), false).unwrap(); + BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(default_ratio::()), false).unwrap(); BootstrapPallet::::on_initialize(20_u32.into()); - BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount).unwrap(); - BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_provision_amount).unwrap(); + BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount.into()).unwrap(); + BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_provision_amount.into()).unwrap(); // BootstrapPallet::::provision_vested(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_vested_provision_amount).unwrap(); // BootstrapPallet::::provision_vested(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_vested_provision_amount).unwrap(); BootstrapPallet::::on_initialize(30_u32.into()); assert_eq!(BootstrapPallet::::phase(), BootstrapPhase::Finished); - assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), first_token_id), 0_u128); - assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), second_token_id), 0_u128); + assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), first_token_id), 0_u32.into()); + assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), second_token_id), 0_u32.into()); assert_eq!(BootstrapPallet::::valuations(), (total_mga_provision, total_ksm_provision)); - assert_eq!(BootstrapPallet::::provisions(caller.clone(), first_token_id), (ksm_provision_amount)); - assert_eq!(BootstrapPallet::::provisions(caller.clone(), second_token_id), (mga_provision_amount)); + assert_eq!(BootstrapPallet::::provisions(caller.clone(), first_token_id), (ksm_provision_amount.into())); + assert_eq!(BootstrapPallet::::provisions(caller.clone(), second_token_id), (mga_provision_amount.into())); // assert_eq!(BootstrapPallet::::vested_provisions(caller.clone(), first_token_id), (ksm_vested_provision_amount, 1, lock + 1)); // assert_eq!(BootstrapPallet::::vested_provisions(caller.clone(), second_token_id), (mga_vested_provision_amount, 1, lock + 1)); @@ -130,10 +134,10 @@ benchmarks! { }: claim_and_activate_liquidity_tokens(RawOrigin::Signed(caller.clone().into())) verify { let (total_mga_provision, total_ksm_provision) = BootstrapPallet::::valuations(); - let ksm_non_vested_rewards = total_provision / 2 / 2 * ksm_provision_amount / total_ksm_provision; - let ksm_vested_rewards = total_provision / 2 / 2 * ksm_vested_provision_amount / total_ksm_provision; - let mga_non_vested_rewards = total_provision / 2 / 2 * mga_provision_amount / total_mga_provision; - let mga_vested_rewards = total_provision / 2 / 2 * mga_vested_provision_amount / total_mga_provision; + let ksm_non_vested_rewards = total_provision / 4_u32.into() * ksm_provision_amount.into() / total_ksm_provision; + let ksm_vested_rewards = total_provision / 4_u32.into() * ksm_vested_provision_amount.into() / total_ksm_provision; + let mga_non_vested_rewards = total_provision / 4_u32.into() * mga_provision_amount.into() / total_mga_provision; + let mga_vested_rewards = total_provision / 4_u32.into() * mga_vested_provision_amount.into() / total_mga_provision; assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), first_token_id), ksm_vested_rewards + ksm_non_vested_rewards); assert_eq!(BootstrapPallet::::claimed_rewards(caller.clone(), second_token_id), mga_vested_rewards + mga_non_vested_rewards); @@ -142,26 +146,26 @@ benchmarks! { finalize { frame_system::Pallet::::set_block_number(1_u32.into()); let caller: T::AccountId = whitelisted_caller(); - let first_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); - let second_token_id = ::Currency::create(&caller, MILION.into()).expect("Token creation failed").into(); + let first_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); + let second_token_id = ::Currency::create(&caller, MILION.try_into().ok().expect("should fit")).expect("Token creation failed"); - let ksm_provision_amount = 100_000_u128; + let ksm_provision_amount = 100_000_u32; // let ksm_vested_provision_amount = 300_000_u128; - let ksm_vested_provision_amount = 0_u128; + let ksm_vested_provision_amount = 0_u32; let mga_provision_amount = ksm_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; let mga_vested_provision_amount = ksm_vested_provision_amount * DEFAULT_RATIO.1 / DEFAULT_RATIO.0; let total_ksm_provision = ksm_provision_amount + ksm_vested_provision_amount; let total_mga_provision = mga_provision_amount + mga_vested_provision_amount; let total_provision = total_ksm_provision + total_mga_provision; - let lock = 150_u128; + let lock = 150_u32; - ::VestingProvider::lock_tokens(&caller, first_token_id.into(), (ksm_provision_amount + ksm_vested_provision_amount).into(), None, lock.into()).unwrap(); - ::VestingProvider::lock_tokens(&caller, second_token_id.into(), (mga_provision_amount + mga_vested_provision_amount).into(), None, lock.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, first_token_id, (ksm_provision_amount + ksm_vested_provision_amount).into(), None, lock.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, second_token_id, (mga_provision_amount + mga_vested_provision_amount).into(), None, lock.into()).unwrap(); - BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(DEFAULT_RATIO), false).unwrap(); + BootstrapPallet::::schedule_bootstrap(RawOrigin::Root.into(), first_token_id, second_token_id, 10_u32.into(), Some(10_u32), 10_u32, Some(default_ratio::()), false).unwrap(); BootstrapPallet::::on_initialize(20_u32.into()); - BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount).unwrap(); - BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_provision_amount).unwrap(); + BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_provision_amount.into()).unwrap(); + BootstrapPallet::::provision(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_provision_amount.into()).unwrap(); // BootstrapPallet::::provision_vested(RawOrigin::Signed(caller.clone().into()).into(), second_token_id, mga_vested_provision_amount).unwrap(); // BootstrapPallet::::provision_vested(RawOrigin::Signed(caller.clone().into()).into(), first_token_id, ksm_vested_provision_amount).unwrap(); BootstrapPallet::::on_initialize(30_u32.into()); diff --git a/pallets/bootstrap/src/lib.rs b/pallets/bootstrap/src/lib.rs index 43b6bfe5f1..2cf9f675e7 100644 --- a/pallets/bootstrap/src/lib.rs +++ b/pallets/bootstrap/src/lib.rs @@ -126,28 +126,29 @@ //! use frame_support::pallet_prelude::*; +use codec::{Decode, Encode}; use frame_support::{ - codec::{Decode, Encode}, traits::{ - tokens::currency::MultiTokenCurrency, Contains, ExistenceRequirement, Get, StorageVersion, + Contains, ExistenceRequirement, Get, MultiTokenCurrency, MultiTokenVestingLocks, + StorageVersion, }, transactional, PalletId, }; -use frame_system::{ensure_root, ensure_signed, pallet_prelude::OriginFor}; +use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; use mangata_support::traits::{ AssetRegistryApi, GetMaintenanceStatusTrait, PoolCreateApi, ProofOfStakeRewardsApi, }; use mangata_types::multipurpose_liquidity::ActivateKind; -use mangata_types::{Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; -use pallet_vesting_mangata::MultiTokenVestingLocks; use scale_info::TypeInfo; use sp_arithmetic::{helpers_128bit::multiply_by_rational_with_rounding, per_things::Rounding}; use sp_core::U256; use sp_io::KillStorageResult; -use sp_runtime::traits::{AccountIdConversion, CheckedAdd, One, SaturatedConversion, Saturating}; +use sp_runtime::traits::{ + AccountIdConversion, Bounded, CheckedAdd, One, SaturatedConversion, Saturating, Zero, +}; use sp_std::{convert::TryInto, prelude::*}; #[cfg(test)] @@ -164,8 +165,6 @@ pub use weights::WeightInfo; pub use pallet::*; const PALLET_ID: PalletId = PalletId(*b"bootstrp"); -use core::fmt::Debug; - #[macro_export] macro_rules! log { ($level:tt, $patter:expr $(, $values:expr)* $(,)?) => { @@ -176,16 +175,18 @@ macro_rules! log { }; } -pub type BlockNrAsBalance = Balance; +type BalanceOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::Balance; -pub enum ProvisionKind { - Regular, - Vested(BlockNrAsBalance, BlockNrAsBalance), -} +type CurrencyIdOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + +type BlockNrAsBalance = BalanceOf; #[frame_support::pallet] pub mod pallet { - use super::*; const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); @@ -196,8 +197,8 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + impl Hooks> for Pallet { + fn on_initialize(n: BlockNumberFor) -> Weight { let phase = Phase::::get(); // R:1 if phase == BootstrapPhase::Finished { return T::DbWeight::get().reads(1) @@ -269,6 +270,17 @@ pub mod pallet { T::DbWeight::get().reads(2) } } + + fn on_runtime_upgrade() -> Weight { + let onchain = Pallet::::on_chain_storage_version(); + if onchain == 0 { + STORAGE_VERSION.put::>(); + T::DbWeight::get().reads_writes(1, 1) + } else { + log!(warn, "skipping version upgrade, remove migration"); + T::DbWeight::get().reads(1) + } + } } #[cfg(feature = "runtime-benchmarks")] @@ -289,18 +301,22 @@ pub mod pallet { type Currency: MultiTokenCurrencyExtended + MultiTokenReservableCurrency; - type PoolCreateApi: PoolCreateApi; + type PoolCreateApi: PoolCreateApi, CurrencyIdOf>; #[pallet::constant] type DefaultBootstrapPromotedPoolWeight: Get; #[pallet::constant] - type BootstrapUpdateBuffer: Get; + type BootstrapUpdateBuffer: Get>; #[pallet::constant] type TreasuryPalletId: Get; - type VestingProvider: MultiTokenVestingLocks; + type VestingProvider: MultiTokenVestingLocks< + Self::AccountId, + Currency = Self::Currency, + Moment = BlockNumberFor, + >; type ClearStorageLimit: Get; @@ -308,20 +324,27 @@ pub mod pallet { type RewardsApi: ProofOfStakeRewardsApi< Self::AccountId, - Balance = Balance, - CurrencyId = TokenId, + BalanceOf, + CurrencyIdOf, >; - type AssetRegistryApi: AssetRegistryApi; + type AssetRegistryApi: AssetRegistryApi>; } - /// maps ([`frame_system::Config::AccountId`], [`TokenId`]) -> [`Balance`] - identifies how much tokens did account provisioned in active bootstrap + /// maps ([`frame_system::Config::AccountId`], [`CurrencyId`]) -> [`Balance`] - identifies how much tokens did account provisioned in active bootstrap #[pallet::storage] #[pallet::getter(fn provisions)] - pub type Provisions = - StorageDoubleMap<_, Twox64Concat, T::AccountId, Twox64Concat, TokenId, Balance, ValueQuery>; + pub type Provisions = StorageDoubleMap< + _, + Twox64Concat, + T::AccountId, + Twox64Concat, + CurrencyIdOf, + BalanceOf, + ValueQuery, + >; - /// maps ([`frame_system::Config::AccountId`], [`TokenId`]) -> [`Balance`] - identifies how much vested tokens did account provisioned in active bootstrap + /// maps ([`frame_system::Config::AccountId`], [`CurrencyId`]) -> [`Balance`] - identifies how much vested tokens did account provisioned in active bootstrap #[pallet::storage] #[pallet::getter(fn vested_provisions)] pub type VestedProvisions = StorageDoubleMap< @@ -329,8 +352,8 @@ pub mod pallet { Twox64Concat, T::AccountId, Twox64Concat, - TokenId, - (Balance, BlockNrAsBalance, BlockNrAsBalance), + CurrencyIdOf, + (BalanceOf, BlockNrAsBalance, BlockNrAsBalance), ValueQuery, >; @@ -348,25 +371,33 @@ pub mod pallet { /// Total sum of provisions of `first` and `second` token in active bootstrap #[pallet::storage] #[pallet::getter(fn valuations)] - pub type Valuations = StorageValue<_, (Balance, Balance), ValueQuery>; + pub type Valuations = StorageValue<_, (BalanceOf, BalanceOf), ValueQuery>; /// Active bootstrap parameters #[pallet::storage] #[pallet::getter(fn config)] pub type BootstrapSchedule = - StorageValue<_, (T::BlockNumber, u32, u32, (u128, u128)), OptionQuery>; + StorageValue<_, (BlockNumberFor, u32, u32, (BalanceOf, BalanceOf)), OptionQuery>; #[pallet::storage] #[pallet::getter(fn minted_liquidity)] - pub type MintedLiquidity = StorageValue<_, (TokenId, Balance), ValueQuery>; + pub type MintedLiquidity = + StorageValue<_, (CurrencyIdOf, BalanceOf), ValueQuery>; - /// Maps ([`frame_system::Config::AccountId`], [`TokenId`] ) -> [`Balance`] - where [`TokeinId`] is id of the token that user participated with. This storage item is used to identify how much liquidity tokens has been claim by the user. If user participated with 2 tokens there are two entries associated with given account (`Address`, `first_token_id`) and (`Address`, `second_token_id`) + /// Maps ([`frame_system::Config::AccountId`], [`CurrencyId`] ) -> [`Balance`] - where [`CurrencyId`] is id of the token that user participated with. This storage item is used to identify how much liquidity tokens has been claim by the user. If user participated with 2 tokens there are two entries associated with given account (`Address`, `first_token_id`) and (`Address`, `second_token_id`) #[pallet::storage] #[pallet::getter(fn claimed_rewards)] - pub type ClaimedRewards = - StorageDoubleMap<_, Twox64Concat, T::AccountId, Twox64Concat, TokenId, Balance, ValueQuery>; + pub type ClaimedRewards = StorageDoubleMap< + _, + Twox64Concat, + T::AccountId, + Twox64Concat, + CurrencyIdOf, + BalanceOf, + ValueQuery, + >; - /// List of accouts that provisioned funds to bootstrap and has not claimed liquidity tokens yet + /// List of accounts that provisioned funds to bootstrap and has not claimed liquidity tokens yet #[pallet::storage] #[pallet::getter(fn provision_accounts)] pub type ProvisionAccounts = @@ -375,7 +406,8 @@ pub mod pallet { /// Currently bootstraped pair of tokens representaed as [ `first_token_id`, `second_token_id`] #[pallet::storage] #[pallet::getter(fn pair)] - pub type ActivePair = StorageValue<_, (TokenId, TokenId), OptionQuery>; + pub type ActivePair = + StorageValue<_, (CurrencyIdOf, CurrencyIdOf), OptionQuery>; /// Wheter to automatically promote the pool after [`BootstrapPhase::PublicPhase`] or not. #[pallet::storage] @@ -384,8 +416,11 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn archived)] - pub type ArchivedBootstrap = - StorageValue<_, Vec<(T::BlockNumber, u32, u32, (u128, u128))>, ValueQuery>; + pub type ArchivedBootstrap = StorageValue< + _, + Vec<(BlockNumberFor, u32, u32, (BalanceOf, BalanceOf))>, + ValueQuery, + >; #[pallet::call] impl Pallet { @@ -436,8 +471,8 @@ pub mod pallet { #[transactional] pub fn provision( origin: OriginFor, - token_id: TokenId, - amount: Balance, + token_id: CurrencyIdOf, + amount: BalanceOf, ) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -446,7 +481,7 @@ pub mod pallet { Error::::ProvisioningBlockedByMaintenanceMode ); - Self::do_provision(&sender, token_id, amount, ProvisionKind::Regular)?; + Self::do_provision(&sender, token_id, amount)?; ProvisionAccounts::::insert(&sender, ()); Self::deposit_event(Event::Provisioned(token_id, amount)); Ok(()) @@ -528,12 +563,12 @@ pub mod pallet { #[transactional] pub fn schedule_bootstrap( origin: OriginFor, - first_token_id: TokenId, - second_token_id: TokenId, - ido_start: T::BlockNumber, + first_token_id: CurrencyIdOf, + second_token_id: CurrencyIdOf, + ido_start: BlockNumberFor, whitelist_phase_length: Option, - public_phase_lenght: u32, - max_first_to_second_ratio: Option<(u128, u128)>, + public_phase_length: u32, + max_first_to_second_ratio: Option<(BalanceOf, BalanceOf)>, promote_bootstrap_pool: bool, ) -> DispatchResult { ensure_root(origin)?; @@ -559,20 +594,20 @@ pub mod pallet { ); let whitelist_phase_length = whitelist_phase_length.unwrap_or_default(); - let max_first_to_second_ratio = - max_first_to_second_ratio.unwrap_or((Balance::max_value(), Balance::one())); + let max_first_to_second_ratio = max_first_to_second_ratio + .unwrap_or((BalanceOf::::max_value(), BalanceOf::::one())); - ensure!(max_first_to_second_ratio.0 != 0, Error::::WrongRatio); + ensure!(max_first_to_second_ratio.0 != BalanceOf::::zero(), Error::::WrongRatio); - ensure!(max_first_to_second_ratio.1 != 0, Error::::WrongRatio); + ensure!(max_first_to_second_ratio.1 != BalanceOf::::zero(), Error::::WrongRatio); - ensure!(public_phase_lenght > 0, Error::::PhaseLengthCannotBeZero); + ensure!(public_phase_length > 0, Error::::PhaseLengthCannotBeZero); ensure!( ido_start .checked_add(&whitelist_phase_length.into()) .and_then(|whiteslist_start| whiteslist_start - .checked_add(&public_phase_lenght.into())) + .checked_add(&public_phase_length.into())) .is_some(), Error::::MathOverflow ); @@ -591,7 +626,7 @@ pub mod pallet { BootstrapSchedule::::put(( ido_start, whitelist_phase_length, - public_phase_lenght, + public_phase_length, max_first_to_second_ratio, )); @@ -764,7 +799,7 @@ pub mod pallet { Phase::::put(BootstrapPhase::BeforeStart); let (liq_token_id, _) = MintedLiquidity::::take(); let balance = T::Currency::free_balance(liq_token_id.into(), &Self::vault_address()); - if balance > 0_u128.into() { + if balance > 0_u32.into() { T::Currency::transfer( liq_token_id.into(), &Self::vault_address(), @@ -861,13 +896,13 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Funds provisioned - Provisioned(TokenId, Balance), + Provisioned(CurrencyIdOf, BalanceOf), /// Funds provisioned using vested tokens - VestedProvisioned(TokenId, Balance), + VestedProvisioned(CurrencyIdOf, BalanceOf), /// The activation of the rewards liquidity tokens failed - RewardsLiquidityAcitvationFailed(T::AccountId, TokenId, Balance), + RewardsLiquidityAcitvationFailed(T::AccountId, CurrencyIdOf, BalanceOf), /// Rewards claimed - RewardsClaimed(TokenId, Balance), + RewardsClaimed(CurrencyIdOf, BalanceOf), /// account whitelisted AccountsWhitelisted, /// bootstrap pre finalization has completed partially @@ -908,14 +943,14 @@ impl Pallet { fn claim_liquidity_tokens_from_single_currency( who: &T::AccountId, - provision_token_id: &TokenId, - rewards: Balance, - rewards_vested: Balance, - lock: (BlockNrAsBalance, BlockNrAsBalance), + provision_token_id: &CurrencyIdOf, + rewards: BalanceOf, + rewards_vested: BalanceOf, + lock: (BlockNrAsBalance, BlockNrAsBalance), ) -> DispatchResult { let (liq_token_id, _) = Self::minted_liquidity(); - let total_rewards = rewards.checked_add(rewards_vested).ok_or(Error::::MathOverflow)?; - if total_rewards == 0 { + let total_rewards = rewards.checked_add(&rewards_vested).ok_or(Error::::MathOverflow)?; + if total_rewards == BalanceOf::::zero() { return Ok(()) } @@ -923,12 +958,12 @@ impl Pallet { liq_token_id.into(), &Self::vault_address(), who, - total_rewards.into(), + total_rewards, ExistenceRequirement::KeepAlive, )?; ClaimedRewards::::try_mutate(who, provision_token_id, |rewards| { - if let Some(val) = rewards.checked_add(total_rewards) { + if let Some(val) = rewards.checked_add(&total_rewards) { *rewards = val; Ok(()) } else { @@ -936,13 +971,13 @@ impl Pallet { } })?; - if rewards_vested > 0 { - <::VestingProvider>::lock_tokens( + if rewards_vested > BalanceOf::::zero() { + T::VestingProvider::lock_tokens( who, - liq_token_id.into(), - rewards_vested.into(), - Some(lock.0.saturated_into()), - lock.1.into(), + liq_token_id, + rewards_vested, + Some(lock.0.into().saturated_into()), + lock.1, )?; } @@ -959,18 +994,18 @@ impl Pallet { /// actual_nominator * expected_denominator expected_nominator * actual_denominator /// ---------------------------------------- <= ---------------------------------------- /// actual_denominator * expected_denominator expected_denominator * actual_nominator - fn is_ratio_kept(ratio_nominator: u128, ratio_denominator: u128) -> bool { + fn is_ratio_kept(ratio_nominator: BalanceOf, ratio_denominator: BalanceOf) -> bool { let (second_token_valuation, first_token_valuation) = Valuations::::get(); - let left = U256::from(first_token_valuation) * U256::from(ratio_denominator); - let right = U256::from(ratio_nominator) * U256::from(second_token_valuation); + let left = U256::from(first_token_valuation.into()) * U256::from(ratio_denominator.into()); + let right = U256::from(ratio_nominator.into()) * U256::from(second_token_valuation.into()); left <= right } pub fn do_provision( sender: &T::AccountId, - token_id: TokenId, - amount: Balance, - is_vested: ProvisionKind, + token_id: CurrencyIdOf, + amount: BalanceOf, + // is_vested: ProvisionKind, ) -> DispatchResult { let is_first_token = token_id == Self::first_token_id(); let is_second_token = token_id == Self::second_token_id(); @@ -993,51 +1028,53 @@ impl Pallet { token_id.into(), sender, &Self::vault_address(), - amount.into(), + amount, ExistenceRequirement::KeepAlive, ) .or(Err(Error::::NotEnoughAssets))?; - match is_vested { - ProvisionKind::Regular => { - ensure!( - Provisions::::try_mutate(sender, token_id, |provision| { - if let Some(val) = provision.checked_add(amount) { - *provision = val; - Ok(()) - } else { - Err(()) - } - }) - .is_ok(), - Error::::MathOverflow - ); - }, - ProvisionKind::Vested(provision_start_block, provision_end_block) => { - ensure!( - VestedProvisions::::try_mutate( - sender, - token_id, - |(provision, start_block, end_block)| { - if let Some(val) = provision.checked_add(amount) { - *provision = val; - *start_block = (*start_block).max(provision_start_block); - *end_block = (*end_block).max(provision_end_block); - Ok(()) - } else { - Err(()) - } - } - ) - .is_ok(), - Error::::MathOverflow - ); - }, - } - + // match is_vested { + // ProvisionKind::Regular => { + ensure!( + Provisions::::try_mutate(sender, token_id, |provision| { + if let Some(val) = provision.checked_add(&amount) { + *provision = val; + Ok(()) + } else { + Err(()) + } + }) + .is_ok(), + Error::::MathOverflow + ); + /* + }, + ProvisionKind::Vested(provision_start_block, provision_end_block) => { + ensure!( + VestedProvisions::::try_mutate( + sender, + token_id, + |(provision, start_block, end_block)| { + if let Some(val) = provision.checked_add(amount) { + *provision = val; + *start_block = (*start_block).max(provision_start_block); + *end_block = (*end_block).max(provision_end_block); + Ok(()) + } else { + Err(()) + } + } + ) + .is_ok(), + Error::::MathOverflow + ); + }, + } + */ let (pre_second_token_valuation, _) = Valuations::::get(); ensure!( - token_id != Self::first_token_id() || pre_second_token_valuation != 0, + token_id != Self::first_token_id() || + pre_second_token_valuation != BalanceOf::::zero(), Error::::FirstProvisionInSecondTokenId ); @@ -1046,11 +1083,11 @@ impl Pallet { |(second_token_valuation, first_token_valuation)| -> Result<(), ()> { if token_id == Self::second_token_id() { *second_token_valuation = - second_token_valuation.checked_add(amount).ok_or(())?; + second_token_valuation.checked_add(&amount).ok_or(())?; } if token_id == Self::first_token_id() { *first_token_valuation = - first_token_valuation.checked_add(amount).ok_or(())?; + first_token_valuation.checked_add(&amount).ok_or(())?; } Ok(()) } @@ -1068,34 +1105,45 @@ impl Pallet { Ok(()) } - fn get_valuation(token_id: &TokenId) -> Balance { + fn get_valuation(token_id: &CurrencyIdOf) -> BalanceOf { if *token_id == Self::first_token_id() { Self::valuations().1 } else if *token_id == Self::second_token_id() { Self::valuations().0 } else { - 0 + BalanceOf::::zero() } } fn calculate_rewards( who: &T::AccountId, - token_id: &TokenId, - ) -> Result<(Balance, Balance, (BlockNrAsBalance, BlockNrAsBalance)), Error> { + token_id: &CurrencyIdOf, + ) -> Result<(BalanceOf, BalanceOf, (BlockNrAsBalance, BlockNrAsBalance)), Error> + { let valuation = Self::get_valuation(token_id); let provision = Self::provisions(who, token_id); let (vested_provision, lock_start, lock_end) = Self::vested_provisions(who, token_id); let (_, liquidity) = Self::minted_liquidity(); - let rewards = - multiply_by_rational_with_rounding(liquidity / 2, provision, valuation, Rounding::Down) - .ok_or(Error::::MathOverflow)?; + let rewards = multiply_by_rational_with_rounding( + liquidity.into() / 2, + provision.into(), + valuation.into(), + Rounding::Down, + ) + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; + let vested_rewards = multiply_by_rational_with_rounding( - liquidity / 2, - vested_provision, - valuation, + liquidity.into() / 2, + vested_provision.into(), + valuation.into(), Rounding::Down, ) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; + Ok((rewards, vested_rewards, (lock_start, lock_end))) } @@ -1124,11 +1172,11 @@ impl Pallet { Self::calculate_rewards(who, &Self::second_token_id())?; let total_rewards_claimed = second_token_rewards - .checked_add(second_token_rewards_vested) + .checked_add(&second_token_rewards_vested) .ok_or(Error::::MathOverflow)? - .checked_add(first_token_rewards) + .checked_add(&first_token_rewards) .ok_or(Error::::MathOverflow)? - .checked_add(first_token_rewards_vested) + .checked_add(&first_token_rewards_vested) .ok_or(Error::::MathOverflow)?; Self::claim_liquidity_tokens_from_single_currency( @@ -1140,7 +1188,7 @@ impl Pallet { )?; log!( info, - "Second token rewards (non-vested, vested) = ({}, {})", + "Second token rewards (non-vested, vested) = ({:?}, {:?})", second_token_rewards, second_token_rewards_vested, ); @@ -1154,7 +1202,7 @@ impl Pallet { )?; log!( info, - "First token rewards (non-vested, vested) = ({}, {})", + "First token rewards (non-vested, vested) = ({:?}, {:?})", first_token_rewards, first_token_rewards_vested, ); @@ -1163,9 +1211,9 @@ impl Pallet { if activate_rewards && ::RewardsApi::is_enabled(liq_token_id) { let non_vested_rewards = second_token_rewards - .checked_add(first_token_rewards) + .checked_add(&first_token_rewards) .ok_or(Error::::MathOverflow)?; - if non_vested_rewards > 0 { + if non_vested_rewards > BalanceOf::::zero() { let activate_result = ::RewardsApi::activate_liquidity( who.clone(), liq_token_id, @@ -1175,7 +1223,7 @@ impl Pallet { if let Err(err) = activate_result { log!( error, - "Activating liquidity tokens failed upon bootstrap claim rewards = ({:?}, {}, {}, {:?})", + "Activating liquidity tokens failed upon bootstrap claim rewards = ({:?}, {:?}, {:?}, {:?})", who, liq_token_id, non_vested_rewards, @@ -1196,17 +1244,17 @@ impl Pallet { Ok(()) } - fn first_token_id() -> TokenId { - ActivePair::::get().map(|(first, _)| first).unwrap_or(4_u32) + fn first_token_id() -> CurrencyIdOf { + ActivePair::::get().map(|(first, _)| first).unwrap_or(4_u32.into()) } - fn second_token_id() -> TokenId { - ActivePair::::get().map(|(_, second)| second).unwrap_or(0_u32) + fn second_token_id() -> CurrencyIdOf { + ActivePair::::get().map(|(_, second)| second).unwrap_or(0_u32.into()) } } -impl Contains<(TokenId, TokenId)> for Pallet { - fn contains(pair: &(TokenId, TokenId)) -> bool { +impl Contains<(CurrencyIdOf, CurrencyIdOf)> for Pallet { + fn contains(pair: &(CurrencyIdOf, CurrencyIdOf)) -> bool { pair == &(Self::first_token_id(), Self::second_token_id()) || pair == &(Self::second_token_id(), Self::first_token_id()) } diff --git a/pallets/bootstrap/src/mock.rs b/pallets/bootstrap/src/mock.rs index 41e286b08a..b38d53dee7 100644 --- a/pallets/bootstrap/src/mock.rs +++ b/pallets/bootstrap/src/mock.rs @@ -18,23 +18,26 @@ use super::*; use crate as pallet_bootstrap; -use codec::EncodeLike; use frame_support::{ construct_runtime, parameter_types, traits::{ tokens::currency::MultiTokenCurrency, ConstU128, ConstU32, Contains, Everything, Nothing, + WithdrawReasons, }, }; use mangata_support::traits::ActivationReservesProviderTrait; -use mangata_types::{multipurpose_liquidity::ActivateKind, Amount, Balance, TokenId}; +use mangata_types::multipurpose_liquidity::ActivateKind; use orml_tokens::MultiTokenCurrencyAdapter; use orml_traits::parameter_type_with_key; use pallet_xyk::AssetMetadataMutationTrait; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::{BuildStorage, Perbill, Percent}; use sp_std::convert::TryFrom; use std::sync::Mutex; pub(crate) type AccountId = u128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; +pub(crate) type Amount = i128; parameter_types!( pub const SomeConst: u64 = 10; @@ -44,15 +47,14 @@ parameter_types!( impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -111,6 +113,8 @@ parameter_types! { parameter_types! { pub const MinVestedTransfer: Balance = 0; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting_mangata::Config for Test { @@ -119,6 +123,7 @@ impl pallet_vesting_mangata::Config for Test { type BlockNumberToBalance = sp_runtime::traits::ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting_mangata::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 28; @@ -127,7 +132,7 @@ impl pallet_vesting_mangata::Config for Test { impl pallet_xyk::XykBenchmarkingConfig for Test {} pub struct AssetMetadataMutation; -impl AssetMetadataMutationTrait for AssetMetadataMutation { +impl AssetMetadataMutationTrait for AssetMetadataMutation { fn set_asset_info( _asset: TokenId, _name: Vec, @@ -170,40 +175,36 @@ impl pallet_proof_of_stake::Config for Test { impl BootstrapBenchmarkingConfig for Test {} pub struct TokensActivationPassthrough(PhantomData); -impl ActivationReservesProviderTrait for TokensActivationPassthrough +impl ActivationReservesProviderTrait + for TokensActivationPassthrough where - ::AccountId: EncodeLike, + T: frame_system::Config, + T::Currency: MultiTokenCurrency, { - type AccountId = T::AccountId; - - fn get_max_instant_unreserve_amount(token_id: TokenId, account_id: &Self::AccountId) -> Balance - where - ::AccountId: EncodeLike, - { + fn get_max_instant_unreserve_amount(token_id: TokenId, account_id: &AccountId) -> Balance { ProofOfStake::get_rewards_info(account_id.clone(), token_id).activated_amount } fn can_activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> bool { - ::Currency::can_reserve(token_id.into(), account_id, amount.into()) + ::Currency::can_reserve(token_id.into(), account_id, amount) } fn activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> DispatchResult { - ::Currency::reserve(token_id.into(), account_id, amount.into()) + ::Currency::reserve(token_id.into(), account_id, amount) } - fn deactivate(token_id: TokenId, account_id: &Self::AccountId, amount: Balance) -> Balance { - ::Currency::unreserve(token_id.into(), account_id, amount.into()) - .into() + fn deactivate(token_id: TokenId, account_id: &AccountId, amount: Balance) -> Balance { + ::Currency::unreserve(token_id.into(), account_id, amount) } } @@ -226,56 +227,72 @@ parameter_types! { pub const HistoryLimit: u32 = 10u32; } +impl pallet_issuance::Config for Test { + type RuntimeEvent = RuntimeEvent; + type NativeCurrencyId = MgaTokenId; + type Tokens = orml_tokens::MultiTokenCurrencyAdapter; + type BlocksPerRound = BlocksPerRound; + type HistoryLimit = HistoryLimit; + type LiquidityMiningIssuanceVault = LiquidityMiningIssuanceVault; + type StakingIssuanceVault = StakingIssuanceVault; + type TotalCrowdloanAllocation = TotalCrowdloanAllocation; + type IssuanceCap = IssuanceCap; + type LinearIssuanceBlocks = LinearIssuanceBlocks; + type LiquidityMiningSplit = LiquidityMiningSplit; + type StakingSplit = StakingSplit; + type ImmediateTGEReleasePercent = ImmediateTGEReleasePercent; + type TGEReleasePeriod = TGEReleasePeriod; + type TGEReleaseBegin = TGEReleaseBegin; + type VestingProvider = Vesting; + type WeightInfo = (); + type LiquidityMiningApi = ProofOfStake; +} + mockall::mock! { pub PoolCreateApi {} - impl PoolCreateApi for PoolCreateApi { - type AccountId = u128; - + impl PoolCreateApi for PoolCreateApi { fn pool_exists(first: TokenId, second: TokenId) -> bool; fn pool_create(account: u128, first: TokenId, first_amount: Balance, second: TokenId, second_amount: Balance) -> Option<(TokenId, Balance)>; - } } mockall::mock! { pub RewardsApi {} - impl ProofOfStakeRewardsApi for RewardsApi { - type Balance = ::Balance; - type CurrencyId = ::CurrencyId; + impl ProofOfStakeRewardsApi for RewardsApi { - fn enable(liquidity_token_id: >::CurrencyId, weight: u8); + fn enable(liquidity_token_id: TokenId, weight: u8); - fn disable(liquidity_token_id: >::CurrencyId); + fn disable(liquidity_token_id: TokenId); fn is_enabled( - liquidity_token_id: >::CurrencyId, + liquidity_token_id: TokenId, ) -> bool; fn claim_rewards_all( sender: AccountId, - liquidity_token_id: >::CurrencyId, - ) -> Result<>::Balance, DispatchError>; + liquidity_token_id: TokenId, + ) -> Result; // Activation & deactivation should happen in PoS fn activate_liquidity( sender: AccountId, - liquidity_token_id: >::CurrencyId, - amount: >::Balance, + liquidity_token_id: TokenId, + amount: Balance, use_balance_from: Option, ) -> DispatchResult; // Activation & deactivation should happen in PoS fn deactivate_liquidity( sender: AccountId, - liquidity_token_id: >::CurrencyId, - amount: >::Balance, + liquidity_token_id: TokenId, + amount: Balance, ) -> DispatchResult; fn calculate_rewards_amount( user: AccountId, - liquidity_asset_id: >::CurrencyId, + liquidity_asset_id: TokenId, ) -> Result; } @@ -284,13 +301,13 @@ mockall::mock! { mockall::mock! { pub AssetRegistryApi {} - impl AssetRegistryApi for AssetRegistryApi { + impl AssetRegistryApi for AssetRegistryApi { fn enable_pool_creation(assets: (TokenId, TokenId)) -> bool; } } pub struct AssetRegistry; -impl AssetRegistryApi for AssetRegistry { +impl AssetRegistryApi for AssetRegistry { fn enable_pool_creation(_assets: (TokenId, TokenId)) -> bool { true } @@ -331,7 +348,7 @@ impl GetMaintenanceStatusTrait for MockMaintenanceStatusProvider { } parameter_types! { - pub const BootstrapUpdateBuffer: ::BlockNumber = 10; + pub const BootstrapUpdateBuffer: BlockNumberFor = 10; pub const DefaultBootstrapPromotedPoolWeight: u8 = 1u8; pub const ClearStorageLimit: u32 = 10u32; } @@ -378,39 +395,34 @@ parameter_types! { pub const MaxDecimals: u32 = 255; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - Xyk: pallet_xyk::{Pallet, Call, Storage, Event, Config}, - Bootstrap: pallet_bootstrap::{Pallet, Call, Storage, Event}, - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, - ProofOfStake: pallet_proof_of_stake::{Pallet, Call, Storage, Event}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + Xyk: pallet_xyk, + Bootstrap: pallet_bootstrap, + Vesting: pallet_vesting_mangata, + ProofOfStake: pallet_proof_of_stake, + Issuance: pallet_issuance, } ); impl Pallet where - u128: From<::AccountId>, + T::Currency: MultiTokenCurrencyExtended, { - pub fn balance(id: TokenId, who: T::AccountId) -> Balance { - Tokens::accounts(Into::::into(who.clone()), Into::::into(id)).free - - Tokens::accounts(Into::::into(who), Into::::into(id)).frozen + pub fn balance(id: TokenId, who: AccountId) -> Balance { + Tokens::accounts(who.clone(), id).free - Tokens::accounts(who, id).frozen } - pub fn reserved_balance(id: TokenId, who: ::AccountId) -> Balance { - Tokens::accounts(Into::::into(who), Into::::into(id)).reserved + pub fn reserved_balance(id: TokenId, who: AccountId) -> Balance { + Tokens::accounts(who, id).reserved } - pub fn locked_balance(id: TokenId, who: ::AccountId) -> Balance { - Tokens::accounts(Into::::into(who), Into::::into(id)).frozen + pub fn locked_balance(id: TokenId, who: AccountId) -> Balance { + Tokens::accounts(who, id).frozen } pub fn total_supply(id: TokenId) -> Balance { @@ -418,30 +430,28 @@ where } pub fn transfer( currency_id: TokenId, - source: T::AccountId, - dest: T::AccountId, + source: AccountId, + dest: AccountId, value: Balance, ) -> DispatchResult { ::Currency::transfer( - currency_id.into(), + currency_id, &source, &dest, - value.into(), + value, frame_support::traits::ExistenceRequirement::KeepAlive, ) } - pub fn create_new_token(who: &T::AccountId, amount: Balance) -> TokenId { - ::Currency::create(who, amount.into()) - .expect("Token creation failed") - .into() + pub fn create_new_token(who: &AccountId, amount: Balance) -> TokenId { + ::Currency::create(who, amount).expect("Token creation failed") } } // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default() - .build_storage::() + let t = frame_system::GenesisConfig::::default() + .build_storage() .expect("Frame system builds valid default genesis config"); let mut ext = sp_io::TestExternalities::new(t); diff --git a/pallets/bootstrap/src/tests.rs b/pallets/bootstrap/src/tests.rs index 487daafd98..0d2b2b5051 100644 --- a/pallets/bootstrap/src/tests.rs +++ b/pallets/bootstrap/src/tests.rs @@ -1336,10 +1336,8 @@ macro_rules! init_mocks { }; } -fn provisions( - provisions: Vec<(::AccountId, TokenId, Balance, ProvisionKind)>, -) { - for (user_id, token_id, amount, _lock) in provisions { +fn provisions(provisions: Vec<(::AccountId, TokenId, Balance)>) { + for (user_id, token_id, amount) in provisions { ::Currency::transfer( token_id, &USER_ID, @@ -1465,10 +1463,10 @@ fn multi_provisions_only_with_non_vested() { // ACT provisions(vec![ - (PROVISION_USER1_ID, MGAId::get(), 100_000, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 10, ProvisionKind::Regular), - (PROVISION_USER2_ID, MGAId::get(), 300_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 30, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 100_000), + (PROVISION_USER1_ID, KSMId::get(), 10), + (PROVISION_USER2_ID, MGAId::get(), 300_000), + (PROVISION_USER2_ID, KSMId::get(), 30), ]); let (mga_valuation, ksm_valuation) = Bootstrap::valuations(); let liq_token_minted = (mga_valuation + ksm_valuation) / 2; @@ -1643,10 +1641,10 @@ fn multi_provisions_only_with_non_vested() { #[test_case( vec![ - (PROVISION_USER1_ID, MGAId::get(), 100_000,ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 10, ProvisionKind::Regular), - (PROVISION_USER2_ID, MGAId::get(), 300_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 30, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 100_000), + (PROVISION_USER1_ID, KSMId::get(), 10), + (PROVISION_USER2_ID, MGAId::get(), 300_000), + (PROVISION_USER2_ID, KSMId::get(), 30), ], (50_004, 0), (150014, 0); @@ -1654,8 +1652,8 @@ fn multi_provisions_only_with_non_vested() { ] #[test_case( vec![ - (PROVISION_USER1_ID, MGAId::get(), 100_000, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 10, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 100_000), + (PROVISION_USER1_ID, KSMId::get(), 10), ], (50_004, 0), (0, 0); @@ -1663,8 +1661,8 @@ fn multi_provisions_only_with_non_vested() { ] #[test_case( vec![ - (PROVISION_USER1_ID, MGAId::get(), 100_000, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 10, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 100_000), + (PROVISION_USER1_ID, KSMId::get(), 10), ], (50_004, 0), (0, 0); @@ -1672,10 +1670,10 @@ fn multi_provisions_only_with_non_vested() { ] #[test_case( vec![ - (PROVISION_USER1_ID, MGAId::get(), 100_000, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 10, ProvisionKind::Regular), - (PROVISION_USER2_ID, MGAId::get(), 300_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 30, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 100_000), + (PROVISION_USER1_ID, KSMId::get(), 10), + (PROVISION_USER2_ID, MGAId::get(), 300_000), + (PROVISION_USER2_ID, KSMId::get(), 30), ], (50_004, 0), // 400040 / 2 / 2 * 1 / 4 (150014, 0); // 400040 / 2 / 2 * 3 / 4 @@ -1683,22 +1681,22 @@ fn multi_provisions_only_with_non_vested() { ] #[test_case( vec![ - (PROVISION_USER1_ID, MGAId::get(), 10_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER1_ID, MGAId::get(), 20_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER1_ID, MGAId::get(), 30_000, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 1, ProvisionKind::Regular), - (PROVISION_USER1_ID, MGAId::get(), 40_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, MGAId::get(), 200_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, MGAId::get(), 100_000, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 10, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), 15, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 4, ProvisionKind::Regular), - (PROVISION_USER1_ID, KSMId::get(), 5, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), 10_000), + (PROVISION_USER2_ID, KSMId::get(), 1), + (PROVISION_USER1_ID, MGAId::get(), 20_000), + (PROVISION_USER2_ID, KSMId::get(), 1), + (PROVISION_USER2_ID, KSMId::get(), 1), + (PROVISION_USER1_ID, MGAId::get(), 30_000), + (PROVISION_USER1_ID, KSMId::get(), 1), + (PROVISION_USER2_ID, KSMId::get(), 1), + (PROVISION_USER2_ID, KSMId::get(), 1), + (PROVISION_USER1_ID, MGAId::get(), 40_000), + (PROVISION_USER2_ID, MGAId::get(), 200_000), + (PROVISION_USER2_ID, MGAId::get(), 100_000), + (PROVISION_USER2_ID, KSMId::get(), 10), + (PROVISION_USER2_ID, KSMId::get(), 15), + (PROVISION_USER1_ID, KSMId::get(), 4), + (PROVISION_USER1_ID, KSMId::get(), 5), ], (50004, 0), (150014, 0); @@ -1706,12 +1704,7 @@ fn multi_provisions_only_with_non_vested() { ] #[serial] fn test_multi_provisions_only_with_non_vested( - provisions_list: Vec<( - ::AccountId, - TokenId, - Balance, - ProvisionKind, - )>, + provisions_list: Vec<(::AccountId, TokenId, Balance)>, user1_rewards: (Balance, Balance), user2_rewards: (Balance, Balance), ) { @@ -1725,13 +1718,13 @@ fn test_multi_provisions_only_with_non_vested( let liq_token_id = Tokens::next_asset_id(); let user1_has_provisions = - provisions_list.iter().any(|(who, _, _, _)| *who == PROVISION_USER1_ID); + provisions_list.iter().any(|(who, _, _)| *who == PROVISION_USER1_ID); let user2_has_provisions = - provisions_list.iter().any(|(who, _, _, _)| *who == PROVISION_USER2_ID); + provisions_list.iter().any(|(who, _, _)| *who == PROVISION_USER2_ID); let total_ksm_provision: u128 = provisions_list .iter() .filter_map( - |(_, token_id, amount, _)| { + |(_, token_id, amount)| { if *token_id == KSMId::get() { Some(amount) } else { @@ -1743,7 +1736,7 @@ fn test_multi_provisions_only_with_non_vested( let total_mga_provision: u128 = provisions_list .iter() .filter_map( - |(_, token_id, amount, _)| { + |(_, token_id, amount)| { if *token_id == MGAId::get() { Some(amount) } else { @@ -2116,8 +2109,8 @@ fn test_activate_liq_tokens_is_called_with_all_liq_tokens_when_pool_is_promoted_ // ACT provisions(vec![ - (PROVISION_USER1_ID, MGAId::get(), mga_provision, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), ksm_provision, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), mga_provision), + (PROVISION_USER2_ID, KSMId::get(), ksm_provision), ]); let (mga_valuation, ksm_valuation) = Bootstrap::valuations(); assert_eq!(mga_valuation, 1_000_000); @@ -2227,8 +2220,8 @@ fn test_dont_activate_liquidity_when_pool_is_not_promoted_and_provisions_are_not // ACT provisions(vec![ - (PROVISION_USER1_ID, MGAId::get(), mga_provision, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), ksm_provision, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), mga_provision), + (PROVISION_USER2_ID, KSMId::get(), ksm_provision), ]); Bootstrap::on_initialize(100_u32.into()); @@ -2267,8 +2260,8 @@ fn test_claim_and_activate_doesnt_fail_when_tokens_activations_fails() { // ACT provisions(vec![ - (PROVISION_USER1_ID, MGAId::get(), mga_provision, ProvisionKind::Regular), - (PROVISION_USER2_ID, KSMId::get(), ksm_provision, ProvisionKind::Regular), + (PROVISION_USER1_ID, MGAId::get(), mga_provision), + (PROVISION_USER2_ID, KSMId::get(), ksm_provision), ]); Bootstrap::on_initialize(100_u32.into()); assert_eq!(BootstrapPhase::Finished, Phase::::get()); diff --git a/pallets/fee-lock/Cargo.toml b/pallets/fee-lock/Cargo.toml index 5e68380273..886577fe3a 100644 --- a/pallets/fee-lock/Cargo.toml +++ b/pallets/fee-lock/Cargo.toml @@ -1,56 +1,59 @@ [package] -authors = ['Mangata team'] -edition = '2018' -name = 'pallet-fee-lock' -version = '0.1.0' +authors = ["Mangata team"] +edition = "2018" +name = "pallet-fee-lock" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex = { package = "rustc-hex", version = "2.1.0", default-features = false } hex-literal = { version = "0.3.3", default-features = false } +log = { version = "0.4.14", default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = "5.0.0", default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -pallet-xyk = { path = '../xyk/', default-features = false} -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-arithmetic = { default-features = false, version = '6.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +pallet-xyk = { path = "../xyk/", default-features = false } + +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" env_logger = "0.9.0" +lazy_static = "1.1.1" serial_test = { version = "0.6.0", default-features = false } test-case = "2.0.2" +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + [features] -default = ['std'] +default = ["std"] enable-trading = [] std = [ - 'hex/std', - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - "sp-runtime/std", - 'frame-support/std', - 'frame-system/std', - "frame-benchmarking/std", - 'orml-tokens/std', + "codec/std", "frame-benchmarking/std", - "mangata-support/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "mangata-support/std", + "orml-tokens/std", + "serde", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] @@ -60,5 +63,5 @@ try-runtime = [ "frame-system/try-runtime", "orml-tokens/try-runtime", "pallet-xyk/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/fee-lock/src/benchmarking.rs b/pallets/fee-lock/src/benchmarking.rs index bc4a1e526b..507e08b192 100644 --- a/pallets/fee-lock/src/benchmarking.rs +++ b/pallets/fee-lock/src/benchmarking.rs @@ -26,21 +26,19 @@ use frame_support::{assert_ok, traits::tokens::currency::MultiTokenCurrency}; use frame_system::RawOrigin; use orml_tokens::MultiTokenCurrencyExtended; -use sp_std::collections::btree_set::BTreeSet; - use crate::Pallet as FeeLock; -const MGA_TOKEN_ID: TokenId = 0; +const MGA_TOKEN_ID: u32 = 0; benchmarks! { update_fee_lock_metadata{ - let period_length: T::BlockNumber = 1000u32.into(); - let fee_lock_amount: Balance = 1000; - let swap_value_threshold: Balance = 1000; - let mut whitelisted_tokens: Vec<(TokenId, bool)> = Vec::new(); + let period_length: BlockNumberFor = 1000u32.into(); + let fee_lock_amount: BalanceOf = 1000_u32.into(); + let swap_value_threshold: BalanceOf = 1000_u32.into(); + let mut whitelisted_tokens: Vec<(CurrencyIdOf, bool)> = Vec::new(); for i in 0..::MaxCuratedTokens::get() { - whitelisted_tokens.push((i, true)); + whitelisted_tokens.push((i.into(), true)); } }: {assert_ok!(FeeLock::::update_fee_lock_metadata(RawOrigin::Root.into(), Some(period_length), Some(fee_lock_amount), Some(swap_value_threshold), Some(whitelisted_tokens)));} verify{ @@ -53,22 +51,22 @@ benchmarks! { unlock_fee{ let caller: T::AccountId = whitelisted_caller(); - let period_length: T::BlockNumber = 10u32.into(); - let fee_lock_amount: Balance = 1000; - let swap_value_threshold: Balance = 1000; + let period_length: BlockNumberFor = 10u32.into(); + let fee_lock_amount: BalanceOf = 1000_u32.into(); + let swap_value_threshold: BalanceOf = 1000_u32.into(); let now= >::block_number(); - let token_id = MGA_TOKEN_ID; + let token_id = MGA_TOKEN_ID.into(); - if ::Tokens::get_next_currency_id().into() > TokenId::from(MGA_TOKEN_ID){ - assert_ok!(::Tokens::mint(token_id.into(), &caller.clone(), 1_000_000u128.into())); + if ::Tokens::get_next_currency_id() > token_id { + assert_ok!(::Tokens::mint(token_id, &caller.clone(), 1_000_000u32.into())); } else { - assert_eq!(::Tokens::create(&caller.clone(), 1_000_000u128.into()).unwrap().into(), token_id); + assert_eq!(::Tokens::create(&caller.clone(), 1_000_000u32.into()).unwrap(), token_id); } - let initial_user_free_balance:Balance = ::Tokens::free_balance(token_id.into(), &caller.clone()).into(); - let initial_user_reserved_balance:Balance = ::Tokens::reserved_balance(token_id.into(), &caller.clone()).into(); - let initial_user_locked_balance:Balance = ::Tokens::locked_balance(token_id.into(), &caller.clone()).into(); + let initial_user_free_balance = ::Tokens::free_balance(token_id, &caller.clone()); + let initial_user_reserved_balance = ::Tokens::reserved_balance(token_id, &caller.clone()); + let initial_user_locked_balance = ::Tokens::locked_balance(token_id, &caller.clone()); assert_ok!(FeeLock::::update_fee_lock_metadata(RawOrigin::Root.into(), Some(period_length), Some(fee_lock_amount), Some(swap_value_threshold), None)); @@ -78,14 +76,14 @@ benchmarks! { assert_eq!(FeeLock::::get_fee_lock_metadata().unwrap().whitelisted_tokens.len(), 0u32 as usize); assert_ok!( - as FeeLockTriggerTrait<_>>::process_fee_lock(&caller) + as FeeLockTriggerTrait<_,_,_>>::process_fee_lock(&caller) ); - assert_eq!(::Tokens::free_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::free_balance(token_id, &caller.clone()), initial_user_free_balance - fee_lock_amount); - assert_eq!(::Tokens::reserved_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::reserved_balance(token_id, &caller.clone()), initial_user_reserved_balance + fee_lock_amount); - assert_eq!(::Tokens::locked_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::locked_balance(token_id, &caller.clone()), initial_user_locked_balance); assert_eq!(FeeLock::::get_account_fee_lock_data(caller.clone()), AccountFeeLockDataInfo{ @@ -97,16 +95,16 @@ benchmarks! { }: {assert_ok!(FeeLock::::unlock_fee(RawOrigin::Signed(caller.clone().into()).into()));} verify{ - assert_eq!(::Tokens::free_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::free_balance(token_id, &caller.clone()), initial_user_free_balance); - assert_eq!(::Tokens::reserved_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::reserved_balance(token_id, &caller.clone()), initial_user_reserved_balance); - assert_eq!(::Tokens::locked_balance(token_id.into(), &caller.clone()).into(), + assert_eq!(::Tokens::locked_balance(token_id, &caller.clone()), initial_user_locked_balance); assert_eq!(FeeLock::::get_account_fee_lock_data(caller.clone()), AccountFeeLockDataInfo{ - total_fee_lock_amount: 0, - last_fee_lock_block: 0u32.into(), + total_fee_lock_amount: BalanceOf::::zero(), + last_fee_lock_block: 0_u32.into(), }); } diff --git a/pallets/fee-lock/src/lib.rs b/pallets/fee-lock/src/lib.rs index 3e4e5dc376..74f6797b8d 100644 --- a/pallets/fee-lock/src/lib.rs +++ b/pallets/fee-lock/src/lib.rs @@ -1,23 +1,22 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![feature(custom_test_frameworks)] +// #![feature(custom_test_frameworks)] use frame_support::{ dispatch::DispatchResult, ensure, pallet_prelude::*, storage::bounded_btree_set::BoundedBTreeSet, - traits::{Get, StorageVersion}, + traits::{Get, MultiTokenCurrency, StorageVersion}, transactional, }; use frame_system::{ensure_signed, pallet_prelude::*}; use mangata_support::traits::{FeeLockTriggerTrait, Valuate}; -use mangata_types::{Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; use sp_arithmetic::per_things::Rounding; use sp_runtime::helpers_128bit::multiply_by_rational_with_rounding; use sp_runtime::{ - traits::{CheckedAdd, Zero}, + traits::{Bounded, CheckedAdd, SaturatedConversion, Zero}, Saturating, }; use sp_std::{convert::TryInto, prelude::*}; @@ -47,6 +46,14 @@ macro_rules! log { pub use pallet::*; +pub type BalanceOf = <::Tokens as MultiTokenCurrency< + ::AccountId, +>>::Balance; + +pub type CurrencyIdOf = <::Tokens as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -58,8 +65,8 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet { - fn on_idle(now: T::BlockNumber, remaining_weight: Weight) -> Weight { + impl Hooks> for Pallet { + fn on_idle(now: BlockNumberFor, remaining_weight: Weight) -> Weight { let mut consumed_weight: Weight = Default::default(); // process only up to 80% or remaining weight @@ -105,8 +112,11 @@ pub mod pallet { if matches!(unlock_block, Some(unlock) if unlock <= now) { UnlockQueueBegin::::put(i + 1); consumed_weight += T::WeightInfo::unlock_fee(); - let _ = - >::unlock_fee(&who); + let _ = , + CurrencyIdOf, + >>::unlock_fee(&who); } else { break } @@ -131,14 +141,14 @@ pub mod pallet { #[codec(mel_bound(T: Config))] #[scale_info(skip_type_params(T))] pub struct FeeLockMetadataInfo { - pub period_length: T::BlockNumber, - pub fee_lock_amount: Balance, - pub swap_value_threshold: Balance, - pub whitelisted_tokens: BoundedBTreeSet, + pub period_length: BlockNumberFor, + pub fee_lock_amount: BalanceOf, + pub swap_value_threshold: BalanceOf, + pub whitelisted_tokens: BoundedBTreeSet, T::MaxCuratedTokens>, } impl FeeLockMetadataInfo { - pub fn is_whitelisted(&self, token_id: TokenId) -> bool { + pub fn is_whitelisted(&self, token_id: CurrencyIdOf) -> bool { if T::NativeTokenId::get() == token_id { return true } @@ -166,7 +176,7 @@ pub mod pallet { #[derive( Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, Default, )] - pub struct AccountFeeLockDataInfo { + pub struct AccountFeeLockDataInfo { pub total_fee_lock_amount: Balance, pub last_fee_lock_block: BlockNumber, } @@ -177,7 +187,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - AccountFeeLockDataInfo, + AccountFeeLockDataInfo, BalanceOf>, ValueQuery, >; @@ -185,8 +195,8 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { FeeLockMetadataUpdated, - FeeLockUnlocked(T::AccountId, Balance), - FeeLocked { who: T::AccountId, lock_amount: Balance, total_locked: Balance }, + FeeLockUnlocked(T::AccountId, BalanceOf), + FeeLocked { who: T::AccountId, lock_amount: BalanceOf, total_locked: BalanceOf }, } #[pallet::error] @@ -215,21 +225,20 @@ pub mod pallet { type MaxCuratedTokens: Get; type Tokens: MultiTokenCurrencyExtended + MultiTokenReservableCurrency; - type PoolReservesProvider: Valuate; + type PoolReservesProvider: Valuate, CurrencyIdOf>; #[pallet::constant] - type NativeTokenId: Get; + type NativeTokenId: Get>; type WeightInfo: WeightInfo; } #[pallet::genesis_config] pub struct GenesisConfig { - pub period_length: Option, - pub fee_lock_amount: Option, - pub swap_value_threshold: Option, - pub whitelisted_tokens: Vec, + pub period_length: Option>, + pub fee_lock_amount: Option>, + pub swap_value_threshold: Option>, + pub whitelisted_tokens: Vec>, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { @@ -242,11 +251,11 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { match (self.period_length, self.fee_lock_amount, self.swap_value_threshold) { (Some(period), Some(amount), Some(threshold)) => { - let mut tokens: BoundedBTreeSet = + let mut tokens: BoundedBTreeSet, T::MaxCuratedTokens> = Default::default(); for t in self.whitelisted_tokens.iter() { tokens @@ -277,10 +286,10 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::update_fee_lock_metadata())] pub fn update_fee_lock_metadata( origin: OriginFor, - period_length: Option, - fee_lock_amount: Option, - swap_value_threshold: Option, - should_be_whitelisted: Option>, + period_length: Option>, + fee_lock_amount: Option>, + swap_value_threshold: Option>, + should_be_whitelisted: Option, bool)>>, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -338,7 +347,7 @@ pub mod pallet { pub fn unlock_fee(origin: OriginFor) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; - Ok(>::unlock_fee(&who)?.into()) + Ok(, CurrencyIdOf>>::unlock_fee(&who)?.into()) } } } @@ -364,8 +373,8 @@ impl Pallet { } } -impl FeeLockTriggerTrait for Pallet { - fn is_whitelisted(token_id: TokenId) -> bool { +impl FeeLockTriggerTrait, CurrencyIdOf> for Pallet { + fn is_whitelisted(token_id: CurrencyIdOf) -> bool { if let Some(fee_lock_metadata) = Self::get_fee_lock_metadata() { fee_lock_metadata.is_whitelisted(token_id) } else { @@ -374,14 +383,14 @@ impl FeeLockTriggerTrait for Pallet { } fn get_swap_valuation_for_token( - valuating_token_id: TokenId, - valuating_token_amount: Balance, - ) -> Option { + valuating_token_id: CurrencyIdOf, + valuating_token_amount: BalanceOf, + ) -> Option> { if T::NativeTokenId::get() == valuating_token_id { return Some(valuating_token_amount) } let (native_token_pool_reserve, valuating_token_pool_reserve) = - ::get_reserves( + , CurrencyIdOf>>::get_reserves( T::NativeTokenId::get(), valuating_token_id, ) @@ -391,12 +400,13 @@ impl FeeLockTriggerTrait for Pallet { } Some( multiply_by_rational_with_rounding( - valuating_token_amount, - native_token_pool_reserve, - valuating_token_pool_reserve, + valuating_token_amount.into(), + native_token_pool_reserve.into(), + valuating_token_pool_reserve.into(), Rounding::Down, ) - .unwrap_or(Balance::max_value()), + .map(SaturatedConversion::saturated_into) + .unwrap_or(BalanceOf::::max_value()), ) } @@ -420,7 +430,7 @@ impl FeeLockTriggerTrait for Pallet { ::Tokens::reserve( ::NativeTokenId::get().into(), who, - fee_lock_metadata.fee_lock_amount.into(), + fee_lock_metadata.fee_lock_amount, )?; // Insert updated account_lock_info into storage @@ -442,13 +452,13 @@ impl FeeLockTriggerTrait for Pallet { (x, y) if x > y => ::Tokens::reserve( ::NativeTokenId::get().into(), who, - x.saturating_sub(y).into(), + x.saturating_sub(y), )?, (x, y) if x < y => { let unreserve_result = ::Tokens::unreserve( ::NativeTokenId::get().into(), who, - y.saturating_sub(x).into(), + y.saturating_sub(x), ); if !unreserve_result.is_zero() { log::warn!( @@ -521,7 +531,7 @@ impl FeeLockTriggerTrait for Pallet { let unreserve_result = ::Tokens::unreserve( ::NativeTokenId::get().into(), &who, - account_fee_lock_data.total_fee_lock_amount.into(), + account_fee_lock_data.total_fee_lock_amount, ); if !unreserve_result.is_zero() { log::warn!( diff --git a/pallets/fee-lock/src/mock.rs b/pallets/fee-lock/src/mock.rs index 0e3dbab812..76a5f6ae4e 100644 --- a/pallets/fee-lock/src/mock.rs +++ b/pallets/fee-lock/src/mock.rs @@ -1,73 +1,63 @@ // Copyright (C) 2020 Mangata team use super::*; -use sp_std::convert::TryFrom; - -use sp_core::H256; - -use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, -}; use crate as pallet_fee_lock; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU32, Contains, Everything}, - weights::{constants::RocksDbWeight, Weight}, + traits::{Contains, Everything}, + weights::constants::RocksDbWeight, PalletId, }; use frame_system as system; -use mangata_types::Amount; use orml_traits::parameter_type_with_key; +use sp_runtime::{traits::AccountIdConversion, BuildStorage}; +use sp_std::convert::TryFrom; pub const NATIVE_CURRENCY_ID: u32 = 0; - pub(crate) type AccountId = u128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; +pub(crate) type Amount = i128; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - FeeLock: pallet_fee_lock::{Pallet, Storage, Call, Event}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + FeeLock: pallet_fee_lock, } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; -} -impl system::Config for Test { +parameter_types!( + pub const BlockHashCount: u32 = 250; +); + +impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); type DbWeight = RocksDbWeight; type Version = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type PalletInfo = PalletInfo; - type BlockWeights = (); - type BlockLength = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } parameter_type_with_key! { @@ -112,42 +102,36 @@ parameter_types! { pub struct MockPoolReservesProvider(PhantomData); -impl Valuate for MockPoolReservesProvider { - type Balance = Balance; - - type CurrencyId = TokenId; - +impl Valuate for MockPoolReservesProvider { fn get_liquidity_asset( - _first_asset_id: Self::CurrencyId, - _second_asset_id: Self::CurrencyId, + _first_asset_id: TokenId, + _second_asset_id: TokenId, ) -> Result { unimplemented!() } fn get_liquidity_token_mga_pool( - _liquidity_token_id: Self::CurrencyId, - ) -> Result<(Self::CurrencyId, Self::CurrencyId), DispatchError> { + _liquidity_token_id: TokenId, + ) -> Result<(TokenId, TokenId), DispatchError> { unimplemented!() } fn valuate_liquidity_token( - _liquidity_token_id: Self::CurrencyId, - _liquidity_token_amount: Self::Balance, - ) -> Self::Balance { + _liquidity_token_id: TokenId, + _liquidity_token_amount: Balance, + ) -> Balance { unimplemented!() } fn scale_liquidity_by_mga_valuation( - _mga_valuation: Self::Balance, - _liquidity_token_amount: Self::Balance, - _mga_token_amount: Self::Balance, - ) -> Self::Balance { + _mga_valuation: Balance, + _liquidity_token_amount: Balance, + _mga_token_amount: Balance, + ) -> Balance { unimplemented!() } - fn get_pool_state( - _liquidity_token_id: Self::CurrencyId, - ) -> Option<(Self::Balance, Self::Balance)> { + fn get_pool_state(_liquidity_token_id: TokenId) -> Option<(Balance, Balance)> { unimplemented!() } @@ -182,7 +166,7 @@ impl pallet_fee_lock::Config for Test { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + system::GenesisConfig::::default().build_storage().unwrap().into() } pub struct ExtBuilder { @@ -191,11 +175,11 @@ pub struct ExtBuilder { impl ExtBuilder { pub fn new() -> Self { - let t = frame_system::GenesisConfig::default() - .build_storage::() + let t = frame_system::GenesisConfig::::default() + .build_storage() .expect("Frame system builds valid default genesis config"); - let mut ext = sp_io::TestExternalities::new(t); + let ext = sp_io::TestExternalities::new(t); Self { ext } } diff --git a/pallets/fee-lock/src/tests.rs b/pallets/fee-lock/src/tests.rs index 3a91725237..01edb85e74 100644 --- a/pallets/fee-lock/src/tests.rs +++ b/pallets/fee-lock/src/tests.rs @@ -180,7 +180,7 @@ fn process_fee_lock_trigger_works() { assert_eq!(now, 0); // First timeout on empty user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -200,7 +200,7 @@ fn process_fee_lock_trigger_works() { ); // Second timeout on user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -220,7 +220,7 @@ fn process_fee_lock_trigger_works() { ); // Third timeout on user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -245,7 +245,7 @@ fn process_fee_lock_trigger_works() { let now = System::block_number(); // First timeout in current period on Thrice timedout user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -270,7 +270,7 @@ fn process_fee_lock_trigger_works() { let now = System::block_number(); // First timeout in current period on Once timedout user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -290,7 +290,7 @@ fn process_fee_lock_trigger_works() { ); // Second timeout - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -314,7 +314,7 @@ fn process_fee_lock_trigger_works() { let now = System::block_number(); - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -383,7 +383,7 @@ fn unlock_fee_works() { assert_eq!(now, 0); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::NotFeeLocked ); assert_noop!( @@ -392,7 +392,7 @@ fn unlock_fee_works() { ); // First timeout on empty user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -412,7 +412,7 @@ fn unlock_fee_works() { ); // Second timeout on user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -432,7 +432,7 @@ fn unlock_fee_works() { ); // Third timeout on user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -452,7 +452,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::CantUnlockFeeYet ); assert_noop!( @@ -465,7 +465,7 @@ fn unlock_fee_works() { let now = System::block_number(); - assert_ok!(>::can_unlock_fee(&0u128)); + assert_ok!(>::can_unlock_fee(&0u128)); assert_ok!(FeeLock::unlock_fee(RuntimeOrigin::signed(0u128).into())); assert_eq!( @@ -486,7 +486,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::NotFeeLocked ); assert_noop!( @@ -495,7 +495,7 @@ fn unlock_fee_works() { ); // First timeout in current period on Thrice timedout user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -515,7 +515,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::CantUnlockFeeYet ); assert_noop!( @@ -529,7 +529,7 @@ fn unlock_fee_works() { let now = System::block_number(); // First timeout in current period on Once timedout user state - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -549,7 +549,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::CantUnlockFeeYet ); assert_noop!( @@ -558,7 +558,7 @@ fn unlock_fee_works() { ); // Second timeout - assert_ok!(>::process_fee_lock(&0u128)); + assert_ok!(>::process_fee_lock(&0u128)); assert_eq!( Tokens::accounts(0u128, token_id), @@ -578,7 +578,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::CantUnlockFeeYet ); assert_noop!( @@ -591,7 +591,7 @@ fn unlock_fee_works() { let now = System::block_number(); - assert_ok!(>::can_unlock_fee(&0u128)); + assert_ok!(>::can_unlock_fee(&0u128)); assert_ok!(FeeLock::unlock_fee(RuntimeOrigin::signed(0u128).into())); assert_eq!( @@ -612,7 +612,7 @@ fn unlock_fee_works() { ); assert_noop!( - >::can_unlock_fee(&0u128), + >::can_unlock_fee(&0u128), Error::::NotFeeLocked ); assert_noop!( @@ -648,75 +648,102 @@ fn whitelist_and_valuation_works() { ); // Native is always whitelisted - assert!(>::is_whitelisted(0)); + assert!(>::is_whitelisted(0)); - assert!(>::is_whitelisted(1)); - assert!(>::is_whitelisted(2)); + assert!(>::is_whitelisted(1)); + assert!(>::is_whitelisted(2)); - assert!(!>::is_whitelisted(3)); + assert!(!>::is_whitelisted(3)); assert_eq!( - >::get_swap_valuation_for_token(0, 1000), + >::get_swap_valuation_for_token(0, 1000), Some(1000) ); assert_eq!( - >::get_swap_valuation_for_token(0, 0), + >::get_swap_valuation_for_token(0, 0), Some(0) ); assert_eq!( - >::get_swap_valuation_for_token(0, u128::max_value()), + >::get_swap_valuation_for_token( + 0, + u128::max_value() + ), Some(u128::max_value()) ); assert_eq!( - >::get_swap_valuation_for_token(1, 1000), + >::get_swap_valuation_for_token(1, 1000), Some(500) ); assert_eq!( - >::get_swap_valuation_for_token(1, 0), + >::get_swap_valuation_for_token(1, 0), Some(0) ); assert_eq!( - >::get_swap_valuation_for_token(1, u128::max_value()), + >::get_swap_valuation_for_token( + 1, + u128::max_value() + ), Some(u128::max_value() / 2) ); assert_eq!( - >::get_swap_valuation_for_token(2, 1000), + >::get_swap_valuation_for_token(2, 1000), Some(2000) ); assert_eq!( - >::get_swap_valuation_for_token(2, 0), + >::get_swap_valuation_for_token(2, 0), Some(0) ); assert_eq!( - >::get_swap_valuation_for_token(2, u128::max_value()), + >::get_swap_valuation_for_token( + 2, + u128::max_value() + ), Some(u128::max_value()) ); assert_eq!( - >::get_swap_valuation_for_token(3, 1000), + >::get_swap_valuation_for_token(3, 1000), + None + ); + assert_eq!( + >::get_swap_valuation_for_token(3, 0), None ); - assert_eq!(>::get_swap_valuation_for_token(3, 0), None); assert_eq!( - >::get_swap_valuation_for_token(3, u128::max_value()), + >::get_swap_valuation_for_token( + 3, + u128::max_value() + ), None ); assert_eq!( - >::get_swap_valuation_for_token(4, 1000), + >::get_swap_valuation_for_token(4, 1000), None ); - assert_eq!(>::get_swap_valuation_for_token(4, 0), None); assert_eq!( - >::get_swap_valuation_for_token(4, u128::max_value()), + >::get_swap_valuation_for_token(4, 0), None ); assert_eq!( - >::get_swap_valuation_for_token(5, 1000), + >::get_swap_valuation_for_token( + 4, + u128::max_value() + ), None ); - assert_eq!(>::get_swap_valuation_for_token(5, 0), None); assert_eq!( - >::get_swap_valuation_for_token(5, u128::max_value()), + >::get_swap_valuation_for_token(5, 1000), + None + ); + assert_eq!( + >::get_swap_valuation_for_token(5, 0), + None + ); + assert_eq!( + >::get_swap_valuation_for_token( + 5, + u128::max_value() + ), None ); }) @@ -778,11 +805,11 @@ fn test_on_idle_unlock_for_single_user( .initialize_fee_locks(PERIOD_LENGTH, FEE_LOCK_AMOUNT, SWAP_VALUE_THRESHOLD) .build() .execute_with(|| { - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); fast_forward_blocks(PERIOD_LENGTH); // assert - assert_ok!(>::can_unlock_fee(&ALICE)); + assert_ok!(>::can_unlock_fee(&ALICE)); assert_eq!( Tokens::accounts(ALICE, NativeCurrencyId::get()), AccountData { @@ -832,7 +859,7 @@ fn test_on_idle_unlock_multiple_users( .build() .execute_with(|| { for (account, _) in expected_account_data.iter() { - >::process_fee_lock(account).unwrap(); + >::process_fee_lock(account).unwrap(); } fast_forward_blocks(PERIOD_LENGTH); @@ -856,7 +883,7 @@ fn test_unlock_happens_not_sooner_but_after_period() { .execute_with(|| { // lets move to some block that is not aligned with period start fast_forward_blocks(7); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); for _ in 0..PERIOD_LENGTH - 1 { fast_forward_blocks(1); @@ -890,9 +917,9 @@ fn test_unlock_stops_after_single_iteration_without_consuming_unnecessary_weight .execute_with(|| { // lets move to some block that is not aligned with period start fast_forward_blocks(3); - >::process_fee_lock(&ALICE).unwrap(); - >::process_fee_lock(&BOB).unwrap(); - >::process_fee_lock(&CHARLIE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&CHARLIE).unwrap(); fast_forward_blocks(3); let consumed_weight = FeeLock::on_idle(System::block_number(), UNLIMITED_WEIGHT); @@ -933,7 +960,7 @@ fn test_maintain_queue_with_subsequent_fee_locks_on_single_account() { assert_eq!(FeeLockMetadataQeueuePosition::::get(BOB), None); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 0); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueue::::get(0), Some(ALICE)); assert_eq!(UnlockQueue::::get(1), None); @@ -944,7 +971,7 @@ fn test_maintain_queue_with_subsequent_fee_locks_on_single_account() { assert_eq!(UnlockQueueEnd::::get(), 1); fast_forward_blocks(1); - >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&BOB).unwrap(); assert_eq!(UnlockQueue::::get(0), Some(ALICE)); assert_eq!(UnlockQueue::::get(1), Some(BOB)); assert_eq!(UnlockQueue::::get(2), None); @@ -954,7 +981,7 @@ fn test_maintain_queue_with_subsequent_fee_locks_on_single_account() { assert_eq!(UnlockQueueEnd::::get(), 2); fast_forward_blocks(1); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueue::::get(0), None); assert_eq!(UnlockQueue::::get(1), Some(BOB)); assert_eq!(UnlockQueue::::get(2), Some(ALICE)); @@ -980,12 +1007,12 @@ fn test_process_queue_and_ignore_outdated_items_in_unlock_queue_because_of_subse assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 0); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 1); fast_forward_blocks(1); - >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&BOB).unwrap(); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 2); fast_forward_blocks(1); @@ -994,7 +1021,7 @@ fn test_process_queue_and_ignore_outdated_items_in_unlock_queue_because_of_subse assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 2); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 3); @@ -1019,12 +1046,12 @@ fn test_process_queue_and_ignore_outdated_items_in_unlock_queue_because_of_manua assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 0); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 1); fast_forward_blocks(PERIOD_LENGTH / 2); - >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&BOB).unwrap(); assert_eq!(UnlockQueueBegin::::get(), 0); assert_eq!(UnlockQueueEnd::::get(), 2); @@ -1062,9 +1089,9 @@ fn test_unlock_happens_in_order() { .execute_with(|| { let weight_for_single_unlock: Weight = calculate_estimated_weight(1, 6, 1); - >::process_fee_lock(&ALICE).unwrap(); - >::process_fee_lock(&BOB).unwrap(); - >::process_fee_lock(&CHARLIE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&CHARLIE).unwrap(); assert_eq!( Tokens::accounts(ALICE, NativeCurrencyId::get()), ACCOUNT_WITH_LOCKED_TOKENS @@ -1130,7 +1157,7 @@ fn test_queue_storage_is_cleaned_up() { assert_eq!(UnlockQueue::::get(0), None); assert_eq!(UnlockQueue::::get(1), None); - >::process_fee_lock(&ALICE).unwrap(); + >::process_fee_lock(&ALICE).unwrap(); assert_eq!(UnlockQueue::::get(0), Some(ALICE)); assert_eq!(UnlockQueue::::get(1), None); assert_eq!( @@ -1138,7 +1165,7 @@ fn test_queue_storage_is_cleaned_up() { ACCOUNT_WITH_LOCKED_TOKENS ); - >::process_fee_lock(&BOB).unwrap(); + >::process_fee_lock(&BOB).unwrap(); assert_eq!(UnlockQueue::::get(0), Some(ALICE)); assert_eq!(UnlockQueue::::get(1), Some(BOB)); assert_eq!(Tokens::accounts(BOB, NativeCurrencyId::get()), ACCOUNT_WITH_LOCKED_TOKENS); diff --git a/pallets/issuance/Cargo.toml b/pallets/issuance/Cargo.toml index 6ae05721ee..bfe64726b8 100644 --- a/pallets/issuance/Cargo.toml +++ b/pallets/issuance/Cargo.toml @@ -2,63 +2,66 @@ authors = ["Mangata Team"] edition = "2018" license = "Unlicense" -name = 'pallet-issuance' -version = '2.0.0' +name = "pallet-issuance" +version = "2.0.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] +cfg-if = "1.0.0" +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } log = { version = "0.4.14", default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } -orml-tokens = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-std = { default-features = false, version = '5.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev", optional = true, default-features = false } -cfg-if = "1.0.0" -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } lazy_static = "1.1.1" +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + [features] -default = ['std'] +default = ["std"] std = [ - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - 'sp-runtime/std', - 'frame-support/std', - 'frame-system/std', + "codec/std", + "frame-support/std", + "frame-system/std", "frame-benchmarking/std", - 'orml-tokens/std', - 'pallet-vesting-mangata/std', "mangata-support/std", + "orml-tokens/std", + "pallet-vesting-mangata/std", + "serde", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "orml-tokens/try-runtime", "pallet-vesting-mangata/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/issuance/src/benchmarking.rs b/pallets/issuance/src/benchmarking.rs index 15355db271..08ccfc51c5 100644 --- a/pallets/issuance/src/benchmarking.rs +++ b/pallets/issuance/src/benchmarking.rs @@ -22,18 +22,17 @@ use super::*; use frame_benchmarking::{account, benchmarks}; use frame_support::assert_ok; use frame_system::RawOrigin; -use mangata_types::Balance; use orml_tokens::MultiTokenCurrencyExtended; use crate::{Pallet as Issuance, TgeInfo}; const SEED: u32 = u32::max_value(); -const TGE_AMOUNT: Balance = 1_000_000; +const TGE_AMOUNT: u32 = 1_000_000; -fn create_tge_infos(x: u32) -> Vec> { - let mut tge_infos: Vec> = Vec::new(); +fn create_tge_infos(x: u32) -> Vec>> { + let mut tge_infos: Vec>> = Vec::new(); for i in 0..x { - tge_infos.push(TgeInfo { who: account("who", 0, SEED - i), amount: TGE_AMOUNT }); + tge_infos.push(TgeInfo { who: account("who", 0, SEED - i), amount: TGE_AMOUNT.into() }); } tge_infos } @@ -86,15 +85,15 @@ benchmarks! { IssuanceConfigStore::::get().is_none() ); - assert_eq!(TGETotal::::get(), tge_infos.iter().fold(Balance::zero(), |acc: Balance, tge_info| acc.saturating_add(tge_info.amount))); + assert_eq!(TGETotal::::get(), tge_infos.iter().fold(BalanceOf::::zero(), |acc: BalanceOf, tge_info| acc.saturating_add(tge_info.amount))); let lock_percent = Percent::from_percent(100) .checked_sub(&T::ImmediateTGEReleasePercent::get()).unwrap(); for tge_info in tge_infos{ - assert_eq!(T::VestingProvider::vesting_balance(&tge_info.who, T::NativeCurrencyId::get().into()).unwrap().into(), lock_percent * tge_info.amount); - assert_eq!(T::Tokens::free_balance(T::NativeCurrencyId::get().into(), &tge_info.who).into(), tge_info.amount); - assert_eq!(>::locked_balance(T::NativeCurrencyId::get().into(), &tge_info.who).into(), lock_percent * tge_info.amount); + assert_eq!(T::VestingProvider::vesting_balance(&tge_info.who, T::NativeCurrencyId::get()).unwrap(), lock_percent * tge_info.amount); + assert_eq!(T::Tokens::free_balance(T::NativeCurrencyId::get(), &tge_info.who), tge_info.amount); + assert_eq!(>::locked_balance(T::NativeCurrencyId::get(), &tge_info.who), lock_percent * tge_info.amount); } } diff --git a/pallets/issuance/src/lib.rs b/pallets/issuance/src/lib.rs index 3bf5479564..8b6b31c4ac 100644 --- a/pallets/issuance/src/lib.rs +++ b/pallets/issuance/src/lib.rs @@ -2,27 +2,21 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::pallet_prelude::*; -use frame_system::pallet_prelude::*; - +use codec::{Decode, Encode}; use frame_support::{ - codec::{Decode, Encode}, - traits::{tokens::currency::MultiTokenCurrency, Get, Imbalance}, + pallet_prelude::*, + traits::{tokens::currency::MultiTokenCurrency, Get, Imbalance, MultiTokenVestingSchedule}, }; +use frame_system::pallet_prelude::*; use mangata_support::traits::{ComputeIssuance, GetIssuance, LiquidityMiningApi}; -use mangata_types::{Balance, TokenId}; use orml_tokens::MultiTokenCurrencyExtended; -use pallet_vesting_mangata::MultiTokenVestingSchedule; use scale_info::TypeInfo; use sp_runtime::{ - traits::{CheckedAdd, CheckedSub, One, Zero}, + traits::{CheckedAdd, CheckedDiv, CheckedSub, One, Saturating, Zero}, Perbill, Percent, RuntimeDebug, }; use sp_std::{convert::TryInto, prelude::*}; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; - #[cfg(test)] mod mock; @@ -31,9 +25,8 @@ mod tests; mod benchmarking; -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] -pub struct IssuanceInfo { +pub struct IssuanceInfo { // Max number of MGA to target pub cap: Balance, // MGA created at token generation event @@ -50,9 +43,9 @@ pub struct IssuanceInfo { } #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] -pub struct TgeInfo { +pub struct TgeInfo { // The tge target - pub who: A, + pub who: AccountId, // Amount distributed at tge pub amount: Balance, } @@ -88,6 +81,13 @@ impl WeightInfo for () { pub use pallet::*; +type BalanceOf = + <::Tokens as MultiTokenCurrency<::AccountId>>::Balance; + +type CurrencyIdOf = <::Tokens as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + #[frame_support::pallet] pub mod pallet { @@ -98,7 +98,7 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks> for Pallet {} /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] @@ -106,7 +106,7 @@ pub mod pallet { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// MGA currency to check total_issuance - type NativeCurrencyId: Get; + type NativeCurrencyId: Get>; /// Tokens type Tokens: MultiTokenCurrencyExtended; /// Number of blocks per session/round @@ -123,13 +123,13 @@ pub mod pallet { type StakingIssuanceVault: Get; #[pallet::constant] /// The total mga allocated for crowdloans - type TotalCrowdloanAllocation: Get; + type TotalCrowdloanAllocation: Get>; #[pallet::constant] /// The maximum amount of Mangata tokens type ImmediateTGEReleasePercent: Get; #[pallet::constant] /// The maximum amount of Mangata tokens - type IssuanceCap: Get; + type IssuanceCap: Get>; #[pallet::constant] /// The number of blocks the issuance is linear type LinearIssuanceBlocks: Get; @@ -149,19 +149,20 @@ pub mod pallet { type VestingProvider: MultiTokenVestingSchedule< Self::AccountId, Currency = Self::Tokens, - Moment = Self::BlockNumber, + Moment = BlockNumberFor, >; type WeightInfo: WeightInfo; - type LiquidityMiningApi: LiquidityMiningApi; + type LiquidityMiningApi: LiquidityMiningApi>; } #[pallet::storage] #[pallet::getter(fn get_issuance_config)] - pub type IssuanceConfigStore = StorageValue<_, IssuanceInfo, OptionQuery>; + pub type IssuanceConfigStore = + StorageValue<_, IssuanceInfo>, OptionQuery>; #[pallet::storage] #[pallet::getter(fn get_tge_total)] - pub type TGETotal = StorageValue<_, Balance, ValueQuery>; + pub type TGETotal = StorageValue<_, BalanceOf, ValueQuery>; #[pallet::storage] #[pallet::getter(fn is_tge_finalized)] @@ -170,7 +171,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn get_session_issuance)] pub type SessionIssuance = - StorageMap<_, Twox64Concat, u32, Option<(Balance, Balance)>, ValueQuery>; + StorageMap<_, Twox64Concat, u32, Option<(BalanceOf, BalanceOf)>, ValueQuery>; #[pallet::error] /// Errors @@ -219,7 +220,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::execute_tge(tge_infos.len() as u32))] pub fn execute_tge( origin: OriginFor, - tge_infos: Vec>, + tge_infos: Vec>>, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; @@ -232,14 +233,14 @@ pub mod pallet { .ok_or(Error::::MathError)?; for tge_info in tge_infos { - let locked: Balance = (lock_percent * tge_info.amount).max(One::one()); - let per_block: Balance = - (locked / T::TGEReleasePeriod::get() as Balance).max(One::one()); + let locked: BalanceOf = (lock_percent * tge_info.amount).max(One::one()); + let per_block: BalanceOf = + (locked / T::TGEReleasePeriod::get().into()).max(One::one()); if T::VestingProvider::can_add_vesting_schedule( &tge_info.who, - locked.into(), - per_block.into(), + locked, + per_block, T::TGEReleaseBegin::get().into(), T::NativeCurrencyId::get().into(), ) @@ -248,7 +249,7 @@ pub mod pallet { let imb = T::Tokens::deposit_creating( T::NativeCurrencyId::get().into(), &tge_info.who.clone(), - tge_info.amount.into(), + tge_info.amount, ); if !tge_info.amount.is_zero() && imb.peek().is_zero() { @@ -256,8 +257,8 @@ pub mod pallet { } else { let _ = T::VestingProvider::add_vesting_schedule( &tge_info.who, - locked.into(), - per_block.into(), + locked, + per_block, T::TGEReleaseBegin::get().into(), T::NativeCurrencyId::get().into(), ); @@ -277,17 +278,17 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Issuance for upcoming session issued - SessionIssuanceIssued(u32, Balance, Balance), + SessionIssuanceIssued(u32, BalanceOf, BalanceOf), /// Issuance for upcoming session calculated and recorded - SessionIssuanceRecorded(u32, Balance, Balance), + SessionIssuanceRecorded(u32, BalanceOf, BalanceOf), /// Issuance configuration has been finalized - IssuanceConfigInitialized(IssuanceInfo), + IssuanceConfigInitialized(IssuanceInfo>), /// TGE has been finalized TGEFinalized, /// A TGE instance has failed - TGEInstanceFailed(TgeInfo), + TGEInstanceFailed(TgeInfo>), /// A TGE instance has succeeded - TGEInstanceSucceeded(TgeInfo), + TGEInstanceSucceeded(TgeInfo>), } } @@ -303,25 +304,25 @@ impl ComputeIssuance for Pallet { } } -pub trait ProvideTotalCrowdloanRewardAllocation { - fn get_total_crowdloan_allocation() -> Option; +pub trait ProvideTotalCrowdloanRewardAllocation { + fn get_total_crowdloan_allocation() -> Option>; } -impl ProvideTotalCrowdloanRewardAllocation for Pallet { - fn get_total_crowdloan_allocation() -> Option { +impl ProvideTotalCrowdloanRewardAllocation for Pallet { + fn get_total_crowdloan_allocation() -> Option> { IssuanceConfigStore::::get() .map(|issuance_config| issuance_config.total_crowdloan_allocation) } } -impl GetIssuance for Pallet { - fn get_all_issuance(n: u32) -> Option<(Balance, Balance)> { +impl GetIssuance> for Pallet { + fn get_all_issuance(n: u32) -> Option<(BalanceOf, BalanceOf)> { SessionIssuance::::get(n) } - fn get_liquidity_mining_issuance(n: u32) -> Option { + fn get_liquidity_mining_issuance(n: u32) -> Option> { SessionIssuance::::get(n).map(|(x, _)| x) } - fn get_staking_issuance(n: u32) -> Option { + fn get_staking_issuance(n: u32) -> Option> { SessionIssuance::::get(n).map(|(_, x)| x) } } @@ -334,9 +335,9 @@ impl Pallet { ); ensure!(IsTGEFinalized::::get(), Error::::TGENotFinalized); - let issuance_config: IssuanceInfo = IssuanceInfo { + let issuance_config: IssuanceInfo> = IssuanceInfo { cap: T::IssuanceCap::get(), - issuance_at_init: T::Tokens::total_issuance(T::NativeCurrencyId::get().into()).into(), + issuance_at_init: T::Tokens::total_issuance(T::NativeCurrencyId::get().into()), linear_issuance_blocks: T::LinearIssuanceBlocks::get(), liquidity_mining_split: T::LiquidityMiningSplit::get(), staking_split: T::StakingSplit::get(), @@ -350,7 +351,7 @@ impl Pallet { Ok(().into()) } - pub fn build_issuance_config(issuance_config: IssuanceInfo) -> DispatchResult { + pub fn build_issuance_config(issuance_config: IssuanceInfo>) -> DispatchResult { ensure!( issuance_config .liquidity_mining_split @@ -363,7 +364,7 @@ impl Pallet { issuance_config.cap >= issuance_config .issuance_at_init - .checked_add(issuance_config.total_crowdloan_allocation) + .checked_add(&issuance_config.total_crowdloan_allocation) .ok_or(Error::::IssuanceConfigInvalid)?, Error::::IssuanceConfigInvalid ); @@ -383,29 +384,29 @@ impl Pallet { pub fn calculate_and_store_round_issuance(current_round: u32) -> DispatchResult { let issuance_config = IssuanceConfigStore::::get().ok_or(Error::::IssuanceConfigNotInitialized)?; - let to_be_issued: Balance = issuance_config + let to_be_issued: BalanceOf = issuance_config .cap - .checked_sub(issuance_config.issuance_at_init) + .checked_sub(&issuance_config.issuance_at_init) .ok_or(Error::::MathError)? - .checked_sub(issuance_config.total_crowdloan_allocation) + .checked_sub(&issuance_config.total_crowdloan_allocation) .ok_or(Error::::MathError)?; let linear_issuance_sessions: u32 = issuance_config .linear_issuance_blocks .checked_div(T::BlocksPerRound::get()) .ok_or(Error::::MathError)?; let linear_issuance_per_session = to_be_issued - .checked_div(linear_issuance_sessions as Balance) + .checked_div(&linear_issuance_sessions.into()) .ok_or(Error::::MathError)?; - let current_round_issuance: Balance; + let current_round_issuance: BalanceOf; // We do not want issuance to overshoot // Sessions begin from 0 and linear_issuance_sessions is the total number of linear sessions including 0 // So we stop before that if current_round < linear_issuance_sessions { current_round_issuance = linear_issuance_per_session; } else { - let current_mga_total_issuance: Balance = - T::Tokens::total_issuance(T::NativeCurrencyId::get().into()).into(); + let current_mga_total_issuance: BalanceOf = + T::Tokens::total_issuance(T::NativeCurrencyId::get().into()); if issuance_config.cap > current_mga_total_issuance { // TODO // Here we assume that the crowdloan ends before linear issuance period ends @@ -415,7 +416,7 @@ impl Pallet { current_round_issuance = linear_issuance_per_session.min( issuance_config .cap - .checked_sub(current_mga_total_issuance) + .checked_sub(¤t_mga_total_issuance) .ok_or(Error::::MathError)?, ) } else { @@ -434,17 +435,17 @@ impl Pallet { let liquidity_mining_issuance_issued = T::Tokens::deposit_creating( T::NativeCurrencyId::get().into(), &T::LiquidityMiningIssuanceVault::get(), - liquidity_mining_issuance.into(), + liquidity_mining_issuance, ); let staking_issuance_issued = T::Tokens::deposit_creating( T::NativeCurrencyId::get().into(), &T::StakingIssuanceVault::get(), - staking_issuance.into(), + staking_issuance, ); Self::deposit_event(Event::SessionIssuanceIssued( current_round, - liquidity_mining_issuance_issued.peek().into(), - staking_issuance_issued.peek().into(), + liquidity_mining_issuance_issued.peek(), + staking_issuance_issued.peek(), )); } diff --git a/pallets/issuance/src/mock.rs b/pallets/issuance/src/mock.rs index 5bb57443eb..6ff3c671dd 100644 --- a/pallets/issuance/src/mock.rs +++ b/pallets/issuance/src/mock.rs @@ -20,20 +20,23 @@ use super::*; use crate as pallet_issuance; use frame_support::{ assert_ok, construct_runtime, parameter_types, - traits::{Contains, Everything}, + traits::{Contains, Everything, WithdrawReasons}, PalletId, }; -use mangata_types::{Amount, Balance, TokenId}; use orml_traits::parameter_type_with_key; use sp_core::U256; use sp_runtime::{ traits::{AccountIdConversion, ConvertInto}, - SaturatedConversion, + BuildStorage, SaturatedConversion, }; use sp_std::convert::TryFrom; use std::{collections::HashMap, sync::Mutex}; + +pub(crate) type AccountId = u64; +pub(crate) type Amount = i128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; pub const MGA_TOKEN_ID: TokenId = 0; -pub(crate) type AccountId = u128; parameter_types!( pub const SomeConst: u64 = 10; @@ -43,15 +46,14 @@ parameter_types!( impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -132,7 +134,7 @@ lazy_static::lazy_static! { pub struct MockLiquidityMiningApi; -impl LiquidityMiningApi for MockLiquidityMiningApi { +impl LiquidityMiningApi for MockLiquidityMiningApi { fn distribute_rewards(_liquidity_mining_rewards: Balance) {} } @@ -159,6 +161,8 @@ impl pallet_issuance::Config for Test { parameter_types! { pub const MinVestedTransfer: Balance = 100u128; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting_mangata::Config for Test { @@ -167,37 +171,33 @@ impl pallet_vesting_mangata::Config for Test { type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting_mangata::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. // Should be atleast twice the number of tge recipients const MAX_VESTING_SCHEDULES: u32 = 200; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, - Issuance: pallet_issuance::{Pallet, Event, Storage}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + Vesting: pallet_vesting_mangata, + Issuance: pallet_issuance, } ); // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext_without_issuance_config() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .expect("Frame system builds valid default genesis config"); orml_tokens::GenesisConfig:: { - tokens_endowment: vec![(0u128, 0u32, 2_000_000_000)], + tokens_endowment: vec![(0u64, 0u32, 2_000_000_000)], created_tokens_for_staking: Default::default(), } .assimilate_storage(&mut t) @@ -217,12 +217,12 @@ pub fn new_test_ext_without_issuance_config() -> sp_io::TestExternalities { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .expect("Frame system builds valid default genesis config"); orml_tokens::GenesisConfig:: { - tokens_endowment: vec![(0u128, 0u32, 2_000_000_000)], + tokens_endowment: vec![(0u64, 0u32, 2_000_000_000)], created_tokens_for_staking: Default::default(), } .assimilate_storage(&mut t) @@ -260,7 +260,7 @@ pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option() / BlocksPerRound::get(); - session_issuance = ::get_all_issuance(session_number) + session_issuance = >::get_all_issuance(session_number) .expect("session issuance is always populated in advance"); block_issuance = (session_issuance.0 + session_issuance.1) / (BlocksPerRound::get().saturated_into::()); diff --git a/pallets/issuance/src/tests.rs b/pallets/issuance/src/tests.rs index 4780668f40..8fc807a82d 100644 --- a/pallets/issuance/src/tests.rs +++ b/pallets/issuance/src/tests.rs @@ -144,7 +144,7 @@ fn cannot_execute_tge_if_already_finalized() { fn linear_issuance_works() { new_test_ext().execute_with(|| { let session_number = System::block_number().saturated_into::() / BlocksPerRound::get(); - let session_issuance = ::get_all_issuance(session_number) + let session_issuance = >::get_all_issuance(session_number) .expect("session issuance is always populated in advance"); let block_issuance = (session_issuance.0 + session_issuance.1) / (BlocksPerRound::get().saturated_into::()); @@ -157,17 +157,17 @@ fn linear_issuance_works() { roll_to_while_minting(10000, Some(81008)); // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); roll_to_while_minting(22218, Some(81008)); - assert_eq!(3999997760, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3999997760, Tokens::total_issuance(0u32)); // This the point the next session's issuance will be calculated and minted // on the basis of total_issuance roll_to_while_minting(22219, Some(81008)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); }); } @@ -176,23 +176,23 @@ fn linear_issuance_doesnt_change_upon_burn() { new_test_ext().execute_with(|| { roll_to_while_minting(15000, Some(81008)); - orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u128, 100_000_000) + orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u64, 100_000_000) .unwrap(); - assert_eq!(3115525040, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3115525040, Tokens::total_issuance(0u32)); // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); roll_to_while_minting(22218, Some(81008)); - assert_eq!(3899997760, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3899997760, Tokens::total_issuance(0u32)); // This the point the next session's issuance will be calculated and minted // on the basis of total_issuance roll_to_while_minting(22219, Some(81008)); - assert_eq!(3900402800, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3900402800, Tokens::total_issuance(0u32)); }); } @@ -203,22 +203,22 @@ fn issuance_stops_upon_reaching_cap() { // on the basis of total_issuance // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); // At this point the entirety of the missing issuance will be allocated to the next session roll_to_while_minting(22219, Some(81008)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(22224, Some(448)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); // Now there is not enough missing issuance to issue so no more mga will be issued roll_to_while_minting(23000, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); }); } @@ -226,32 +226,32 @@ fn issuance_stops_upon_reaching_cap() { fn issuance_does_not_stop_upon_burn() { new_test_ext().execute_with(|| { // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); // This the point the next session's issuance will be calculated and minted // on the basis of total_issuance roll_to_while_minting(22219, Some(81008)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(22221, Some(448)); - orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u128, 100_000) + orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u64, 100_000) .unwrap(); // At this point the entirety of the missing issuance will be allocated to the next session roll_to_while_minting(22224, Some(448)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(22229, Some(20000)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(24001, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); }); } @@ -259,40 +259,40 @@ fn issuance_does_not_stop_upon_burn() { fn issuance_restarts_upon_burn() { new_test_ext().execute_with(|| { // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); // This the point the next session's issuance will be calculated and minted // on the basis of total_issuance roll_to_while_minting(22219, Some(81008)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); // At this point the entirety of the missing issuance will be allocated to the next session roll_to_while_minting(22224, Some(448)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); // Now there is not enough missing issuance to issue so no more mga will be issued roll_to_while_minting(23002, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); - orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u128, 100_000) + orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u64, 100_000) .unwrap(); - assert_eq!(3999900000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3999900000, Tokens::total_issuance(0u32)); roll_to_while_minting(23004, Some(0)); roll_to_while_minting(23009, Some(20000)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(24001, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); }); } @@ -300,50 +300,50 @@ fn issuance_restarts_upon_burn() { fn issuance_after_linear_period_never_execeeds_linear() { new_test_ext().execute_with(|| { // Mint for crowdloan - let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u128, 200_000_000u128); + let _ = orml_tokens::MultiTokenCurrencyAdapter::::mint(0u32, &1u64, 200_000_000u128); // This the point the next session's issuance will be calculated and minted // on the basis of total_issuance roll_to_while_minting(22219, Some(81008)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); // At this point the entirety of the missing issuance will be allocated to the next session roll_to_while_minting(22224, Some(448)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); // Now there is not enough missing issuance to issue so no more mga will be issued roll_to_while_minting(23002, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); - orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u128, 100_000) + orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u64, 100_000) .unwrap(); - assert_eq!(3999900000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3999900000, Tokens::total_issuance(0u32)); roll_to_while_minting(23004, Some(0)); roll_to_while_minting(23009, Some(20000)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); roll_to_while_minting(23023, Some(0)); - assert_eq!(4000000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(4000000000, Tokens::total_issuance(0u32)); - orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u128, 100_000_000) + orml_tokens::MultiTokenCurrencyAdapter::::burn_and_settle(0u32, &0u64, 100_000_000) .unwrap(); - assert_eq!(3900000000, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3900000000, Tokens::total_issuance(0u32)); roll_to_while_minting(23024, Some(0)); roll_to_while_minting(23051, Some(81008)); - assert_eq!(3902430240, Tokens::total_issuance(0u32) as Balance); + assert_eq!(3902430240, Tokens::total_issuance(0u32)); }); } diff --git a/pallets/maintenance/Cargo.toml b/pallets/maintenance/Cargo.toml index 144d03d3a5..9cbbe42189 100644 --- a/pallets/maintenance/Cargo.toml +++ b/pallets/maintenance/Cargo.toml @@ -1,56 +1,58 @@ [package] -authors = ['Mangata team'] -edition = '2018' -name = 'pallet-maintenance' -version = '0.1.0' +authors = ["Mangata team"] +edition = "2018" +name = "pallet-maintenance" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex = { package = "rustc-hex", version = "2.1.0", default-features = false } hex-literal = { version = "0.3.3", default-features = false } -serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +log = { version = "0.4.14", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +serde = { version = "1.0.126", optional = true } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = "5.0.0", default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" env_logger = "0.9.0" +lazy_static = "1.1.1" serial_test = { version = "0.6.0", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + + [features] -default = ['std'] +default = ["std"] enable-trading = [] std = [ - 'hex/std', - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - "sp-runtime/std", - 'frame-support/std', - 'frame-system/std', - "frame-benchmarking/std", - 'orml-tokens/std', + "codec/std", "frame-benchmarking/std", - "mangata-support/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "mangata-support/std", + "orml-tokens/std", + "serde", + "sp-std/std", + "sp-core/std", + "sp-runtime/std", ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] -try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "orml-tokens/try-runtime", "sp-runtime/try-runtime"] +try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime", "orml-tokens/try-runtime", "sp-runtime/try-runtime"] diff --git a/pallets/maintenance/src/lib.rs b/pallets/maintenance/src/lib.rs index 01ab349ff5..1f57ce18cb 100644 --- a/pallets/maintenance/src/lib.rs +++ b/pallets/maintenance/src/lib.rs @@ -42,7 +42,7 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks> for Pallet {} #[derive( Eq, PartialEq, RuntimeDebug, Clone, Encode, Decode, MaxEncodedLen, TypeInfo, Default, diff --git a/pallets/maintenance/src/mock.rs b/pallets/maintenance/src/mock.rs index 9f248fa478..f42e3872ab 100644 --- a/pallets/maintenance/src/mock.rs +++ b/pallets/maintenance/src/mock.rs @@ -1,71 +1,50 @@ // Copyright (C) 2020 Mangata team use super::*; -use sp_std::convert::TryFrom; - -use sp_core::H256; - -use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, -}; - use crate as pallet_maintenance; -use frame_support::{ - construct_runtime, parameter_types, - traits::{ConstU32, Contains, Everything}, - PalletId, -}; +use frame_support::{construct_runtime, parameter_types, traits::Everything}; use frame_system as system; -use mangata_types::Amount; -use orml_traits::parameter_type_with_key; - -pub const NATIVE_CURRENCY_ID: u32 = 0; +use sp_runtime::BuildStorage; +use sp_std::convert::TryFrom; pub(crate) type AccountId = u128; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Maintenance: pallet_maintenance::{Pallet, Storage, Call, Event}, + pub enum Test { + System: frame_system, + Maintenance: pallet_maintenance, } ); parameter_types! { pub const BlockHashCount: u64 = 250; } -impl system::Config for Test { +impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); type DbWeight = (); type Version = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type PalletInfo = PalletInfo; - type BlockWeights = (); - type BlockLength = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } pub struct FoundationAccountsProvider(PhantomData); @@ -87,5 +66,5 @@ impl pallet_maintenance::Config for Test { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/pallets/maintenance/src/tests.rs b/pallets/maintenance/src/tests.rs index efde3cf382..4dcb5748a3 100644 --- a/pallets/maintenance/src/tests.rs +++ b/pallets/maintenance/src/tests.rs @@ -1,10 +1,6 @@ use super::*; use crate::mock::*; use frame_support::{assert_noop, assert_ok, error::BadOrigin}; -use sp_std::convert::TryFrom; - -use orml_tokens::AccountData; -use sp_std::collections::btree_map::BTreeMap; #[test] fn switching_maintenance_mode_on_works() { diff --git a/pallets/multipurpose-liquidity/Cargo.toml b/pallets/multipurpose-liquidity/Cargo.toml index 50ab58aedb..7f14e2ced1 100644 --- a/pallets/multipurpose-liquidity/Cargo.toml +++ b/pallets/multipurpose-liquidity/Cargo.toml @@ -1,71 +1,74 @@ [package] -authors = ['Mangata team'] -edition = '2018' -name = 'pallet-multipurpose-liquidity' -version = '0.1.0' +authors = ["Mangata team"] +edition = "2018" +name = "pallet-multipurpose-liquidity" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex = { package = "rustc-hex", version = "2.1.0", default-features = false } hex-literal = { version = "0.3.3", default-features = false } +log = { version = "0.4.14", default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = "5.0.0", default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +parachain-staking = { path = "../parachain-staking", default-features = false } + +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -parachain-staking = { default-features = false, git = "https://github.com/mangata-finance/moonbeam.git", branch = "mangata-dev" } [dev-dependencies] -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" env_logger = "0.9.0" +lazy_static = "1.1.1" serial_test = { version = "0.6.0", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + [features] -default = ['std'] +default = ["std"] enable-trading = [] std = [ - 'hex/std', - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - "sp-runtime/std", - 'frame-support/std', - 'frame-system/std', + "codec/std", + "hex/std", "frame-benchmarking/std", - 'orml-tokens/std', - "frame-benchmarking/std", - 'pallet-vesting-mangata/std', - "mangata-support/std", - "parachain-staking/std", + "frame-support/std", + "frame-system/std", + "mangata-support/std", + "orml-tokens/std", + "pallet-vesting-mangata/std", + "parachain-staking/std", + "serde", + "sp-std/std", + "sp-core/std", + "sp-runtime/std", ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks", "parachain-staking/runtime-benchmarks"] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "orml-tokens/try-runtime", "pallet-vesting-mangata/try-runtime", "parachain-staking/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/multipurpose-liquidity/src/benchmarking.rs b/pallets/multipurpose-liquidity/src/benchmarking.rs index e697557f0e..076b7a3f80 100644 --- a/pallets/multipurpose-liquidity/src/benchmarking.rs +++ b/pallets/multipurpose-liquidity/src/benchmarking.rs @@ -32,78 +32,78 @@ benchmarks! { reserve_vesting_liquidity_tokens{ let caller: T::AccountId = whitelisted_caller(); - let initial_amount: Balance = 2_000_000__u128; - let asset_id_1: TokenId = ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); - let asset_id_2: TokenId = ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); - let asset_id: TokenId = asset_id_2 + 1; + let initial_amount: BalanceOf = 2_000_000__u32.into(); + let asset_id_1 = ::Tokens::create(&caller, initial_amount).unwrap(); + let asset_id_2 = ::Tokens::create(&caller, initial_amount).unwrap(); + let asset_id = asset_id_2 + 1_u32.into(); - ::Xyk::create_pool(caller.clone(), asset_id_1.into(), initial_amount.into(), asset_id_2.into(), initial_amount.into()).unwrap(); + ::Xyk::create_pool(caller.clone(), asset_id_1, initial_amount, asset_id_2, initial_amount).unwrap(); - let locked_amount: Balance = 500_000__u128; - let lock_ending_block_as_balance: Balance = 1_000__u128; + let locked_amount: BalanceOf = 500_000__u32.into(); + let lock_ending_block_as_balance: BalanceOf = 1_000__u32.into(); - let reserve_amount: Balance = 200_000__u128; + let reserve_amount: BalanceOf = 200_000__u32.into(); // Assuming max locks is 50 // Let's add 49 dummy ones for worst case let n = 49; - let dummy_lock_amount = 1000u128; - let dummy_end_block = 10_u128; + let dummy_lock_amount: BalanceOf = 1000u32.into(); + let dummy_end_block: BalanceOf = 10_u32.into(); for _ in 0..n{ - ::VestingProvider::lock_tokens(&caller, asset_id.into(), dummy_lock_amount.into(), None, dummy_end_block.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, asset_id, dummy_lock_amount, None, dummy_end_block).unwrap(); } - ::VestingProvider::lock_tokens(&caller, asset_id.into(), locked_amount.into(), None, lock_ending_block_as_balance.into()).unwrap(); - let now: BlockNumber = >::block_number().saturated_into(); + ::VestingProvider::lock_tokens(&caller, asset_id, locked_amount, None, lock_ending_block_as_balance).unwrap(); + let now: BlockNumberFor = >::block_number(); }: {assert_ok!(MultiPurposeLiquidity::::reserve_vesting_liquidity_tokens(RawOrigin::Signed(caller.clone().into()).into(), asset_id, reserve_amount));} verify{ - assert_eq!(::Tokens::locked_balance(asset_id.into(), &caller).into(), 343600); - assert_eq!(::Tokens::reserved_balance(asset_id.into(), &caller).into(), 200000); + assert_eq!(::Tokens::locked_balance(asset_id, &caller), 343600_u32.into()); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller), 200000_u32.into()); assert_eq!(MultiPurposeLiquidity::::get_reserve_status(caller.clone(), asset_id).relock_amount, reserve_amount); - assert_eq!(MultiPurposeLiquidity::::get_relock_status(caller, asset_id)[0], RelockStatusInfo{amount: reserve_amount, starting_block: now + 1, ending_block_as_balance: lock_ending_block_as_balance}); + assert_eq!(MultiPurposeLiquidity::::get_relock_status(caller, asset_id)[0], RelockStatusInfo{amount: reserve_amount, starting_block: now + 1_u32.into(), ending_block_as_balance: lock_ending_block_as_balance}); } unreserve_and_relock_instance{ let caller: T::AccountId = whitelisted_caller(); - let initial_amount: Balance = 2_000_000__u128; - let asset_id_1: TokenId = ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); - let asset_id_2: TokenId = ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); - let asset_id: TokenId = asset_id_2 + 1; + let initial_amount: BalanceOf = 2_000_000__u32.into(); + let asset_id_1 = ::Tokens::create(&caller, initial_amount).unwrap(); + let asset_id_2 = ::Tokens::create(&caller, initial_amount).unwrap(); + let asset_id = asset_id_2 + 1_u32.into(); - ::Xyk::create_pool(caller.clone(), asset_id_1.into(), initial_amount.into(), asset_id_2.into(), initial_amount.into()).unwrap(); + ::Xyk::create_pool(caller.clone(), asset_id_1, initial_amount, asset_id_2, initial_amount).unwrap(); - let locked_amount: Balance = 500_000__u128; - let lock_ending_block_as_balance: Balance = 1_000__u128; + let locked_amount: BalanceOf = 500_000__u32.into(); + let lock_ending_block_as_balance: BalanceOf = 1_000__u32.into(); - let reserve_amount: Balance = 200_000__u128; + let reserve_amount: BalanceOf = 200_000__u32.into(); // Assuming max locks is 50 // Let's add 48 dummy ones for worst case let n = 48; - let dummy_lock_amount = 1000u128; - let dummy_end_block = 10_u128; + let dummy_lock_amount: BalanceOf = 1000u32.into(); + let dummy_end_block: BalanceOf = 10_u32.into(); for _ in 0..n{ - ::VestingProvider::lock_tokens(&caller, asset_id.into(), dummy_lock_amount.into(), None, dummy_end_block.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, asset_id, dummy_lock_amount, None, dummy_end_block).unwrap(); } - ::VestingProvider::lock_tokens(&caller, asset_id.into(), locked_amount.into(), None, lock_ending_block_as_balance.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, asset_id, locked_amount, None, lock_ending_block_as_balance).unwrap(); - let now: BlockNumber = >::block_number().saturated_into(); + let now: BlockNumberFor = >::block_number(); MultiPurposeLiquidity::::reserve_vesting_liquidity_tokens(RawOrigin::Signed(caller.clone().into()).into(), asset_id, reserve_amount).unwrap(); - assert_eq!(::Tokens::locked_balance(asset_id.into(), &caller).into(), 348000); - assert_eq!(::Tokens::reserved_balance(asset_id.into(), &caller).into(), 200000); + assert_eq!(::Tokens::locked_balance(asset_id, &caller), 348000_u32.into()); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller), 200000_u32.into()); assert_eq!(MultiPurposeLiquidity::::get_reserve_status(caller.clone(), asset_id).relock_amount, reserve_amount); assert_eq!(MultiPurposeLiquidity::::get_relock_status(caller.clone(), asset_id)[0], RelockStatusInfo{amount: reserve_amount, starting_block: now, ending_block_as_balance: lock_ending_block_as_balance}); }: {assert_ok!(MultiPurposeLiquidity::::unreserve_and_relock_instance(RawOrigin::Signed(caller.clone().into()).into(), asset_id, 0u32));} verify{ - assert_eq!(::Tokens::locked_balance(asset_id.into(), &caller).into(), 542700); - assert_eq!(::Tokens::reserved_balance(asset_id.into(), &caller).into(), 0); - assert_eq!(MultiPurposeLiquidity::::get_reserve_status(caller.clone(), asset_id).relock_amount, Balance::zero()); + assert_eq!(::Tokens::locked_balance(asset_id, &caller), 542700_u32.into()); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller), 0_u32.into()); + assert_eq!(MultiPurposeLiquidity::::get_reserve_status(caller.clone(), asset_id).relock_amount, 0_u32.into()); assert_eq!(MultiPurposeLiquidity::::get_relock_status(caller, asset_id), vec![]); } diff --git a/pallets/multipurpose-liquidity/src/lib.rs b/pallets/multipurpose-liquidity/src/lib.rs index 33859d91bd..79ed1c12de 100644 --- a/pallets/multipurpose-liquidity/src/lib.rs +++ b/pallets/multipurpose-liquidity/src/lib.rs @@ -4,20 +4,19 @@ use frame_support::{ dispatch::DispatchResult, ensure, pallet_prelude::*, - traits::{tokens::currency::MultiTokenCurrency, Get, StorageVersion, WithdrawReasons}, + traits::{ + tokens::currency::{MultiTokenCurrency, MultiTokenVestingLocks}, + Get, StorageVersion, WithdrawReasons, + }, transactional, }; use frame_system::{ensure_signed, pallet_prelude::*}; use mangata_support::traits::{ ActivationReservesProviderTrait, StakingReservesProviderTrait, XykFunctionsTrait, }; -use mangata_types::{ - multipurpose_liquidity::{ActivateKind, BondKind}, - Balance, BlockNumber, TokenId, -}; +use mangata_types::multipurpose_liquidity::{ActivateKind, BondKind}; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; -use pallet_vesting_mangata::MultiTokenVestingLocks; -use sp_runtime::traits::{SaturatedConversion, Zero}; +use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Saturating, Zero}; use sp_std::{convert::TryInto, prelude::*}; #[cfg(feature = "std")] @@ -48,6 +47,13 @@ macro_rules! log { pub use pallet::*; +type BalanceOf = + <::Tokens as MultiTokenCurrency<::AccountId>>::Balance; + +type CurrencyIdOf = <::Tokens as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + #[frame_support::pallet] pub mod pallet { @@ -60,7 +66,7 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks> for Pallet {} #[pallet::config] pub trait Config: frame_system::Config { @@ -68,9 +74,13 @@ pub mod pallet { type MaxRelocks: Get; type Tokens: MultiTokenCurrencyExtended + MultiTokenReservableCurrency; - type NativeCurrencyId: Get; - type VestingProvider: MultiTokenVestingLocks; - type Xyk: XykFunctionsTrait; + type NativeCurrencyId: Get>; + type VestingProvider: MultiTokenVestingLocks< + Self::AccountId, + Currency = Self::Tokens, + Moment = BlockNumberFor, + >; + type Xyk: XykFunctionsTrait, CurrencyIdOf>; type WeightInfo: WeightInfo; } @@ -94,15 +104,15 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - VestingTokensReserved(T::AccountId, TokenId, Balance), - TokensRelockedFromReserve(T::AccountId, TokenId, Balance, Balance), + VestingTokensReserved(T::AccountId, CurrencyIdOf, BalanceOf), + TokensRelockedFromReserve(T::AccountId, CurrencyIdOf, BalanceOf, BalanceOf), } #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive( Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, Default, )] - pub struct ReserveStatusInfo { + pub struct ReserveStatusInfo { pub staked_unactivated_reserves: Balance, pub activated_unstaked_reserves: Balance, pub staked_and_activated_reserves: Balance, @@ -114,7 +124,7 @@ pub mod pallet { #[derive( Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, Default, )] - pub struct RelockStatusInfo { + pub struct RelockStatusInfo { pub amount: Balance, pub starting_block: BlockNumber, pub ending_block_as_balance: Balance, @@ -127,8 +137,8 @@ pub mod pallet { Blake2_256, T::AccountId, Twox64Concat, - TokenId, - ReserveStatusInfo, + CurrencyIdOf, + ReserveStatusInfo>, ValueQuery, >; @@ -139,8 +149,8 @@ pub mod pallet { Blake2_256, T::AccountId, Twox64Concat, - TokenId, - BoundedVec, + CurrencyIdOf, + BoundedVec, BlockNumberFor>, T::MaxRelocks>, ValueQuery, >; @@ -155,9 +165,9 @@ pub mod pallet { /// Vested pallet tokens can be unlocked. pub fn reserve_vesting_liquidity_tokens_by_vesting_index( origin: OriginFor, - liquidity_token_id: TokenId, + liquidity_token_id: CurrencyIdOf, liquidity_token_vesting_index: u32, - liquidity_token_unlock_some_amount_or_all: Option, + liquidity_token_unlock_some_amount_or_all: Option>, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -179,7 +189,7 @@ pub mod pallet { pub fn reserve_vesting_native_tokens_by_vesting_index( origin: OriginFor, liquidity_token_vesting_index: u32, - liquidity_token_unlock_some_amount_or_all: Option, + liquidity_token_unlock_some_amount_or_all: Option>, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -197,30 +207,28 @@ pub mod pallet { // This extrinsic has to be transactional pub fn reserve_vesting_liquidity_tokens( origin: OriginFor, - liquidity_token_id: TokenId, - liquidity_token_amount: Balance, + liquidity_token_id: CurrencyIdOf, + liquidity_token_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; ensure!(T::Xyk::is_liquidity_token(liquidity_token_id), Error::::NotALiquidityToken); - let (vesting_starting_block, vesting_ending_block_as_balance): (BlockNumber, Balance) = - T::VestingProvider::unlock_tokens( - &sender, - liquidity_token_id.into(), - liquidity_token_amount.into(), - ) - .map(|x| (x.0.saturated_into(), x.1.into()))?; + let (vesting_starting_block, vesting_ending_block_as_balance): ( + BlockNumberFor, + BalanceOf, + ) = T::VestingProvider::unlock_tokens(&sender, liquidity_token_id, liquidity_token_amount) + .map(|x| (x.0, x.1))?; let mut reserve_status = Pallet::::get_reserve_status(&sender, liquidity_token_id); reserve_status.relock_amount = reserve_status .relock_amount - .checked_add(liquidity_token_amount) + .checked_add(&liquidity_token_amount) .ok_or(Error::::MathError)?; reserve_status.unspent_reserves = reserve_status .unspent_reserves - .checked_add(liquidity_token_amount) + .checked_add(&liquidity_token_amount) .ok_or(Error::::MathError)?; ReserveStatus::::insert(&sender, liquidity_token_id, reserve_status); @@ -236,7 +244,7 @@ pub mod pallet { ) .map_err(|_| Error::::RelockCountLimitExceeded)?; - T::Tokens::reserve(liquidity_token_id.into(), &sender, liquidity_token_amount.into())?; + T::Tokens::reserve(liquidity_token_id.into(), &sender, liquidity_token_amount)?; Pallet::::deposit_event(Event::VestingTokensReserved( sender, @@ -253,50 +261,53 @@ pub mod pallet { // This extrinsic has to be transactional pub fn unreserve_and_relock_instance( origin: OriginFor, - liquidity_token_id: TokenId, + liquidity_token_id: CurrencyIdOf, relock_instance_index: u32, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - let relock_instances: Vec = + let relock_instances: Vec, BlockNumberFor>> = Self::get_relock_status(&sender, liquidity_token_id).into(); - let selected_relock_instance: RelockStatusInfo = relock_instances - .get(relock_instance_index as usize) - .ok_or(Error::::RelockInstanceIndexOOB)? - .clone(); - - let updated_relock_instances: BoundedVec = + let selected_relock_instance: RelockStatusInfo, BlockNumberFor> = relock_instances - .into_iter() - .enumerate() - .filter_map(move |(index, relock_instance)| { - if index == relock_instance_index as usize { - None - } else { - Some(relock_instance) - } - }) - .collect::>() - .try_into() - .map_err(|_| Error::::RelockCountLimitExceeded)?; + .get(relock_instance_index as usize) + .ok_or(Error::::RelockInstanceIndexOOB)? + .clone(); + + let updated_relock_instances: BoundedVec< + RelockStatusInfo, BlockNumberFor>, + T::MaxRelocks, + > = relock_instances + .into_iter() + .enumerate() + .filter_map(move |(index, relock_instance)| { + if index == relock_instance_index as usize { + None + } else { + Some(relock_instance) + } + }) + .collect::>() + .try_into() + .map_err(|_| Error::::RelockCountLimitExceeded)?; let mut reserve_status = Pallet::::get_reserve_status(&sender, liquidity_token_id); reserve_status.relock_amount = reserve_status .relock_amount - .checked_sub(selected_relock_instance.amount) + .checked_sub(&selected_relock_instance.amount) .ok_or(Error::::MathError)?; reserve_status.unspent_reserves = reserve_status .unspent_reserves - .checked_sub(selected_relock_instance.amount) + .checked_sub(&selected_relock_instance.amount) .ok_or(Error::::NotEnoughUnspentReserves)?; ensure!( T::Tokens::unreserve( liquidity_token_id.into(), &sender, - selected_relock_instance.amount.into() + selected_relock_instance.amount ) .is_zero(), Error::::MathError @@ -305,9 +316,9 @@ pub mod pallet { T::VestingProvider::lock_tokens( &sender, liquidity_token_id.into(), - selected_relock_instance.amount.into(), + selected_relock_instance.amount, Some(selected_relock_instance.starting_block.into()), - selected_relock_instance.ending_block_as_balance.into(), + selected_relock_instance.ending_block_as_balance, )?; ReserveStatus::::insert(&sender, liquidity_token_id, reserve_status); @@ -326,13 +337,13 @@ pub mod pallet { } } -impl StakingReservesProviderTrait for Pallet { - type AccountId = T::AccountId; - +impl StakingReservesProviderTrait, CurrencyIdOf> + for Pallet +{ fn can_bond( - token_id: TokenId, - account_id: &Self::AccountId, - amount: Balance, + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, use_balance_from: Option, ) -> bool { let reserve_status = Pallet::::get_reserve_status(account_id, token_id); @@ -344,24 +355,27 @@ impl StakingReservesProviderTrait for Pallet { T::Tokens::ensure_can_withdraw( token_id.into(), &account_id, - amount.into(), + amount, WithdrawReasons::all(), Default::default(), ) - .is_ok() && reserve_status.staked_unactivated_reserves.checked_add(amount).is_some(), + .is_ok() && reserve_status + .staked_unactivated_reserves + .checked_add(&amount) + .is_some(), BondKind::ActivatedUnstakedReserves => - reserve_status.activated_unstaked_reserves.checked_sub(amount).is_some() && - reserve_status.staked_and_activated_reserves.checked_add(amount).is_some(), + reserve_status.activated_unstaked_reserves.checked_sub(&amount).is_some() && + reserve_status.staked_and_activated_reserves.checked_add(&amount).is_some(), BondKind::UnspentReserves => - reserve_status.unspent_reserves.checked_sub(amount).is_some() && - reserve_status.staked_unactivated_reserves.checked_add(amount).is_some(), + reserve_status.unspent_reserves.checked_sub(&amount).is_some() && + reserve_status.staked_unactivated_reserves.checked_add(&amount).is_some(), } } fn bond( - token_id: TokenId, - account_id: &Self::AccountId, - amount: Balance, + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, use_balance_from: Option, ) -> DispatchResult { let mut reserve_status = Pallet::::get_reserve_status(account_id, token_id); @@ -372,28 +386,28 @@ impl StakingReservesProviderTrait for Pallet { BondKind::AvailableBalance => { reserve_status.staked_unactivated_reserves = reserve_status .staked_unactivated_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; - T::Tokens::reserve(token_id.into(), &account_id, amount.into())?; + T::Tokens::reserve(token_id.into(), &account_id, amount)?; }, BondKind::ActivatedUnstakedReserves => { reserve_status.activated_unstaked_reserves = reserve_status .activated_unstaked_reserves - .checked_sub(amount) + .checked_sub(&amount) .ok_or(Error::::NotEnoughTokens)?; reserve_status.staked_and_activated_reserves = reserve_status .staked_and_activated_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; }, BondKind::UnspentReserves => { reserve_status.unspent_reserves = reserve_status .unspent_reserves - .checked_sub(amount) + .checked_sub(&amount) .ok_or(Error::::NotEnoughTokens)?; reserve_status.staked_unactivated_reserves = reserve_status .staked_unactivated_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; }, } @@ -402,23 +416,26 @@ impl StakingReservesProviderTrait for Pallet { Ok(()) } - fn unbond(token_id: TokenId, account_id: &Self::AccountId, amount: Balance) -> Balance { + fn unbond( + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, + ) -> BalanceOf { // From staked_unactivated_reserves goes to either free balance or unspent reserves depending on relock_amount // From staked_and_activated_reserves goes to activated always. let mut reserve_status = Pallet::::get_reserve_status(account_id, token_id); let mut working_amount = amount; - let mut unreserve_amount = Balance::zero(); + let mut unreserve_amount = working_amount.min(reserve_status.staked_unactivated_reserves); - unreserve_amount = working_amount.min(reserve_status.staked_unactivated_reserves); working_amount = working_amount.saturating_sub(unreserve_amount); reserve_status.staked_unactivated_reserves = reserve_status.staked_unactivated_reserves.saturating_sub(unreserve_amount); let mut move_reserve = working_amount.min(reserve_status.staked_and_activated_reserves); // This is just to prevent overflow. - move_reserve = Balance::max_value() + move_reserve = BalanceOf::::max_value() .saturating_sub(reserve_status.activated_unstaked_reserves) .min(move_reserve); reserve_status.staked_and_activated_reserves = @@ -448,8 +465,8 @@ impl StakingReservesProviderTrait for Pallet { reserve_status.unspent_reserves = reserve_status.unspent_reserves.saturating_add(add_to_unspent); - let unreserve_result: Balance = - T::Tokens::unreserve(token_id.into(), account_id, unreserve_amount.into()).into(); + let unreserve_result: BalanceOf = + T::Tokens::unreserve(token_id.into(), account_id, unreserve_amount); if !unreserve_result.is_zero() { log::warn!("Unbond resulted in non-zero unreserve_result {:?}", unreserve_result); @@ -464,13 +481,13 @@ impl StakingReservesProviderTrait for Pallet { } } -impl ActivationReservesProviderTrait for Pallet { - type AccountId = T::AccountId; - +impl ActivationReservesProviderTrait, CurrencyIdOf> + for Pallet +{ fn get_max_instant_unreserve_amount( - token_id: TokenId, - account_id: &Self::AccountId, - ) -> Balance { + token_id: CurrencyIdOf, + account_id: &T::AccountId, + ) -> BalanceOf { let reserve_status = Pallet::::get_reserve_status(account_id, token_id); let total_remaining_reserve = reserve_status @@ -488,9 +505,9 @@ impl ActivationReservesProviderTrait for Pallet { } fn can_activate( - token_id: TokenId, - account_id: &Self::AccountId, - amount: Balance, + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, use_balance_from: Option, ) -> bool { let reserve_status = Pallet::::get_reserve_status(account_id, token_id); @@ -502,24 +519,27 @@ impl ActivationReservesProviderTrait for Pallet { T::Tokens::ensure_can_withdraw( token_id.into(), &account_id, - amount.into(), + amount, WithdrawReasons::all(), Default::default(), ) - .is_ok() && reserve_status.activated_unstaked_reserves.checked_add(amount).is_some(), + .is_ok() && reserve_status + .activated_unstaked_reserves + .checked_add(&amount) + .is_some(), ActivateKind::StakedUnactivatedReserves => - reserve_status.staked_unactivated_reserves.checked_sub(amount).is_some() && - reserve_status.staked_and_activated_reserves.checked_add(amount).is_some(), + reserve_status.staked_unactivated_reserves.checked_sub(&amount).is_some() && + reserve_status.staked_and_activated_reserves.checked_add(&amount).is_some(), ActivateKind::UnspentReserves => - reserve_status.unspent_reserves.checked_sub(amount).is_some() && - reserve_status.activated_unstaked_reserves.checked_add(amount).is_some(), + reserve_status.unspent_reserves.checked_sub(&amount).is_some() && + reserve_status.activated_unstaked_reserves.checked_add(&amount).is_some(), } } fn activate( - token_id: TokenId, - account_id: &Self::AccountId, - amount: Balance, + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, use_balance_from: Option, ) -> DispatchResult { let mut reserve_status = Pallet::::get_reserve_status(account_id, token_id); @@ -530,28 +550,28 @@ impl ActivationReservesProviderTrait for Pallet { ActivateKind::AvailableBalance => { reserve_status.activated_unstaked_reserves = reserve_status .activated_unstaked_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; - T::Tokens::reserve(token_id.into(), &account_id, amount.into())?; + T::Tokens::reserve(token_id.into(), &account_id, amount)?; }, ActivateKind::StakedUnactivatedReserves => { reserve_status.staked_unactivated_reserves = reserve_status .staked_unactivated_reserves - .checked_sub(amount) + .checked_sub(&amount) .ok_or(Error::::NotEnoughTokens)?; reserve_status.staked_and_activated_reserves = reserve_status .staked_and_activated_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; }, ActivateKind::UnspentReserves => { reserve_status.unspent_reserves = reserve_status .unspent_reserves - .checked_sub(amount) + .checked_sub(&amount) .ok_or(Error::::NotEnoughTokens)?; reserve_status.activated_unstaked_reserves = reserve_status .activated_unstaked_reserves - .checked_add(amount) + .checked_add(&amount) .ok_or(Error::::MathError)?; }, } @@ -560,22 +580,25 @@ impl ActivationReservesProviderTrait for Pallet { Ok(()) } - fn deactivate(token_id: TokenId, account_id: &Self::AccountId, amount: Balance) -> Balance { + fn deactivate( + token_id: CurrencyIdOf, + account_id: &T::AccountId, + amount: BalanceOf, + ) -> BalanceOf { // From ActivatedUnstakedReserves goes to either free balance or unspent reserves depending on relock_amount // From staked_and_activated_reserves goes to staked always. let mut reserve_status = Pallet::::get_reserve_status(account_id, token_id); let mut working_amount = amount; - let mut unreserve_amount = Balance::zero(); + let mut unreserve_amount = working_amount.min(reserve_status.activated_unstaked_reserves); - unreserve_amount = working_amount.min(reserve_status.activated_unstaked_reserves); working_amount = working_amount.saturating_sub(unreserve_amount); reserve_status.activated_unstaked_reserves = reserve_status.activated_unstaked_reserves.saturating_sub(unreserve_amount); let mut move_reserve = working_amount.min(reserve_status.staked_and_activated_reserves); // This is just to prevent overflow. - move_reserve = Balance::max_value() + move_reserve = BalanceOf::::max_value() .saturating_sub(reserve_status.staked_unactivated_reserves) .min(move_reserve); reserve_status.staked_and_activated_reserves = @@ -605,8 +628,8 @@ impl ActivationReservesProviderTrait for Pallet { reserve_status.unspent_reserves = reserve_status.unspent_reserves.saturating_add(add_to_unspent); - let unreserve_result: Balance = - T::Tokens::unreserve(token_id.into(), account_id, unreserve_amount.into()).into(); + let unreserve_result: BalanceOf = + T::Tokens::unreserve(token_id.into(), account_id, unreserve_amount); if !unreserve_result.is_zero() { log::warn!("Unbond resulted in non-zero unreserve_result {:?}", unreserve_result); @@ -624,31 +647,31 @@ impl ActivationReservesProviderTrait for Pallet { impl Pallet { fn do_reserve_tokens_by_vesting_index( account: T::AccountId, - liquidity_token_id: TokenId, + liquidity_token_id: CurrencyIdOf, liquidity_token_vesting_index: u32, - liquidity_token_unlock_some_amount_or_all: Option, + liquidity_token_unlock_some_amount_or_all: Option>, ) -> DispatchResultWithPostInfo { let (unlocked_amount, vesting_starting_block, vesting_ending_block_as_balance): ( - Balance, - BlockNumber, - Balance, + BalanceOf, + BlockNumberFor, + BalanceOf, ) = T::VestingProvider::unlock_tokens_by_vesting_index( &account, - liquidity_token_id.into(), + liquidity_token_id, liquidity_token_vesting_index, - liquidity_token_unlock_some_amount_or_all.map(Into::into), + liquidity_token_unlock_some_amount_or_all, ) - .map(|x| (x.0.into(), x.1.saturated_into(), x.2.into()))?; + .map(|x| (x.0, x.1, x.2))?; let mut reserve_status = Pallet::::get_reserve_status(&account, liquidity_token_id); reserve_status.relock_amount = reserve_status .relock_amount - .checked_add(unlocked_amount) + .checked_add(&unlocked_amount) .ok_or(Error::::MathError)?; reserve_status.unspent_reserves = reserve_status .unspent_reserves - .checked_add(unlocked_amount) + .checked_add(&unlocked_amount) .ok_or(Error::::MathError)?; ReserveStatus::::insert(&account, liquidity_token_id, reserve_status); @@ -664,7 +687,7 @@ impl Pallet { ) .map_err(|_| Error::::RelockCountLimitExceeded)?; - T::Tokens::reserve(liquidity_token_id.into(), &account, unlocked_amount.into())?; + T::Tokens::reserve(liquidity_token_id.into(), &account, unlocked_amount)?; Pallet::::deposit_event(Event::VestingTokensReserved( account, diff --git a/pallets/multipurpose-liquidity/src/mock.rs b/pallets/multipurpose-liquidity/src/mock.rs index 51ad6c907b..5d1b3064ab 100644 --- a/pallets/multipurpose-liquidity/src/mock.rs +++ b/pallets/multipurpose-liquidity/src/mock.rs @@ -2,74 +2,63 @@ use super::*; -use sp_core::H256; -use sp_std::convert::TryFrom; - -use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, - Permill, -}; - use crate as pallet_multipurpose_liquidity; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU32, Contains, Everything}, + traits::{Contains, Everything}, PalletId, }; use frame_system as system; -use mangata_types::{Amount, Balance, TokenId}; use orml_tokens::MultiTokenCurrencyAdapter; use orml_traits::parameter_type_with_key; +use sp_runtime::{traits::AccountIdConversion, BuildStorage, Permill}; +use sp_std::convert::TryFrom; pub const NATIVE_CURRENCY_ID: u32 = 0; -pub(crate) type AccountId = u128; +pub(crate) type AccountId = u64; +pub(crate) type Amount = i128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, - MultiPurposeLiquidity: pallet_multipurpose_liquidity::{Pallet, Call, Storage, Event}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + Vesting: pallet_vesting_mangata, + MultiPurposeLiquidity: pallet_multipurpose_liquidity, } ); parameter_types! { pub const BlockHashCount: u64 = 250; } -impl system::Config for Test { +impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); type DbWeight = (); type Version = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type PalletInfo = PalletInfo; - type BlockWeights = (); - type BlockLength = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } parameter_type_with_key! { @@ -114,6 +103,8 @@ parameter_types! { parameter_types! { pub const MinVestedTransfer: Balance = 0; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting_mangata::Config for Test { @@ -122,6 +113,7 @@ impl pallet_vesting_mangata::Config for Test { type BlockNumberToBalance = sp_runtime::traits::ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting_mangata::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 50; @@ -138,128 +130,124 @@ impl Config for Test { } pub struct MockXyk(PhantomData); -impl XykFunctionsTrait for MockXyk { - type Balance = Balance; - - type CurrencyId = TokenId; - +impl XykFunctionsTrait for MockXyk { fn create_pool( - sender: T::AccountId, - first_asset_id: Self::CurrencyId, - first_asset_amount: Self::Balance, - second_asset_id: Self::CurrencyId, - second_asset_amount: Self::Balance, + _sender: AccountId, + _first_asset_id: TokenId, + _first_asset_amount: Balance, + _second_asset_id: TokenId, + _second_asset_amount: Balance, ) -> DispatchResult { unimplemented!() } fn sell_asset( - sender: T::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, - err_upon_bad_slippage: bool, - ) -> Result { + _sender: AccountId, + _sold_asset_id: TokenId, + _bought_asset_id: TokenId, + _sold_asset_amount: Balance, + _min_amount_out: Balance, + _err_upon_bad_slippage: bool, + ) -> Result { unimplemented!() } fn do_multiswap_sell_asset( - sender: T::AccountId, - swap_token_list: Vec, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, - ) -> Result { + _sender: AccountId, + _swap_token_list: Vec, + _sold_asset_amount: Balance, + _min_amount_out: Balance, + ) -> Result { unimplemented!() } fn do_multiswap_buy_asset( - sender: T::AccountId, - swap_token_list: Vec, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, - ) -> Result { + _sender: AccountId, + _swap_token_list: Vec, + _bought_asset_amount: Balance, + _max_amount_in: Balance, + ) -> Result { unimplemented!() } fn buy_asset( - sender: T::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, - err_upon_bad_slippage: bool, - ) -> Result { + _sender: AccountId, + _sold_asset_id: TokenId, + _bought_asset_id: TokenId, + _bought_asset_amount: Balance, + _max_amount_in: Balance, + _err_upon_bad_slippage: bool, + ) -> Result { unimplemented!() } fn multiswap_sell_asset( - sender: T::AccountId, - swap_token_list: Vec, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, - err_upon_bad_slippage: bool, - err_upon_non_slippage_fail: bool, - ) -> Result { + _sender: AccountId, + _swap_token_list: Vec, + _sold_asset_amount: Balance, + _min_amount_out: Balance, + _err_upon_bad_slippage: bool, + _err_upon_non_slippage_fail: bool, + ) -> Result { unimplemented!() } fn multiswap_buy_asset( - sender: T::AccountId, - swap_token_list: Vec, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, - err_upon_bad_slippage: bool, - err_upon_non_slippage_fail: bool, - ) -> Result { + _sender: AccountId, + _swap_token_list: Vec, + _bought_asset_amount: Balance, + _max_amount_in: Balance, + _err_upon_bad_slippage: bool, + _err_upon_non_slippage_fail: bool, + ) -> Result { unimplemented!() } fn mint_liquidity( - sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - first_asset_amount: Self::Balance, - expected_second_asset_amount: Self::Balance, - activate_minted_liquidity: bool, - ) -> Result<(Self::CurrencyId, Self::Balance), DispatchError> { + _sender: AccountId, + _first_asset_id: TokenId, + _second_asset_id: TokenId, + _first_asset_amount: Balance, + _expected_second_asset_amount: Balance, + _activate_minted_liquidity: bool, + ) -> Result<(TokenId, Balance), DispatchError> { unimplemented!() } fn provide_liquidity_with_conversion( - sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - provided_asset_id: Self::CurrencyId, - provided_asset_amount: Self::Balance, - activate_minted_liquidity: bool, - ) -> Result<(Self::CurrencyId, Self::Balance), DispatchError> { + _sender: AccountId, + _first_asset_id: TokenId, + _second_asset_id: TokenId, + _provided_asset_id: TokenId, + _provided_asset_amount: Balance, + _activate_minted_liquidity: bool, + ) -> Result<(TokenId, Balance), DispatchError> { unimplemented!() } fn burn_liquidity( - sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - liquidity_asset_amount: Self::Balance, + _sender: AccountId, + _first_asset_id: TokenId, + _second_asset_id: TokenId, + _liquidity_asset_amount: Balance, ) -> DispatchResult { unimplemented!() } fn get_tokens_required_for_minting( - liquidity_asset_id: Self::CurrencyId, - liquidity_token_amount: Self::Balance, - ) -> Result<(Self::CurrencyId, Self::Balance, Self::CurrencyId, Self::Balance), DispatchError> { + _liquidity_asset_id: TokenId, + _liquidity_token_amount: Balance, + ) -> Result<(TokenId, Balance, TokenId, Balance), DispatchError> { unimplemented!() } - fn is_liquidity_token(liquidity_asset_id: TokenId) -> bool { + fn is_liquidity_token(_liquidity_asset_id: TokenId) -> bool { true } fn do_compound_rewards( - sender: T::AccountId, - liquidity_asset_id: TokenId, - amount_permille: Permill, + _sender: AccountId, + _liquidity_asset_id: TokenId, + _amount_permille: Permill, ) -> DispatchResult { unimplemented!() } @@ -268,5 +256,5 @@ impl XykFunctionsTrait for MockXyk { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + system::GenesisConfig::::default().build_storage().unwrap().into() } diff --git a/pallets/multipurpose-liquidity/src/tests.rs b/pallets/multipurpose-liquidity/src/tests.rs index 4648a23688..153d1decda 100644 --- a/pallets/multipurpose-liquidity/src/tests.rs +++ b/pallets/multipurpose-liquidity/src/tests.rs @@ -7,10 +7,9 @@ use pallet_vesting_mangata::VestingInfo; #[test] fn reserve_vesting_liquidity_tokens_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 2_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let locked_amount: Balance = 500_000__u128; let lock_ending_block_as_balance: Balance = 1_000__u128; @@ -26,39 +25,39 @@ fn reserve_vesting_liquidity_tokens_works() { for _ in 0..n { ::VestingProvider::lock_tokens( &caller, - asset_id.into(), - dummy_lock_amount.into(), + asset_id, + dummy_lock_amount, None, - dummy_end_block.into(), + dummy_end_block, ) .unwrap(); } ::VestingProvider::lock_tokens( &caller, - asset_id.into(), - locked_amount.into(), + asset_id, + locked_amount, None, - lock_ending_block_as_balance.into(), + lock_ending_block_as_balance, ) .unwrap(); - let now: BlockNumber = >::block_number().saturated_into(); + let now = >::block_number(); assert_ok!(MultiPurposeLiquidity::reserve_vesting_liquidity_tokens( - RawOrigin::Signed(caller.clone().into()).into(), + RawOrigin::Signed(caller.clone()).into(), asset_id, reserve_amount )); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, 1800000u128 ); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, + ::Tokens::locked_balance(asset_id, &caller) as Balance, 349000u128 ); assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, 200000u128 ); assert_eq!( @@ -76,7 +75,7 @@ fn reserve_vesting_liquidity_tokens_works() { ); assert_eq!( MultiPurposeLiquidity::get_relock_status(caller, asset_id)[0], - RelockStatusInfo { + RelockStatusInfo::> { amount: reserve_amount, starting_block: now, ending_block_as_balance: lock_ending_block_as_balance @@ -88,10 +87,9 @@ fn reserve_vesting_liquidity_tokens_works() { #[test] fn unreserve_and_relock_instance_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 2_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let locked_amount: Balance = 500_000__u128; let lock_ending_block_as_balance: Balance = 1_000__u128; @@ -107,39 +105,39 @@ fn unreserve_and_relock_instance_works() { for _ in 0..n { ::VestingProvider::lock_tokens( &caller, - asset_id.into(), - dummy_lock_amount.into(), + asset_id, + dummy_lock_amount, None, - dummy_end_block.into(), + dummy_end_block, ) .unwrap(); } ::VestingProvider::lock_tokens( &caller, - asset_id.into(), - locked_amount.into(), + asset_id, + locked_amount, None, - lock_ending_block_as_balance.into(), + lock_ending_block_as_balance, ) .unwrap(); - let now: BlockNumber = >::block_number().saturated_into(); + let now = >::block_number(); assert_ok!(MultiPurposeLiquidity::reserve_vesting_liquidity_tokens( - RawOrigin::Signed(caller.clone().into()).into(), + RawOrigin::Signed(caller.clone()).into(), asset_id, reserve_amount )); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, 1_800_000__u128 ); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, + ::Tokens::locked_balance(asset_id, &caller) as Balance, 348000u128 ); assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, 200000u128 ); assert_eq!( @@ -157,7 +155,7 @@ fn unreserve_and_relock_instance_works() { ); assert_eq!( MultiPurposeLiquidity::get_relock_status(caller, asset_id)[0], - RelockStatusInfo { + RelockStatusInfo::> { amount: reserve_amount, starting_block: now, ending_block_as_balance: lock_ending_block_as_balance @@ -165,23 +163,17 @@ fn unreserve_and_relock_instance_works() { ); assert_ok!(MultiPurposeLiquidity::unreserve_and_relock_instance( - RawOrigin::Signed(caller.clone().into()).into(), + RawOrigin::Signed(caller.clone()).into(), asset_id, 0u32 )); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, 2_000_000__u128 ); - assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 548000 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, - 0 - ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 548000); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller) as Balance, 0); assert_eq!( Vesting::vesting(caller.clone(), asset_id as TokenId) .unwrap() @@ -202,10 +194,9 @@ fn unreserve_and_relock_instance_works() { #[test] fn bond_from_available_balance_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let bond_amount: Balance = 100_000__u128; let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -215,27 +206,23 @@ fn bond_from_available_balance_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount ); - assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, - 0 - ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller) as Balance, 0); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as StakingReservesProviderTrait>::bond( - asset_id, - &caller, - bond_amount, - Some(BondKind::AvailableBalance) - )); + assert_ok!( + as StakingReservesProviderTrait>::bond( + asset_id, + &caller, + bond_amount, + Some(BondKind::AvailableBalance) + ) + ); let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); let relock_status = Pallet::::get_relock_status(caller.clone(), asset_id); @@ -244,17 +231,14 @@ fn bond_from_available_balance_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - bond_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, bond_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -264,18 +248,13 @@ fn bond_from_available_balance_works() { #[test] fn bond_from_activated_unstaked_liquidity_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let activated_amount: Balance = 200_000__u128; let bond_amount: Balance = 100_000__u128; - assert_ok!(::Tokens::reserve( - asset_id.into(), - &caller, - activated_amount.into() - )); + assert_ok!(::Tokens::reserve(asset_id, &caller, activated_amount)); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); updated_reserve_status.activated_unstaked_reserves = activated_amount; @@ -288,27 +267,26 @@ fn bond_from_activated_unstaked_liquidity_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - activated_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, activated_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as StakingReservesProviderTrait>::bond( - asset_id, - &caller, - bond_amount, - Some(BondKind::ActivatedUnstakedReserves) - )); + assert_ok!( + as StakingReservesProviderTrait>::bond( + asset_id, + &caller, + bond_amount, + Some(BondKind::ActivatedUnstakedReserves) + ) + ); let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); let relock_status = Pallet::::get_relock_status(caller.clone(), asset_id); @@ -317,17 +295,14 @@ fn bond_from_activated_unstaked_liquidity_works() { assert_eq!(reserve_status.staked_and_activated_reserves, bond_amount); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - activated_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, activated_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -337,18 +312,13 @@ fn bond_from_activated_unstaked_liquidity_works() { #[test] fn bond_from_unspent_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let unspent_amount: Balance = 200_000__u128; let bond_amount: Balance = 100_000__u128; - assert_ok!(::Tokens::reserve( - asset_id.into(), - &caller, - unspent_amount.into() - )); + assert_ok!(::Tokens::reserve(asset_id, &caller, unspent_amount)); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); updated_reserve_status.unspent_reserves = unspent_amount; @@ -361,27 +331,26 @@ fn bond_from_unspent_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, unspent_amount); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - unspent_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, unspent_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as StakingReservesProviderTrait>::bond( - asset_id, - &caller, - bond_amount, - Some(BondKind::UnspentReserves) - )); + assert_ok!( + as StakingReservesProviderTrait>::bond( + asset_id, + &caller, + bond_amount, + Some(BondKind::UnspentReserves) + ) + ); let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); let relock_status = Pallet::::get_relock_status(caller.clone(), asset_id); @@ -390,17 +359,14 @@ fn bond_from_unspent_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, unspent_amount - bond_amount); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - unspent_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, unspent_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -410,10 +376,9 @@ fn bond_from_unspent_works() { #[test] fn activate_from_available_balance_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let activate_amount: Balance = 100_000__u128; let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -423,26 +388,21 @@ fn activate_from_available_balance_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount ); - assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, - 0 - ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); + assert_eq!(::Tokens::reserved_balance(asset_id, &caller) as Balance, 0); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as ActivationReservesProviderTrait>::activate( - asset_id, - &caller, - activate_amount, - Some(ActivateKind::AvailableBalance) + assert_ok!( as ActivationReservesProviderTrait< + AccountId, + Balance, + TokenId, + >>::activate( + asset_id, &caller, activate_amount, Some(ActivateKind::AvailableBalance) )); let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -452,17 +412,14 @@ fn activate_from_available_balance_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - activate_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, activate_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -472,18 +429,13 @@ fn activate_from_available_balance_works() { #[test] fn activate_from_staked_unactivated_liquidity_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let bonded_amount: Balance = 200_000__u128; let activate_amount: Balance = 100_000__u128; - assert_ok!(::Tokens::reserve( - asset_id.into(), - &caller, - bonded_amount.into() - )); + assert_ok!(::Tokens::reserve(asset_id, &caller, bonded_amount)); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); updated_reserve_status.staked_unactivated_reserves = bonded_amount; @@ -496,22 +448,23 @@ fn activate_from_staked_unactivated_liquidity_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - bonded_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, bonded_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as ActivationReservesProviderTrait>::activate( + assert_ok!( as ActivationReservesProviderTrait< + AccountId, + Balance, + TokenId, + >>::activate( asset_id, &caller, activate_amount, @@ -525,17 +478,14 @@ fn activate_from_staked_unactivated_liquidity_works() { assert_eq!(reserve_status.staked_and_activated_reserves, activate_amount); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - bonded_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, bonded_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -545,18 +495,13 @@ fn activate_from_staked_unactivated_liquidity_works() { #[test] fn activate_from_unspent_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let unspent_amount: Balance = 200_000__u128; let activate_amount: Balance = 100_000__u128; - assert_ok!(::Tokens::reserve( - asset_id.into(), - &caller, - unspent_amount.into() - )); + assert_ok!(::Tokens::reserve(asset_id, &caller, unspent_amount)); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); updated_reserve_status.unspent_reserves = unspent_amount; @@ -569,26 +514,24 @@ fn activate_from_unspent_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, unspent_amount); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - unspent_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, unspent_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); - assert_ok!( as ActivationReservesProviderTrait>::activate( - asset_id, - &caller, - activate_amount, - Some(ActivateKind::UnspentReserves) + assert_ok!( as ActivationReservesProviderTrait< + AccountId, + Balance, + TokenId, + >>::activate( + asset_id, &caller, activate_amount, Some(ActivateKind::UnspentReserves) )); let reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -598,17 +541,14 @@ fn activate_from_unspent_works() { assert_eq!(reserve_status.staked_and_activated_reserves, Balance::zero()); assert_eq!(reserve_status.unspent_reserves, unspent_amount - activate_amount); assert_eq!(reserve_status.relock_amount, Balance::zero()); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - unspent_amount ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, unspent_amount ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -618,19 +558,18 @@ fn activate_from_unspent_works() { #[test] fn unbond_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let staked_unactivated_amount: Balance = 50_000__u128; let staked_and_activated_amount: Balance = 85_000__u128; let relock_amount: Balance = 100_000__u128; let unbond_amount: Balance = 90_000_u128; assert_ok!(::Tokens::reserve( - asset_id.into(), + asset_id, &caller, - (staked_unactivated_amount + staked_and_activated_amount).into() + staked_unactivated_amount + staked_and_activated_amount )); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -646,23 +585,20 @@ fn unbond_works() { assert_eq!(reserve_status.staked_and_activated_reserves, staked_and_activated_amount); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, relock_amount); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - (staked_unactivated_amount + staked_and_activated_amount) ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, (staked_unactivated_amount + staked_and_activated_amount) ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); assert_eq!( - as StakingReservesProviderTrait>::unbond( + as StakingReservesProviderTrait>::unbond( asset_id, &caller, unbond_amount @@ -677,17 +613,14 @@ fn unbond_works() { assert_eq!(reserve_status.staked_and_activated_reserves, 45_000__u128); assert_eq!(reserve_status.unspent_reserves, 15_000__u128); assert_eq!(reserve_status.relock_amount, relock_amount); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - 135_000__u128 + 35_000__u128 ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, 135_000__u128 - 35_000__u128 ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -697,19 +630,18 @@ fn unbond_works() { #[test] fn deactivate_works() { new_test_ext().execute_with(|| { - let caller: u128 = 0u128; + let caller = 0u64; let initial_amount: Balance = 1_000_000__u128; - let asset_id: TokenId = - ::Tokens::create(&caller, initial_amount.into()).unwrap().into(); + let asset_id: TokenId = ::Tokens::create(&caller, initial_amount).unwrap(); let activated_unstaked_amount: Balance = 50_000__u128; let staked_and_activated_amount: Balance = 85_000__u128; let relock_amount: Balance = 100_000__u128; let deactivate_amount: Balance = 90_000_u128; assert_ok!(::Tokens::reserve( - asset_id.into(), + asset_id, &caller, - (activated_unstaked_amount + staked_and_activated_amount).into() + activated_unstaked_amount + staked_and_activated_amount )); let mut updated_reserve_status = Pallet::::get_reserve_status(caller.clone(), asset_id); @@ -725,23 +657,20 @@ fn deactivate_works() { assert_eq!(reserve_status.staked_and_activated_reserves, staked_and_activated_amount); assert_eq!(reserve_status.unspent_reserves, Balance::zero()); assert_eq!(reserve_status.relock_amount, relock_amount); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - (activated_unstaked_amount + staked_and_activated_amount) ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, (activated_unstaked_amount + staked_and_activated_amount) ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); assert_eq!( - as ActivationReservesProviderTrait>::deactivate( + as ActivationReservesProviderTrait>::deactivate( asset_id, &caller, deactivate_amount @@ -756,17 +685,14 @@ fn deactivate_works() { assert_eq!(reserve_status.staked_and_activated_reserves, 45_000__u128); assert_eq!(reserve_status.unspent_reserves, 15_000__u128); assert_eq!(reserve_status.relock_amount, relock_amount); - assert_eq!(relock_status, Vec::::new()); + assert_eq!(relock_status, Vec::>>::new()); assert_eq!( - ::Tokens::free_balance(asset_id.into(), &caller) as Balance, + ::Tokens::free_balance(asset_id, &caller) as Balance, initial_amount - 135_000__u128 + 35_000__u128 ); + assert_eq!(::Tokens::locked_balance(asset_id, &caller) as Balance, 0); assert_eq!( - ::Tokens::locked_balance(asset_id.into(), &caller) as Balance, - 0 - ); - assert_eq!( - ::Tokens::reserved_balance(asset_id.into(), &caller) as Balance, + ::Tokens::reserved_balance(asset_id, &caller) as Balance, 135_000__u128 - 35_000__u128 ); assert_eq!(Vesting::vesting(caller.clone(), asset_id as TokenId), None); @@ -779,20 +705,20 @@ type TokensOf = ::Tokens; fn vested_mpl_vested_transition_works_for_native_tokens() { new_test_ext().execute_with(|| { const MGX: u32 = ::NativeCurrencyId::get(); - const ALICE: u128 = 0u128; + const ALICE: u64 = 0u64; const MILLION: u128 = 1_000_000__000_000_000_000_000_000u128; const PER_BLOCK: u128 = 1; const STARTING_BLOCK: u64 = 10; - let token_id = ::Tokens::create(&ALICE, MILLION.into()).unwrap(); + let token_id = ::Tokens::create(&ALICE, MILLION).unwrap(); assert_eq!(token_id, MGX); - assert_eq!(TokensOf::::free_balance(MGX.into(), &ALICE), MILLION); + assert_eq!(TokensOf::::free_balance(MGX, &ALICE), MILLION); assert_eq!(orml_tokens::Accounts::::get(ALICE, MGX).frozen, 0u128); // vest tokens pallet_vesting_mangata::Pallet::::force_vested_transfer( RawOrigin::Root.into(), - MGX.into(), + MGX, ALICE, ALICE, VestingInfo::new(MILLION, PER_BLOCK, STARTING_BLOCK), @@ -806,21 +732,17 @@ fn vested_mpl_vested_transition_works_for_native_tokens() { // move vested tokens to MPL Pallet::::reserve_vesting_native_tokens_by_vesting_index( - RawOrigin::Signed(ALICE.into()).into(), + RawOrigin::Signed(ALICE).into(), 0, - MILLION.into(), + Some(MILLION), ) .unwrap(); assert_eq!(orml_tokens::Accounts::::get(ALICE, MGX).frozen, 0u128); assert!(pallet_vesting_mangata::Pallet::::vesting(ALICE, MGX).is_none()); // move tokens from MPL to vested - Pallet::::unreserve_and_relock_instance( - RawOrigin::Signed(ALICE.into()).into(), - MGX, - 0, - ) - .unwrap(); + Pallet::::unreserve_and_relock_instance(RawOrigin::Signed(ALICE).into(), MGX, 0) + .unwrap(); let infos = pallet_vesting_mangata::Pallet::::vesting(ALICE, MGX).unwrap(); assert_eq!(infos.get(0).unwrap().locked(), MILLION); assert_eq!(infos.get(0).unwrap().per_block(), PER_BLOCK); diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml new file mode 100644 index 0000000000..ff9588746e --- /dev/null +++ b/pallets/parachain-staking/Cargo.toml @@ -0,0 +1,68 @@ +[package] +name = "parachain-staking" +authors = ["PureStake"] +description = "parachain staking pallet for collator selection and reward distribution" +edition = "2021" +version = "3.0.0" + +[dependencies] +aquamarine = "0.1.12" +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +itertools = { version = "0.10.3", default-features = false, features = ["use_alloc"] } +log = { version = "0.4", default-features = false } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +serde = { version = "1.0.126", optional = true } + +pallet-issuance = { path = "../issuance", default-features = false, optional = true } + +# Substrate +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-authorship = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-collective-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-staking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + +[dev-dependencies] +similar-asserts = "1.1.0" + +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "mangata-support/std", + "mangata-types/std", + "orml-tokens/std", + "pallet-authorship/std", + "pallet-session/std", + "scale-info/std", + "serde", + "sp-runtime/std", + "sp-staking/std", + "sp-std/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-collective-mangata/runtime-benchmarks", + "pallet-issuance", +] +try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime"] diff --git a/pallets/parachain-staking/README.md b/pallets/parachain-staking/README.md new file mode 100644 index 0000000000..ff83118cd5 --- /dev/null +++ b/pallets/parachain-staking/README.md @@ -0,0 +1,26 @@ +# DPoS Pallet for Parachain Staking + +## Formatting Rules + +- dependencies in alphabetical order in the `Cargo.toml` and at the top of each file +- prefer explicit imports to glob import syntax i.e. prefer `use::crate::{Ex1, Ex2, ..};` to `use super::*;` + +## Description + +Implements Delegated Proof of Stake to + +1. select the active set of eligible block producers +2. reward block authors +3. enable delegators and collators to participate in inflationary rewards + +Links: + +- [Rust Documentation](https://purestake.github.io/moonbeam/parachain_staking/index.html) +- [Unofficial Documentation](https://meta5.world/parachain-staking-docs/) +- [(Outdated) Blog Post with Justification](https://meta5.world/posts/parachain-staking) + +## History + +Since January 2021, Moonbeam's team has maintained this Delegated Proof of Stake (DPoS) pallet designed specifically for parachains. + +Since April 2021, the development of this pallet has been supported by [a Web3 Foundation grant](https://github.com/w3f/Grants-Program/pull/389). The [first milestone](https://github.com/w3f/Grant-Milestone-Delivery/pull/218) was approved in June 2021. diff --git a/pallets/parachain-staking/migrations.md b/pallets/parachain-staking/migrations.md new file mode 100644 index 0000000000..d2277ffcd0 --- /dev/null +++ b/pallets/parachain-staking/migrations.md @@ -0,0 +1,42 @@ +# Migration History + +## Calculate outgoing rewards based on pending revoke and decrease changes + +- [Migration PR `#1408`](https://github.com/PureStake/moonbeam/pull/1408) + +## Patch delegations total mismatch + +- [Migration PR `#1291`](https://github.com/PureStake/moonbeam/pull/1291) + +## Split candidate state for PoV optimization + +- [Migration PR `#1117`](https://github.com/PureStake/moonbeam/pull/1117) + +## Increase max delegations per candidate + +- [Migration PR `#1096`](https://github.com/PureStake/moonbeam/pull/1096) +- [Migratio bugfix `#1112`](https://github.com/PureStake/moonbeam/pull/1112) + +## Manual Exits and Patch Lack of Delay for bond\_{more, less} + +- [Migration PR `#810`](https://github.com/PureStake/moonbeam/pull/810) +- [Migration Removal PR `#?`]() + +## Purge Stale Storage + +- [Migration PR `#970`](https://github.com/PureStake/moonbeam/pull/970) + +## Delay nominator exits by changing NominatorState and ExitQueue + +- [Migration PR `#610`](https://github.com/PureStake/moonbeam/pull/610) +- [Migration Removal PR `#662`](https://github.com/PureStake/moonbeam/pull/662) + +## Patch nomination DOS attack vector by changing CollatorState + +- [Migration PR `#505`](https://github.com/PureStake/moonbeam/pull/505) +- [Migration Removal PR `#553`](https://github.com/PureStake/moonbeam/pull/553) + +## Patch underflow bug and correct Total storage item + +- [Migration PR `#502`](https://github.com/PureStake/moonbeam/pull/502) +- [Migration Removal PR `#553`](https://github.com/PureStake/moonbeam/pull/553) diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs new file mode 100644 index 0000000000..aeb7a33a23 --- /dev/null +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -0,0 +1,1941 @@ +// Copyright 2019-2021 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +#![cfg(feature = "runtime-benchmarks")] + +//! Benchmarking +// use crate::{ +// BalanceOf, Call, CandidateBondChange, CandidateBondRequest, Config, DelegationChange, +// DelegationRequest, Pallet, Range, +// }; +use crate::*; +use frame_benchmarking::{account, benchmarks}; +use frame_support::{ + assert_ok, + traits::{ExistenceRequirement, Get}, +}; +use frame_system::RawOrigin; +use itertools::Itertools; +use mangata_support::traits::{ProofOfStakeRewardsApi, XykFunctionsTrait}; +use orml_tokens::MultiTokenCurrencyExtended; +use pallet_authorship::EventHandler; +use sp_runtime::Perbill; +use sp_std::vec::Vec; + +const DOLLAR: u128 = 1__000_000_000_000_000_000u128; +const MGA_TOKEN_ID: u32 = 0u32; + +trait ToBalance { + fn to_balance(self) -> BalanceOf; +} + +impl ToBalance for u128 { + fn to_balance(self) -> BalanceOf { + self.try_into().ok().expect("u128 should fit into Balance type") + } +} + +/// We assume +/// Mga token is token id 0 +/// Not more than 100 curated tokens +/// Not more than 1000 candidates + +/// To maintain simplicity, creating a pool and using resulting liqudity tokens to stake have been separated +/// To do this we mint tokens and create pools using one user, the funding account +/// And then distribute the liquidity tokens to various users +/// For each liquidity token, two additional tokens must be created +/// (Token n, Token n+1) <=> Token n+2 +/// Starting from n0=5 as the first 4 are taken by the genesis config, but the starting n0 will be determined at the start of each bench by checking tokens +/// Any set of tokens x, x0=0, will have token_id, (3x+5, 3x+6) <=> 3x+7 +/// Since we are creating new tokens every time we can simply just use (v, v+1) as the pooled token amounts, to mint v liquidity tokens + +// pub(crate) fn payout_collator_for_round( +// n: u32, +// ) { +// let dummy_user: T::AccountId = account("dummy", 0u32, 0u32); +// let collators: Vec<::AccountId> = +// RoundCollatorRewardInfo::::iter_key_prefix(n).collect(); +// for collator in collators.iter() { +// Pallet::::payout_collator_rewards( +// RawOrigin::Signed(dummy_user.clone()).into(), +// n.try_into().unwrap(), +// collator.clone(), +// <::MaxDelegatorsPerCandidate as Get>::get(), +// ); +// } +// } + +/// Mint v liquidity tokens of token set x to funding account +fn create_non_staking_liquidity_for_funding< + T: Config, CurrencyId = CurrencyIdOf>, +>( + v: Option>, +) -> Result, DispatchError> { + let funding_account: T::AccountId = account("funding", 0u32, 0u32); + let x = T::Currency::get_next_currency_id(); + let v = v.unwrap_or((1_000_000_000_000_000_000 * DOLLAR).to_balance::()); + T::Currency::create(&funding_account, v)?; + T::Currency::create(&funding_account, v + 1u32.into())?; + + assert!( + T::Xyk::create_pool(funding_account.clone(), x, v, x + 1_u32.into(), v + 1_u32.into(),) + .is_ok() + ); + + assert_eq!(T::Currency::total_balance(x + 2u32.into(), &funding_account), v); + Ok(x + 2u32.into()) +} + +/// Mint v liquidity tokens of token set x to funding account +fn create_staking_liquidity_for_funding< + T: Config, CurrencyId = CurrencyIdOf>, +>( + v: Option>, +) -> Result, DispatchError> { + let funding_account: T::AccountId = account("funding", 0u32, 0u32); + let x = T::Currency::get_next_currency_id(); + let v = v.unwrap_or((1_000_000_000_000_000_000 * DOLLAR).to_balance::()); + T::Currency::mint(MGA_TOKEN_ID.into(), &funding_account, v)?; + T::Currency::create(&funding_account, v + 1u32.into())?; + + assert!(T::Xyk::create_pool( + funding_account.clone(), + MGA_TOKEN_ID.into(), + v, + x, + v + 1_u32.into(), + ) + .is_ok()); + + assert_eq!(T::Currency::total_balance(x + 1u32.into(), &funding_account), v); + Ok(x + 1u32.into()) +} + +/// Create a funded user. +/// Extra + min_candidate_stk is total minted funds +/// Returns tuple (id, balance) +fn create_funded_user, CurrencyId = CurrencyIdOf>>( + string: &'static str, + n: u32, + token_id: CurrencyIdOf, + v: Option>, +) -> (T::AccountId, CurrencyIdOf, BalanceOf) { + let funding_account: T::AccountId = account("funding", 0u32, 0u32); + const SEED: u32 = 0; + let user = account(string, n, SEED); + log::info!("create user {}-{}-{}", string, n, SEED); + let v = v.unwrap_or((1_000_000_000 * DOLLAR).to_balance::()); + assert_ok!(T::Currency::transfer( + token_id.into(), + &funding_account, + &user, + v, + ExistenceRequirement::AllowDeath + )); + (user, token_id, v) +} + +/// Create a funded delegator. +fn create_funded_delegator, CurrencyId = CurrencyIdOf>>( + string: &'static str, + n: u32, + collator: T::AccountId, + collator_token_id: CurrencyIdOf, + v: Option>, + collator_delegator_count: u32, +) -> Result { + let (user, _, v) = create_funded_user::(string, n, collator_token_id, v); + Pallet::::delegate( + RawOrigin::Signed(user.clone()).into(), + collator, + v, + None, + collator_delegator_count, + 0u32, // first delegation for all calls + )?; + Ok(user) +} + +/// Create a funded collator. +fn create_funded_collator, CurrencyId = CurrencyIdOf>>( + string: &'static str, + n: u32, + token_id: CurrencyIdOf, + v: Option>, + candidate_count: u32, + liquidity_token_count: u32, +) -> Result { + let (user, token_id, v) = create_funded_user::(string, n, token_id, v); + Pallet::::join_candidates( + RawOrigin::Signed(user.clone()).into(), + v, + token_id, + None, + candidate_count, + liquidity_token_count, + )?; + Ok(user) +} + +pub(crate) fn roll_to_round_and_author( + n: u32, + author: Option, +) { + let current_round: u32 = Pallet::::round().current; + + while !(Pallet::::round().current >= n + current_round as u32 + 1u32) { + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize( + >::block_number(), + ); + >::set_block_number( + >::block_number() + 1u32.into(), + ); + as frame_support::traits::Hooks<_>>::on_initialize( + >::block_number(), + ); + if author.clone().is_some() { + Pallet::::note_author(author.clone().unwrap().clone()); + } + as frame_support::traits::Hooks<_>>::on_initialize( + >::block_number(), + ); + if as pallet_session::ShouldEndSession<_>>::should_end_session( + >::block_number(), + ) { + // This doesn't really use pallet_session::Pallet::::current_index() + // especially since pallet_session's on_initialize is not triggered (session index will always be 0) + // But Staking's start session doesn't care as long as it isn't session 0 + as pallet_session::SessionManager<_>>::start_session( + pallet_session::Pallet::::current_index() as u32 + 1u32, + ); + } + } + + // Assumes round is atleast 3 blocks + // Roll to 2 blocks into the given round + for _i in 0..2 { + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize( + >::block_number(), + ); + >::set_block_number( + >::block_number() + 1u32.into(), + ); + as frame_support::traits::Hooks<_>>::on_initialize( + >::block_number(), + ); + if author.clone().is_some() { + Pallet::::note_author(author.clone().unwrap().clone()); + } + as frame_support::traits::Hooks<_>>::on_initialize( + >::block_number(), + ); + } +} + +const USER_SEED: u32 = 999666; +const DUMMY_COUNT: u32 = 999666; + +benchmarks! { + where_clause { where T: Config, CurrencyId = CurrencyIdOf> } + // ROOT DISPATCHABLES + + set_total_selected {}: _(RawOrigin::Root, 100u32) + verify { + assert_eq!(Pallet::::total_selected(), 100u32); + } + + set_collator_commission {}: _(RawOrigin::Root, Perbill::from_percent(33)) + verify { + assert_eq!(Pallet::::collator_commission(), Perbill::from_percent(33)); + } + + // USER DISPATCHABLES + + join_candidates { + let x in 3_u32..(<::MaxCollatorCandidates as Get>::get() - 1u32); + let y in 3_u32..100; + + // Worst Case Complexity is search into a list so \exists full list before call + let liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + assert!(y > liquidity_token_count); + for i in liquidity_token_count..(y - 1u32){ + let liquidity_token_id = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(liquidity_token_id), i)?; + } + + let created_liquidity_token = + create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get() * x.into())).unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), y - 1)); + + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + assert!(x >= candidate_count); + + // Worst Case Complexity is insertion into an ordered list so \exists full list before call + + for i in candidate_count..x { + let seed = USER_SEED - i; + let res = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + Some(T::MinCandidateStk::get()), + candidate_count + i, + y + ); + if res.is_err(){ + let res_str: &str = res.unwrap_err().try_into().unwrap(); + log::info!("res_str: {:?}", res_str); + } else { + let collator = res.unwrap(); + } + } + let (caller, _, _) = create_funded_user::("caller", USER_SEED, created_liquidity_token, Some(T::MinCandidateStk::get())); + }: _(RawOrigin::Signed(caller.clone()), T::MinCandidateStk::get(), created_liquidity_token, None, x, y) + verify { + assert!(Pallet::::is_candidate(&caller)); + } + + // This call schedules the collator's exit and removes them from the candidate pool + // -> it retains the self-bond and delegator bonds + schedule_leave_candidates { + let x in 3..(<::MaxCollatorCandidates as Get>::get() - 1u32); + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + assert!(x >= candidate_count); + + // Worst Case Complexity is insertion into an ordered list so \exists full list before call + + for i in candidate_count..(x - 1u32) { + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + i, + liquidity_token_count + )?; + } + let caller = create_funded_collator::("caller", USER_SEED, created_liquidity_token, None, x - 1u32, liquidity_token_count)?; + + }: _(RawOrigin::Signed(caller.clone()), x) + verify { + assert!(Pallet::::candidate_state(&caller).unwrap().is_leaving()); + } + + execute_leave_candidates { + // x is total number of delegations for the candidate + let x in 2..(<::MaxTotalDelegatorsPerCandidate as Get>::get()); + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let candidate: T::AccountId = create_funded_collator::( + "unique_caller", + USER_SEED - 100, + created_liquidity_token, + None, + candidate_count + 1u32, + liquidity_token_count, + )?; + // 2nd delegation required for all delegators to ensure DelegatorState updated not removed + let second_candidate: T::AccountId = create_funded_collator::( + "unique__caller", + USER_SEED - 99, + created_liquidity_token, + None, + candidate_count + 2u32, + liquidity_token_count, + )?; + + let mut delegators: Vec = Vec::new(); + let mut col_del_count = 0u32; + for i in 1..x { + let seed = USER_SEED + i; + let delegator = create_funded_delegator::( + "delegator", + seed, + candidate.clone(), + created_liquidity_token, + None, + col_del_count, + )?; + assert_ok!(T::Currency::transfer(created_liquidity_token, &account("funding", 0u32, 0u32), &delegator, (100*DOLLAR).to_balance::(), ExistenceRequirement::AllowDeath)); + assert_ok!(Pallet::::delegate( + RawOrigin::Signed(delegator.clone()).into(), + second_candidate.clone(), + (100*DOLLAR).to_balance::(), + None, + col_del_count, + 1u32 + )); + assert_ok!(Pallet::::schedule_revoke_delegation( + RawOrigin::Signed(delegator.clone()).into(), + candidate.clone() + )); + delegators.push(delegator); + col_del_count += 1u32; + } + assert_ok!(Pallet::::schedule_leave_candidates( + RawOrigin::Signed(candidate.clone()).into(), + candidate_count + 3u32 + )); + roll_to_round_and_author::(2, Some(candidate.clone())); + }: _(RawOrigin::Signed(candidate.clone()), candidate.clone(), col_del_count) + verify { + assert!(Pallet::::candidate_state(&candidate).is_none()); + assert!(Pallet::::candidate_state(&second_candidate).is_some()); + for delegator in delegators { + assert!(Pallet::::is_delegator(&delegator)); + } + } + + cancel_leave_candidates { + let x in 3..(<::MaxCollatorCandidates as Get>::get() - 1u32); + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + // Worst Case Complexity is removal from an ordered list so \exists full list before call + let mut candidate_count = Pallet::::candidate_pool().0.len().try_into().unwrap(); + for i in 2..x { + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + candidate_count += 1u32; + } + let caller: T::AccountId = create_funded_collator::( + "caller", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + candidate_count += 1u32; + Pallet::::schedule_leave_candidates( + RawOrigin::Signed(caller.clone()).into(), + candidate_count + )?; + candidate_count -= 1u32; + }: _(RawOrigin::Signed(caller.clone()), candidate_count) + verify { + assert!(Pallet::::candidate_state(&caller).unwrap().is_active()); + } + + go_offline { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + }: _(RawOrigin::Signed(caller.clone())) + verify { + assert!(!Pallet::::candidate_state(&caller).unwrap().is_active()); + } + + go_online { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + Pallet::::go_offline(RawOrigin::Signed(caller.clone()).into())?; + }: _(RawOrigin::Signed(caller.clone())) + verify { + assert!(Pallet::::candidate_state(&caller).unwrap().is_active()); + } + + schedule_candidate_bond_more { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let more = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + assert_ok!(T::Currency::transfer(created_liquidity_token, &account("funding", 0u32, 0u32), &caller, more, ExistenceRequirement::AllowDeath)); + + }: _(RawOrigin::Signed(caller.clone()), more, None) + verify { + let state = Pallet::::candidate_state(&caller).expect("request bonded more so exists"); + assert_eq!( + state.request, + Some(CandidateBondRequest { + amount: more, + change: CandidateBondChange::Increase, + when_executable: 2, + }) + ); + } + + schedule_candidate_bond_less { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let less = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + }: _(RawOrigin::Signed(caller.clone()), less) + verify { + let state = Pallet::::candidate_state(&caller).expect("request bonded less so exists"); + assert_eq!( + state.request, + Some(CandidateBondRequest { + amount: less, + change: CandidateBondChange::Decrease, + when_executable: 2, + }) + ); + } + + execute_candidate_bond_more { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let more = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + assert_ok!(T::Currency::transfer(created_liquidity_token, &account("funding", 0u32, 0u32), &caller, more, ExistenceRequirement::AllowDeath)); + + Pallet::::schedule_candidate_bond_more( + RawOrigin::Signed(caller.clone()).into(), + more, + None + )?; + roll_to_round_and_author::(2, Some(caller.clone())); + }: { + Pallet::::execute_candidate_bond_request( + RawOrigin::Signed(caller.clone()).into(), + caller.clone(), + None + )?; + } verify { + let expected_bond = 1000000010* DOLLAR; + assert_eq!(::Currency::reserved_balance(created_liquidity_token, &caller).into(), expected_bond); + } + + execute_candidate_bond_less { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let less = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + Pallet::::schedule_candidate_bond_less( + RawOrigin::Signed(caller.clone()).into(), + less + )?; + roll_to_round_and_author::(2, Some(caller.clone())); + }: { + Pallet::::execute_candidate_bond_request( + RawOrigin::Signed(caller.clone()).into(), + caller.clone(), + None + )?; + } verify { + assert_eq!(::Currency::reserved_balance(created_liquidity_token.into(), &caller).into(), 999999990*DOLLAR); + } + + cancel_candidate_bond_more { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let more = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + assert_ok!(T::Currency::transfer(created_liquidity_token, &account("funding", 0u32, 0u32), &caller, more, ExistenceRequirement::AllowDeath)); + + Pallet::::schedule_candidate_bond_more( + RawOrigin::Signed(caller.clone()).into(), + more, + None + )?; + }: { + Pallet::::cancel_candidate_bond_request( + RawOrigin::Signed(caller.clone()).into(), + )?; + } verify { + assert!( + Pallet::::candidate_state(&caller).unwrap().request.is_none() + ); + } + + cancel_candidate_bond_less { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let less = (10*DOLLAR).to_balance::(); + let caller: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + Pallet::::schedule_candidate_bond_less( + RawOrigin::Signed(caller.clone()).into(), + less + )?; + }: { + Pallet::::cancel_candidate_bond_request( + RawOrigin::Signed(caller.clone()).into(), + )?; + } verify { + assert!( + Pallet::::candidate_state(&caller).unwrap().request.is_none() + ); + } + + delegate { + let x in 3..(<::MaxDelegationsPerDelegator as Get>::get().min(<::MaxCollatorCandidates as Get>::get() - 2u32)); + let y in 2..<::MaxDelegatorsPerCandidate as Get>::get(); + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + // Worst Case is full of delegations before calling `delegate` + let mut collators: Vec = Vec::new(); + // Initialize MaxDelegationsPerDelegator collator candidates + for i in 2..x { + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + collators.len() as u32 + candidate_count, + liquidity_token_count, + )?; + collators.push(collator.clone()); + } + + let (caller, _, _) = create_funded_user::("caller", USER_SEED, created_liquidity_token, Some((100 * DOLLAR * (collators.len() as u128 + 1u128) + 1u128).to_balance::())); + // Delegation count + let mut del_del_count = 0u32; + // Nominate MaxDelegationsPerDelegators collator candidates + for col in collators.clone() { + Pallet::::delegate( + RawOrigin::Signed(caller.clone()).into(), col, (100 * DOLLAR).to_balance::(), None, 0u32, del_del_count + )?; + del_del_count += 1u32; + } + // Last collator to be delegated + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + collators.len() as u32 + candidate_count + 1, + liquidity_token_count, + )?; + // Worst Case Complexity is insertion into an almost full collator + let mut col_del_count = 0u32; + for i in 1..y { + let seed = USER_SEED + i; + let _ = create_funded_delegator::( + "delegator", + seed, + collator.clone(), + created_liquidity_token, + None, + col_del_count, + )?; + col_del_count += 1u32; + } + }: _(RawOrigin::Signed(caller.clone()), collator, (100*DOLLAR + 1u128).to_balance::(), None, col_del_count, del_del_count) + verify { + assert!(Pallet::::is_delegator(&caller)); + } + + schedule_leave_delegators { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, _) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + (100*DOLLAR).to_balance::(), + None, + 0u32, + 0u32 + )?; + }: _(RawOrigin::Signed(caller.clone())) + verify { + assert!(Pallet::::delegator_state(&caller).unwrap().is_leaving()); + } + + execute_leave_delegators { + let x in 2..(<::MaxDelegationsPerDelegator as Get>::get().min(<::MaxCollatorCandidates as Get>::get() - 2u32)); + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + // Worst Case is full of delegations before execute exit + let mut collators: Vec = Vec::new(); + // Initialize MaxDelegationsPerDelegator collator candidates + for i in 1..x { + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + collators.len() as u32 + candidate_count, + liquidity_token_count + )?; + collators.push(collator.clone()); + } + // Fund the delegator + let (caller, _, _) = create_funded_user::("caller", USER_SEED, created_liquidity_token, Some((100 * DOLLAR * (collators.len() as u128)).to_balance::())); + // Delegation count + let mut delegation_count = 0u32; + let author = collators[0].clone(); + // Nominate MaxDelegationsPerDelegators collator candidates + for col in collators { + Pallet::::delegate( + RawOrigin::Signed(caller.clone()).into(), + col, + (100*DOLLAR).to_balance::(), + None, + 0u32, + delegation_count + )?; + delegation_count += 1u32; + } + Pallet::::schedule_leave_delegators(RawOrigin::Signed(caller.clone()).into())?; + roll_to_round_and_author::(2, Some(author)); + }: _(RawOrigin::Signed(caller.clone()), caller.clone(), delegation_count) + verify { + assert!(Pallet::::delegator_state(&caller).is_none()); + } + + cancel_leave_delegators { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + Pallet::::schedule_leave_delegators(RawOrigin::Signed(caller.clone()).into())?; + }: _(RawOrigin::Signed(caller.clone())) + verify { + assert!(Pallet::::delegator_state(&caller).unwrap().is_active()); + } + + schedule_revoke_delegation { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + }: _(RawOrigin::Signed(caller.clone()), collator.clone()) + verify { + assert_eq!( + Pallet::::delegator_state(&caller).unwrap().requests().get(&collator), + Some(&DelegationRequest { + collator, + amount: v, + when_executable: 2, + action: DelegationChange::Revoke + }) + ); + } + + schedule_delegator_bond_more { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + v - (10*DOLLAR).to_balance::(), + None, + 0u32, + 0u32 + )?; + }: _(RawOrigin::Signed(caller.clone()), collator.clone(), (10*DOLLAR).to_balance::(), None) + verify { + let state = Pallet::::delegator_state(&caller) + .expect("just request bonded less so exists"); + assert_eq!( + state.requests().get(&collator), + Some(&DelegationRequest { + collator, + amount: (10*DOLLAR).to_balance::(), + when_executable: 2, + action: DelegationChange::Increase + }) + ); + } + + schedule_delegator_bond_less { + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + }: _(RawOrigin::Signed(caller.clone()), collator.clone(), (10*DOLLAR).to_balance::()) + verify { + let state = Pallet::::delegator_state(&caller) + .expect("just request bonded less so exists"); + assert_eq!( + state.requests().get(&collator), + Some(&DelegationRequest { + collator, + amount: (10*DOLLAR).to_balance::(), + when_executable: 2, + action: DelegationChange::Decrease + }) + ); + } + + execute_revoke_delegation { + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + Pallet::::schedule_revoke_delegation(RawOrigin::Signed( + caller.clone()).into(), + collator.clone() + )?; + roll_to_round_and_author::(2, Some(collator.clone())); + }: { + Pallet::::execute_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + caller.clone(), + collator.clone(), + None + )?; + } verify { + assert!( + !Pallet::::is_delegator(&caller) + ); + } + + execute_delegator_bond_more { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + + Pallet::::delegate( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + v - (10*DOLLAR).to_balance::(), + None, + 0u32, + 0u32 + )?; + Pallet::::schedule_delegator_bond_more( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + (10*DOLLAR).to_balance::(), + None + )?; + roll_to_round_and_author::(2, Some(collator.clone())); + }: { + Pallet::::execute_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + caller.clone(), + collator.clone(), + None + )?; + } verify { + let expected_bond = 1000000000* DOLLAR; + assert_eq!(::Currency::reserved_balance(created_liquidity_token.into(), &caller).into(), expected_bond); + } + + execute_delegator_bond_less { + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + let bond_less = (10*DOLLAR).to_balance::(); + Pallet::::schedule_delegator_bond_less( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + bond_less + )?; + roll_to_round_and_author::(2, Some(collator.clone())); + }: { + Pallet::::execute_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + caller.clone(), + collator.clone(), + None + )?; + } verify { + let expected = v - bond_less; + assert_eq!(::Currency::reserved_balance(created_liquidity_token.into(), &caller), expected); + } + + cancel_revoke_delegation { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + v, + None, + 0u32, + 0u32 + )?; + Pallet::::schedule_revoke_delegation( + RawOrigin::Signed(caller.clone()).into(), + collator.clone() + )?; + }: { + Pallet::::cancel_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + collator.clone() + )?; + } verify { + assert!( + Pallet::::delegator_state(&caller).unwrap().requests().get(&collator).is_none() + ); + } + + cancel_delegator_bond_more { + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, v) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + + Pallet::::delegate( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + v - (10*DOLLAR).to_balance::(), + None, + 0u32, + 0u32 + )?; + Pallet::::schedule_delegator_bond_more( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + (10*DOLLAR).to_balance::(), + None + )?; + roll_to_round_and_author::(2, Some(collator.clone())); + }: { + Pallet::::cancel_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + collator.clone() + )?; + } verify { + assert!( + Pallet::::delegator_state(&caller) + .unwrap() + .requests() + .get(&collator) + .is_none() + ); + } + + cancel_delegator_bond_less { + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + let mut liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), liquidity_token_count)); + + liquidity_token_count = liquidity_token_count + 1u32; + + let candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + let collator: T::AccountId = create_funded_collator::( + "collator", + USER_SEED, + created_liquidity_token, + None, + candidate_count, + liquidity_token_count, + )?; + let (caller, _, total) = create_funded_user::("caller", USER_SEED, created_liquidity_token, None); + Pallet::::delegate(RawOrigin::Signed( + caller.clone()).into(), + collator.clone(), + total - (10*DOLLAR).to_balance::(), + None, + 0u32, + 0u32 + )?; + let bond_less = (10*DOLLAR).to_balance::(); + Pallet::::schedule_delegator_bond_less( + RawOrigin::Signed(caller.clone()).into(), + collator.clone(), + bond_less + )?; + roll_to_round_and_author::(2, Some(collator.clone())); + }: { + Pallet::::cancel_delegation_request( + RawOrigin::Signed(caller.clone()).into(), + collator.clone() + )?; + } verify { + assert!( + Pallet::::delegator_state(&caller) + .unwrap() + .requests() + .get(&collator) + .is_none() + ); + } + + add_staking_liquidity_token { + let x in 3..100; + + let liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + assert!(x > liquidity_token_count); + for i in liquidity_token_count..(x){ + let liquidity_token_id = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(liquidity_token_id), i)); + } + + let liquidity_token_id = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + + }: _(RawOrigin::Root, PairedOrLiquidityToken::Liquidity(liquidity_token_id), x) + verify { + assert!( + Pallet::::staking_liquidity_tokens() + .contains_key(&liquidity_token_id) + ); + } + + remove_staking_liquidity_token { + let x in 3..100; + + let liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + assert!(x > liquidity_token_count); + for i in liquidity_token_count..(x - 1u32){ + let token_id = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(token_id), i)); + } + + let token_id = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(token_id), x - 1u32)); + + }: _(RawOrigin::Root, PairedOrLiquidityToken::Liquidity(token_id), x) + verify { + assert!( + !Pallet::::staking_liquidity_tokens() + .contains_key(&(token_id)) + ); + } + + aggregator_update_metadata { + + let x = <::MaxCollatorCandidates as Get>::get() - 2u32; // to account for the two candidates we start with + + + let start_liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + let initial_candidates: Vec = Pallet::::candidate_pool().0.into_iter().map(|x| x.owner).collect::<_>(); + let base_candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + assert_eq!(base_candidate_count, 2); + + let mut candidates: Vec = Vec::::new(); + + + const SEED: u32 = 0; + + for i in 0u32..x{ + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), 1000)); + + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + candidates.len() as u32 + base_candidate_count, + 1000 + )?; + + candidates.push(collator.clone()); + + } + + let aggregator: T::AccountId = account("aggregator", 0u32, SEED); + assert_ok!(Pallet::::aggregator_update_metadata(RawOrigin::Signed( + aggregator.clone()).into(), + candidates.clone(), + MetadataUpdateAction::ExtendApprovedCollators + )); + + for i in 0u32..(x){ + + let seed = USER_SEED - i; + + let collator: T::AccountId = account("collator", seed, SEED); + assert_ok!(Pallet::::update_candidate_aggregator(RawOrigin::Signed( + collator.clone()).into(), + Some(aggregator.clone()), + )); + + } + + for i in 0u32..(x){ + + let seed = USER_SEED - i; + + let collator: T::AccountId = account("collator", seed, SEED); + assert_eq!(CandidateAggregator::::get() + .get(&collator).cloned(), + Some(aggregator.clone()), + ); + + } + + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().token_collator_map.len(), x as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().approved_candidates.len(), x as usize); + + }: _(RawOrigin::Signed(aggregator.clone()), candidates.clone(), MetadataUpdateAction::RemoveApprovedCollators) + verify { + + for i in 0u32..(x){ + + let seed = USER_SEED - i; + + let collator = account("collator", seed, SEED); + assert_eq!(CandidateAggregator::::get() + .get(&collator).cloned(), + None, + ); + + } + + assert_eq!(AggregatorMetadata::::get(&aggregator), None); + assert_eq!(AggregatorMetadata::::get(&aggregator), None); + + } + + update_candidate_aggregator { + + let x = <::MaxCollatorCandidates as Get>::get() - 2u32; // to account for the two candidates we start with + + + let start_liquidity_token_count: u32 = Pallet::::staking_liquidity_tokens().len().try_into().unwrap(); + + let initial_candidates: Vec = Pallet::::candidate_pool().0.into_iter().map(|x| x.owner).collect::<_>(); + let base_candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + assert_eq!(base_candidate_count, 2); + + let mut candidates: Vec = Vec::::new(); + + const SEED: u32 = 0; + + for i in 0u32..x{ + + let created_liquidity_token = + create_staking_liquidity_for_funding::(None).unwrap(); + + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), 1000)); + + let seed = USER_SEED - i; + let collator = create_funded_collator::( + "collator", + seed, + created_liquidity_token, + None, + candidates.len() as u32 + base_candidate_count, + 1000 + )?; + + candidates.push(collator.clone()); + + } + + let aggregator: T::AccountId = account("aggregator", 0u32, SEED); + assert_ok!(Pallet::::aggregator_update_metadata(RawOrigin::Signed( + aggregator.clone()).into(), + candidates.clone(), + MetadataUpdateAction::ExtendApprovedCollators + )); + + for i in 1u32..(x){ + + let seed = USER_SEED - i; + + let collator: T::AccountId = account("collator", seed, SEED); + assert_ok!(Pallet::::update_candidate_aggregator(RawOrigin::Signed( + collator.clone()).into(), + Some(aggregator.clone()), + )); + + } + + for i in 1u32..(x){ + + let seed = USER_SEED - i; + + let collator: T::AccountId = account("collator", seed, SEED); + assert_eq!(CandidateAggregator::::get() + .get(&collator).cloned(), + Some(aggregator.clone()), + ); + + } + + let collator_switching: T::AccountId = account("collator", USER_SEED, SEED); + let aggregator_old: T::AccountId = account("aggregator", 1u32, SEED); + assert_ok!(Pallet::::aggregator_update_metadata(RawOrigin::Signed( + aggregator_old.clone()).into(), + vec![collator_switching.clone()], + MetadataUpdateAction::ExtendApprovedCollators + )); + + assert_ok!(Pallet::::update_candidate_aggregator(RawOrigin::Signed( + collator_switching.clone()).into(), + Some(aggregator_old.clone()), + )); + + assert_eq!(CandidateAggregator::::get() + .get(&collator_switching).cloned(), + Some(aggregator_old.clone()), + ); + + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().token_collator_map.len(), (x - 1) as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().approved_candidates.len(), x as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator_old).unwrap().token_collator_map.len(), 1 as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator_old).unwrap().approved_candidates.len(), 1 as usize); + + }: _(RawOrigin::Signed(collator_switching.clone()), Some(aggregator.clone())) + verify { + + for i in 0u32..(x){ + + let seed = USER_SEED - i; + + let collator = account("collator", seed, SEED); + assert_eq!(CandidateAggregator::::get() + .get(&collator).cloned(), + Some(aggregator.clone()), + ); + + } + + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().token_collator_map.len(), x as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator).unwrap().approved_candidates.len(), x as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator_old).unwrap().token_collator_map.len(), 0 as usize); + assert_eq!(AggregatorMetadata::::get(&aggregator_old).unwrap().approved_candidates.len(), 1 as usize); + + } + + payout_collator_rewards { + + let funding_account: T::AccountId = account("funding", 0u32, 0u32); + assert_ok!(T::Currency::mint(MGA_TOKEN_ID.into(), &<::StakingIssuanceVault as Get>::get(), (1_000_000*DOLLAR).to_balance::())); + + const SEED: u32 = 0; + let collator: T::AccountId = account("collator", 0u32, SEED); + + let mut round_collator_reward_info = RoundCollatorRewardInfoType::>::default(); + round_collator_reward_info.collator_reward = (1*DOLLAR).to_balance::(); + + for i in 0u32..<::MaxDelegatorsPerCandidate as Get>::get() { + let delegator: T::AccountId = account("delegator", USER_SEED - i, SEED); + round_collator_reward_info.delegator_rewards.insert(delegator, (1*DOLLAR).to_balance::()); + } + + RoundCollatorRewardInfo::::insert(collator.clone(), 1000, round_collator_reward_info); + + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000).unwrap().collator_reward, (1*DOLLAR).to_balance::()); + + }: _(RawOrigin::Signed(collator.clone()), collator.clone(), Some(1)) + verify { + + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000), None); + + } + + + payout_delegator_reward { + + let funding_account: T::AccountId = account("funding", 0u32, 0u32); + assert_ok!(T::Currency::mint(MGA_TOKEN_ID.into(), &<::StakingIssuanceVault as Get>::get(), (1_000_000*DOLLAR).to_balance::())); + + const SEED: u32 = 0; + let collator: T::AccountId = account("collator", 0u32, SEED); + + let mut round_collator_reward_info = RoundCollatorRewardInfoType::>::default(); + round_collator_reward_info.collator_reward = (1*DOLLAR).to_balance::(); + + for i in 0u32..(<::MaxDelegatorsPerCandidate as Get>::get()) { + let delegator: T::AccountId = account("delegator", USER_SEED - i, SEED); + round_collator_reward_info.delegator_rewards.insert(delegator, (1*DOLLAR).to_balance::()); + } + + RoundCollatorRewardInfo::::insert(collator.clone(), 1000, round_collator_reward_info); + + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000).unwrap().collator_reward, (1*DOLLAR).to_balance::()); + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000).unwrap().delegator_rewards.len(), <::MaxDelegatorsPerCandidate as Get>::get() as usize); + + let delegator_target: T::AccountId = account("delegator", USER_SEED, SEED); + + }: _(RawOrigin::Signed(delegator_target.clone()), 1000, collator.clone(), delegator_target.clone()) + verify { + + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000).unwrap().collator_reward, (1*DOLLAR).to_balance::()); + assert_eq!(RoundCollatorRewardInfo::::get(&collator, 1000).unwrap().delegator_rewards.len(), (<::MaxDelegatorsPerCandidate as Get>::get() - 1) as usize); + + } + + // Session Change + + // The session pallet's on initialize is called but should_end_session returns false + // This essentially just benhcmarks should_end_session + passive_session_change { + // Move on by a block + // Assuming we start at (say) 0, and that round is atleast 3 blocks. + + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + + assert_eq!(pallet_session::Pallet::::current_index() as u32, 0u32); + + assert!(! as pallet_session::ShouldEndSession<_>>::should_end_session(>::block_number())); + + }: { as frame_support::traits::Hooks<_>>::on_initialize(>::block_number());} + verify { + assert_eq!(pallet_session::Pallet::::current_index() as u32, 0u32); + } + + active_session_change { + + // liquidity tokens + let x in 3..100; + // candidate_count + let y in (<::MinSelectedCandidates as Get>::get() + 1u32)..(<::MaxCollatorCandidates as Get>::get() - 2u32); // to account for the two candidates we start with + // MaxDelegatorsPerCandidate + let z in 3..<::MaxDelegatorsPerCandidate as Get>::get(); + + // // Since now an aggregator can have multiple collators each of whose rewards will be written to the storage individually + // // Total selected + let w = <::MinSelectedCandidates as Get>::get() + 1u32; + + // // liquidity tokens + // let x = 100; + // // candidate_count + // let y = 190; + // // MaxDelegatorsPerCandidate + // let z = 200; + // // Total selected + // let w = 190; + + assert_ok!(>::finalize_tge(RawOrigin::Root.into())); + assert_ok!(>::init_issuance_config(RawOrigin::Root.into())); + assert_ok!(>::calculate_and_store_round_issuance(0u32)); + + assert_ok!(Pallet::::set_total_selected(RawOrigin::Root.into(), w)); + + // We will prepare `x-1` liquidity tokens in loop and then another after + + let start_liquidity_token = Pallet::::staking_liquidity_tokens(); + let start_liquidity_token_count: u32 = start_liquidity_token.len().try_into().unwrap(); + for (token,_) in start_liquidity_token { + // as PoolPromoteApi>::update_pool_promotion(token, Some(1)); + T::RewardsApi::enable(token, 1); + } + + assert!(x > start_liquidity_token_count); + // create X - 1 Tokens now and then remaining one + for i in start_liquidity_token_count..(x-1){ + let created_liquidity_token = create_staking_liquidity_for_funding::(Some(T::MinCandidateStk::get())).unwrap(); + Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), i).unwrap(); + // as PoolPromoteApi>::update_pool_promotion(created_liquidity_token, Some(1)); + T::RewardsApi::enable(created_liquidity_token, 1); + } + + // Now to prepare the liquidity token we will use for collator and delegators + let amount = ((z*(y+1)) as u128 * 100 * DOLLAR).to_balance::() + T::MinCandidateStk::get() * DOLLAR.to_balance::(); + let created_liquidity_token = create_staking_liquidity_for_funding::(Some(amount)).unwrap(); + assert_ok!(Pallet::::add_staking_liquidity_token(RawOrigin::Root.into(), PairedOrLiquidityToken::Liquidity(created_liquidity_token), x)); + // as PoolPromoteApi>::update_pool_promotion(created_liquidity_token, Some(1)); + T::RewardsApi::enable(created_liquidity_token, 1); + + + // Now we will create y funded collators + let initial_candidates: Vec = Pallet::::candidate_pool().0.into_iter().map(|x| x.owner).collect::<_>(); + let base_candidate_count: u32 = Pallet::::candidate_pool().0.len().try_into().unwrap(); + + assert_eq!(base_candidate_count, 2); + assert_eq!(x as usize , StakingLiquidityTokens::::get().len()); + + // let pool_rewards = pallet_issuance::PromotedPoolsRewardsV2::::get(); + // assert_eq!(pool_rewards.len(), x as usize); + + + let mut candidates = (0u32..y) + .map(|i|{ + create_funded_collator::( + "collator", + USER_SEED - i, + created_liquidity_token, + Some(T::MinCandidateStk::get()), + i + base_candidate_count, + x + ) + }).collect::, &'static str>>()?; + + // create one aggregator per candidate + for (id, c) in candidates.iter().enumerate() { + let aggregator: T::AccountId = account("aggregator", id as u32, 0); + assert_ok!(Pallet::::aggregator_update_metadata(RawOrigin::Signed( + aggregator.clone()).into(), + vec![c.clone()], + MetadataUpdateAction::ExtendApprovedCollators, + )); + + assert_ok!(Pallet::::update_candidate_aggregator(RawOrigin::Signed( + c.clone()).into(), + Some(aggregator.clone()), + )); + } + + assert_eq!(candidates.len(), y as usize); + // + // // Now we will create `z*y` delegators each with `100*DOLLAR` created_liquidity_token tokens + // + let delegators_count = z*y; + let delegators: Vec<_> = (0u32..delegators_count) + .map(|i| + create_funded_user::("delegator", USER_SEED-i, created_liquidity_token, Some((100*DOLLAR).to_balance::())) + ).map(|(account, _token_id, _amount)| account) + .collect(); + assert_eq!(delegators.len(), (z*y) as usize); + + for (delegators, candidate) in delegators.iter().chunks(z as usize).into_iter() + .zip(candidates.clone()) + { + + for (count, delegator) in delegators.into_iter().enumerate() { + Pallet::::delegate(RawOrigin::Signed( + delegator.clone()).into(), + candidate.clone().into(), + (100*DOLLAR).to_balance::(), + None, + count as u32, + 0u32, + ).unwrap(); + } + + assert_eq!(Pallet::::candidate_state(candidate.clone()).unwrap().delegators.0.len() , z as usize); + assert_eq!(Pallet::::candidate_state(candidate.clone()).unwrap().top_delegations.len() , z as usize); + assert_eq!(Pallet::::candidate_state(candidate.clone()).unwrap().bottom_delegations.len() , 0usize); + + } + + + // + // Remove the initial two collators so that they do not get selected + // We do this as the two collators do not have max delegators and would not be worst case + + for initial_candidate in initial_candidates{ + assert_ok!(Pallet::::go_offline(RawOrigin::Signed( + initial_candidate.clone()).into())); + } + + + + // We would like to move on to the end of round 4 + let session_to_reach = 4u32; + + // Moves to the end of the round + // Infinite loop that breaks when should_end_session is true + loop { + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + if Pallet::::round().current == session_to_reach { + for i in 0..2{ + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + } + break; + } + } + + let selected_author = Pallet::::selected_candidates(); + + + // We would like to move on to the end of round 1 + let session_to_reach = 5u32; + + // Moves to the end of the round 0 + // Infinite loop that breaks when should_end_session is true + loop { + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + if Pallet::::round().current == session_to_reach { + for i in 0..2{ + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + } + break; + } + } + + + assert_eq!(pallet_session::Pallet::::current_index() as u32, 5u32); + assert_eq!(Pallet::::round().current as u32, 5u32); + assert_eq!(selected_author.len(), (w as usize).min(Pallet::::candidate_pool().0.len() as usize)); + + + let candidate_pool_state = Pallet::::candidate_pool().0; + + for (i, candidate_bond) in candidate_pool_state.into_iter().enumerate() { + if candidate_bond.liquidity_token == created_liquidity_token { + assert_eq!(candidate_bond.amount.into(), (1+(z as u128)*100)*DOLLAR); + } + } + + for author in selected_author.clone() { + Pallet::::note_author(author.clone()); + } + + // We would like to move on to the end of round 1 + let end_of_session_to_reach = 6u32; + // let pool_rewards = pallet_issuance::PromotedPoolsRewardsV2::::get(); + // assert_eq!(pool_rewards.len(), x as usize); + + // Moves to the end of the round 0 + // Infinite loop that breaks when should_end_session is true + loop { + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_finalize(>::block_number()); + >::set_block_number(>::block_number() + 1u32.into()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + if as pallet_session::ShouldEndSession<_>>::should_end_session(>::block_number()) + && (Pallet::::round().current == end_of_session_to_reach) { + break; + } else { + as frame_support::traits::Hooks<_>>::on_initialize(>::block_number()); + } + } + + + assert_eq!(pallet_session::Pallet::::current_index() as u32, 6u32); + assert_eq!(Pallet::::round().current as u32, 6u32); + + assert!( as pallet_session::ShouldEndSession<_>>::should_end_session(>::block_number())); + + for author in selected_author.clone() { + for candidate in AggregatorMetadata::::get(&author).unwrap().token_collator_map.iter().map(|x| x.1){ + assert!(T::Currency::total_balance(MGA_TOKEN_ID.into(), &candidate).is_zero()); + } + } + + }: { as frame_support::traits::Hooks<_>>::on_initialize(>::block_number());} + verify { + assert_eq!(pallet_session::Pallet::::current_index() as u32, 7u32); + assert_eq!(Pallet::::round().current as u32, 7u32); + assert_eq!(w as usize, candidates.iter().filter_map(|c| RoundCollatorRewardInfo::::get(c.clone(), 5u32)).count()); + } + +} diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs new file mode 100644 index 0000000000..f4c4262a0e --- /dev/null +++ b/pallets/parachain-staking/src/lib.rs @@ -0,0 +1,3549 @@ +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! # Parachain Staking +//! Minimal staking pallet that implements collator selection by total backed stake. +//! The main difference between this pallet and `frame/pallet-staking` is that this pallet +//! uses direct delegation. Delegators choose exactly who they delegate and with what stake. +//! This is different from `frame/pallet-staking` where delegators approval vote and run Phragmen. +//! +//! ### Actors +//! There are multiple functions that can be distinguished: +//! - Collator Candidate - depending on managed stake can or can not bo chosen as collator +//! - Delegator - delegates to collator candidate, if that collator candidate will become +//! collator delegator is eligible for proportional part of the rewards that collator receives for +//! building blocks +//! - Aggregator - A collator candiate may choose to aggregate under an aggregator. If this aggregator +//! gets selected then he becomes an author/collator representing the collator candidates aggregating under him. +//! If a collator candidate does not choose to aggregate under an aggregator and gets selected, then he +//! himself becomes the author/collator. Any account that is not delegator or candidate can become +//! aggregator +//! +//! ### Rules +//! There is a new round every `>::get().length` blocks. +//! +//! At the start of every round, +//! * issuance is assigned to collators (and their delegators) for block authoring +//! `T::RewardPaymentDelay` rounds ago, afterwards it can be claimed using dedicated extrinsics +//! * queued collator and delegator exits are executed +//! * a new set of collators is chosen from the candidates +//! +//! To join the set of candidates, call `join_candidates` with `bond >= MinCandidateStk`. +//! To leave the set of candidates, call `schedule_leave_candidates`. If the call succeeds, +//! the collator is removed from the pool of candidates so they cannot be selected for future +//! collator sets, but they are not unbonded until their exit request is executed. Any signed +//! account may trigger the exit `T::LeaveCandidatesDelay` rounds after the round in which the +//! original request was made. +//! +//! To join the set of delegators, call `delegate` and pass in an account that is +//! already a collator candidate and `bond >= MinDelegatorStk`. Each delegator can delegate up to +//! `T::MaxDelegationsPerDelegator` collator candidates by calling `delegate`. +//! +//! To revoke a delegation, call `revoke_delegation` with the collator candidate's account. +//! To leave the set of delegators and revoke all delegations, call `leave_delegators`. +//! +//! +//! # Aggregation +//! Aggregation feature allows accumulating stake in different liquidity tokens under single aggregator account +//! by assosiating several candidates stake with that (aggregator) account. Each candidate needs to bond different +//! liquidity token +//! ```ignore +//! #################### +//! -------------# Aggregator A #------------- +//! | # # | +//! | #################### | +//! | | | +//! | | | +//! | | | +//! | | | +//! | | | +//! | | | +//! -------------------- -------------------- -------------------- +//! | Candidate B | | Candidate C | | Candidate D | +//! | token: MGX:TUR | | token: MGX:IMBU | | token: MGX:MOVR | +//! -------------------- -------------------- -------------------- +//! ``` +//! If candidate decides to aggregate under Aggregator it cannot be chosen to be collator(the +//! candidate), instead aggregator account can be selected (even though its not present on +//! candidates list). +//! +//! +//! Block authors selection algorithm details [`Pallet::select_top_candidates`] +//! +//!```ignore +//! candidate B MGX valuation +//! Candidate B rewards = ------------------------------------ * Aggregator A total staking rewards +//! candidate ( B + C + D) valuation +//!``` +//! +//! Extrinsics: +//! - [`Pallet::aggregator_update_metadata`] - enable/disable candidates for aggregation +//! - [`Pallet::update_candidate_aggregator`] - assign aggregator for candidate +//! +//! Storage entries: +//! - [`CandidateAggregator`] +//! - [`AggregatorMetadata`] +//! - [`RoundAggregatorInfo`] +//! - [`RoundCollatorRewardInfo`] +//! +//! ## Candidate selection mechanism +//! Aggregation feature modifies how collators are selected. Rules are as follows: +//! - Everything is valuated in `MGX` part of staked liquidity token. So if collator A has X MGX:KSM +//! liquidity tokens. And X MGX:KSM liquidity token is convertible to Y `MGX` and Z `KSM`. Then X +//! MGX:KSM tokens has valuation of Y. +//! - If candidate allows for staking native tokens number of native tokens/2 == candidate valuation. +//! - for aggregator(A) each aggregation account (such that aggregates under A) is valuated in MGX and +//! sumed. +//! - Candidates that aggregates under some other account cannot be selected as collators (but the +//! account they aggregate under can) +//! - Candidates with top MGX valuation are selected as collators +//! +//! # Manual payouts +//! Due to big cost of automatic rewards distribution (N transfers where N is total amount of all +//! rewarded collators & delegators) it was decided to switch to manual payouts mechanism. Instead +//! of automatically transferring all the rewards at the end session only rewards amount per account +//! is stored. Then collators & delegators can claim their rewards manually (after T::RewardPaymentDelay). +//! +//! Extrinsics: +//! - [`Pallet::payout_collator_rewards`] - supposed to be called by collator after every round. +//! - [`Pallet::payout_delegator_reward`] - backup solution for withdrawing rewards when collator +//! +//! Storage entries: +//! - [`RoundCollatorRewardInfo`] +//! +//! is not available. +//! +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(doc)] +use aquamarine::aquamarine; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod mock; +mod set; +#[cfg(test)] +#[cfg(not(feature = "runtime-benchmarks"))] +mod tests; + +use crate::set::OrderedSet; +use codec::{Decode, Encode}; +use frame_support::{ + pallet, + pallet_prelude::*, + traits::{ + tokens::currency::MultiTokenCurrency, EstimateNextSessionRotation, ExistenceRequirement, + Get, + }, + transactional, +}; +use frame_system::{pallet_prelude::*, RawOrigin}; +pub use mangata_support::traits::{ + ComputeIssuance, GetIssuance, PoolCreateApi, ProofOfStakeRewardsApi, + StakingReservesProviderTrait, Valuate, XykFunctionsTrait, +}; +pub use mangata_types::multipurpose_liquidity::BondKind; +use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; +use pallet_collective_mangata::GetMembers; +use scale_info::TypeInfo; +use sp_arithmetic::per_things::Rounding; +use sp_runtime::{ + helpers_128bit::multiply_by_rational_with_rounding, + traits::{ + Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, One, SaturatedConversion, + Saturating, Zero, + }, + Perbill, Permill, RuntimeDebug, +}; +use sp_staking::SessionIndex; +use sp_std::{ + cmp::Ordering, + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + convert::TryInto, + prelude::*, +}; + +pub use pallet::*; + +pub mod weights; +pub use weights::WeightInfo; + +trait FromInfiniteZeros { + type Output; + fn from_zeros() -> Self::Output; +} + +impl FromInfiniteZeros for D { + type Output = D; + fn from_zeros() -> Self::Output { + D::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap() + } +} + +#[derive(Eq, PartialEq, Encode, Decode, TypeInfo, Debug, Clone)] +pub enum MetadataUpdateAction { + ExtendApprovedCollators, + RemoveApprovedCollators, +} + +#[derive(Eq, PartialEq, Debug, Clone)] +pub enum RewardKind { + Collator, + Delegator(AccountId), +} + +#[derive(Eq, PartialEq, Encode, Decode, TypeInfo, Debug, Clone)] +pub enum PayoutRounds { + All, + Partial(Vec), +} + +#[pallet] +pub mod pallet { + pub use super::*; + + /// Pallet for parachain staking + #[pallet::pallet] + #[pallet::without_storage_info] + pub struct Pallet(PhantomData); + + #[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] + pub enum PairedOrLiquidityToken { + Paired(CurrencyId), + Liquidity(CurrencyId), + } + + #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] + pub struct Bond { + pub owner: AccountId, + pub amount: Balance, + pub liquidity_token: CurrencyId, + } + + impl Default for Bond { + fn default() -> Bond { + Bond { + owner: A::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"), + amount: B::default(), + liquidity_token: C::default(), + } + } + } + + impl Bond { + pub fn from_owner(owner: A) -> Self { + Bond { owner, amount: B::default(), liquidity_token: C::default() } + } + } + + impl Eq for Bond {} + + impl Ord for Bond { + fn cmp(&self, other: &Self) -> Ordering { + self.owner.cmp(&other.owner) + } + } + + impl PartialOrd for Bond { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + } + + impl PartialEq for Bond { + fn eq(&self, other: &Self) -> bool { + self.owner == other.owner + } + } + + #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] + /// The activity status of the collator + pub enum CollatorStatus { + /// Committed to be online and producing valid blocks (not equivocating) + Active, + /// Temporarily inactive and excused for inactivity + Idle, + /// Bonded until the inner round + Leaving(RoundIndex), + } + + impl Default for CollatorStatus { + fn default() -> CollatorStatus { + CollatorStatus::Active + } + } + + #[derive(Encode, Decode, RuntimeDebug, TypeInfo)] + /// Snapshot of collator state at the start of the round for which they are selected + pub struct CollatorSnapshot { + pub bond: Balance, + pub delegations: Vec>, + pub total: Balance, + pub liquidity_token: CurrencyId, + } + + impl Default + for CollatorSnapshot + { + fn default() -> CollatorSnapshot { + Self { + delegations: Default::default(), + bond: Default::default(), + total: Default::default(), + liquidity_token: Default::default(), + } + } + } + + #[derive(PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Changes allowed by an active collator candidate to their self bond + pub enum CandidateBondChange { + Increase, + Decrease, + } + + #[derive(PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Request scheduled to change the collator candidate self-bond + pub struct CandidateBondRequest { + pub amount: Balance, + pub change: CandidateBondChange, + pub when_executable: RoundIndex, + } + + #[derive(Encode, Decode, RuntimeDebug, TypeInfo)] + /// Collator candidate state with self bond + delegations + pub struct CollatorCandidate { + /// The account of this collator + pub id: AccountId, + /// This collator's self stake. + pub bond: Balance, + /// This is the liquidity_token the collator uses + pub liquidity_token: CurrencyId, + /// Set of all delegator AccountIds (to prevent >1 delegation per AccountId) + pub delegators: OrderedSet, + /// Top T::MaxDelegatorsPerCollator::get() delegations, ordered greatest to least + pub top_delegations: Vec>, + /// Bottom delegations (unbounded), ordered least to greatest + pub bottom_delegations: Vec>, + /// Sum of top delegations + self.bond + pub total_counted: Balance, + /// Sum of all delegations + self.bond = (total_counted + uncounted) + pub total_backing: Balance, + /// Maximum 1 pending request to adjust candidate self bond at any given time + pub request: Option>, + /// Current status of the collator + pub state: CollatorStatus, + } + + /// Convey relevant information describing if a delegator was added to the top or bottom + /// Delegations added to the top yield a new total + #[derive(Clone, Copy, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub enum DelegatorAdded { + AddedToTop { new_total: Balance }, + AddedToBottom, + } + + impl CollatorCandidate + where + A: Ord + Clone + sp_std::fmt::Debug, + Balance: Default + PartialOrd + CheckedAdd + CheckedSub + Saturating + Ord + Copy, + CurrencyId: Copy, + { + pub fn new(id: A, bond: Balance, liquidity_token: CurrencyId) -> Self { + CollatorCandidate { + id, + bond, + liquidity_token, + delegators: OrderedSet::new(), + top_delegations: Vec::new(), + bottom_delegations: Vec::new(), + total_counted: bond, + total_backing: bond, + request: None, + state: CollatorStatus::default(), // default active + } + } + pub fn is_active(&self) -> bool { + self.state == CollatorStatus::Active + } + pub fn is_leaving(&self) -> bool { + matches!(self.state, CollatorStatus::Leaving(_)) + } + pub fn can_leave(&self) -> DispatchResult { + if let CollatorStatus::Leaving(when) = self.state { + ensure!(>::get().current >= when, Error::::CandidateCannotLeaveYet); + Ok(()) + } else { + Err(Error::::CandidateNotLeaving.into()) + } + } + /// Schedule executable increase of collator candidate self bond + /// Returns the round at which the collator can execute the pending request + pub fn schedule_bond_more( + &mut self, + more: Balance, + use_balance_from: Option, + ) -> Result + where + T::AccountId: From, + BalanceOf: From, + CurrencyIdOf: From, + { + // ensure no pending request + ensure!(self.request.is_none(), Error::::PendingCandidateRequestAlreadyExists); + let candidate_id: T::AccountId = self.id.clone().into(); + ensure!( + ::StakingReservesProvider::can_bond( + self.liquidity_token.into(), + &candidate_id, + more.into(), + use_balance_from + ), + Error::::InsufficientBalance + ); + let when_executable = + >::get().current.saturating_add(T::CandidateBondDelay::get()); + self.request = Some(CandidateBondRequest { + change: CandidateBondChange::Increase, + amount: more, + when_executable, + }); + Ok(when_executable) + } + /// Schedule executable decrease of collator candidate self bond + /// Returns the round at which the collator can execute the pending request + pub fn schedule_bond_less( + &mut self, + less: Balance, + ) -> Result + where + BalanceOf: From, + CurrencyIdOf: From, + { + // ensure no pending request + ensure!(self.request.is_none(), Error::::PendingCandidateRequestAlreadyExists); + // ensure bond above min after decrease + ensure!(self.bond > less, Error::::CandidateBondBelowMin); + + let bond_valution_after = Pallet::::valuate_bond( + self.liquidity_token.into(), + self.bond.checked_sub(&less).unwrap_or_default().into(), + ); + ensure!( + bond_valution_after >= T::MinCandidateStk::get(), + Error::::CandidateBondBelowMin + ); + let when_executable = + >::get().current.saturating_add(T::CandidateBondDelay::get()); + self.request = Some(CandidateBondRequest { + change: CandidateBondChange::Decrease, + amount: less, + when_executable, + }); + Ok(when_executable) + } + /// Execute pending request to change the collator self bond + /// Returns the event to be emitted + pub fn execute_pending_request( + &mut self, + use_balance_from: Option, + ) -> Result, DispatchError> + where + T::AccountId: From, + BalanceOf: From, + CurrencyIdOf: From, + { + let request = self.request.ok_or(Error::::PendingCandidateRequestsDNE)?; + ensure!( + request.when_executable <= >::get().current, + Error::::PendingCandidateRequestNotDueYet + ); + let caller: T::AccountId = self.id.clone().into(); + let event = match request.change { + CandidateBondChange::Increase => { + self.bond = + self.bond.checked_add(&request.amount).ok_or(Error::::MathError)?; + + self.total_counted = self + .total_counted + .checked_add(&request.amount) + .ok_or(Error::::MathError)?; + self.total_backing = self + .total_backing + .checked_add(&request.amount) + .ok_or(Error::::MathError)?; + ::StakingReservesProvider::bond( + self.liquidity_token.into(), + &caller, + request.amount.into(), + use_balance_from, + )?; + let currency: CurrencyIdOf = self.liquidity_token.into(); + let new_total = >::get(currency).saturating_add(request.amount.into()); + >::insert(currency, new_total); + Event::CandidateBondedMore( + self.id.clone().into(), + request.amount.into(), + self.bond.into(), + ) + }, + CandidateBondChange::Decrease => { + // Arithmetic assumptions are self.bond > less && self.bond - less > CollatorMinBond + // (assumptions enforced by `schedule_bond_less`; if storage corrupts, must re-verify) + self.bond = + self.bond.checked_sub(&request.amount).ok_or(Error::::MathError)?; + + self.total_counted = self + .total_counted + .checked_sub(&request.amount) + .ok_or(Error::::MathError)?; + self.total_backing = self + .total_backing + .checked_sub(&request.amount) + .ok_or(Error::::MathError)?; + let debug_amount = ::StakingReservesProvider::unbond( + self.liquidity_token.into(), + &caller, + request.amount.into(), + ); + if !debug_amount.is_zero() { + log::warn!("Unbond in staking returned non-zero value {:?}", debug_amount); + } + let currency: CurrencyIdOf = self.liquidity_token.into(); + let new_total_staked = + >::get(currency).saturating_sub(request.amount.into()); + >::insert(currency, new_total_staked); + Event::CandidateBondedLess( + self.id.clone().into(), + request.amount.into(), + self.bond.into(), + ) + }, + }; + // reset s.t. no pending request + self.request = None; + // update candidate pool value because it must change if self bond changes + if self.is_active() { + Pallet::::update_active( + self.id.clone().into(), + self.total_counted.into(), + self.liquidity_token.into(), + ); + } + Ok(event) + } + /// Cancel pending request to change the collator self bond + pub fn cancel_pending_request(&mut self) -> Result, DispatchError> + where + T::AccountId: From, + CandidateBondRequest>: From>, + { + let request = self.request.ok_or(Error::::PendingCandidateRequestsDNE)?; + let event = Event::CancelledCandidateBondChange(self.id.clone().into(), request.into()); + self.request = None; + Ok(event) + } + /// Infallible sorted insertion + /// caller must verify !self.delegators.contains(delegation.owner) before call + pub fn add_top_delegation(&mut self, delegation: Bond) { + match self.top_delegations.binary_search_by(|x| delegation.amount.cmp(&x.amount)) { + Ok(i) => self.top_delegations.insert(i, delegation), + Err(i) => self.top_delegations.insert(i, delegation), + } + } + /// Infallible sorted insertion + /// caller must verify !self.delegators.contains(delegation.owner) before call + pub fn add_bottom_delegation(&mut self, delegation: Bond) { + match self.bottom_delegations.binary_search_by(|x| x.amount.cmp(&delegation.amount)) { + Ok(i) => self.bottom_delegations.insert(i, delegation), + Err(i) => self.bottom_delegations.insert(i, delegation), + } + } + /// Sort top delegations from greatest to least + pub fn sort_top_delegations(&mut self) { + self.top_delegations.sort_unstable_by(|a, b| b.amount.cmp(&a.amount)); + } + /// Sort bottom delegations from least to greatest + pub fn sort_bottom_delegations(&mut self) { + self.bottom_delegations.sort_unstable_by(|a, b| a.amount.cmp(&b.amount)); + } + /// Bond account and add delegation. If successful, the return value indicates whether the + /// delegation is top for the candidate. + pub fn add_delegation( + &mut self, + acc: A, + amount: Balance, + ) -> Result>, DispatchError> + where + BalanceOf: From, + { + ensure!(self.delegators.insert(acc.clone()), Error::::DelegatorExists); + self.total_backing = + self.total_backing.checked_add(&amount).ok_or(Error::::MathError)?; + if (self.top_delegations.len() as u32) < T::MaxDelegatorsPerCandidate::get() { + self.add_top_delegation(Bond { + owner: acc, + amount, + liquidity_token: self.liquidity_token, + }); + self.total_counted = + self.total_counted.checked_add(&amount).ok_or(Error::::MathError)?; + Ok(DelegatorAdded::AddedToTop { new_total: self.total_counted.into() }) + } else { + // >pop requires push to reset in case isn't pushed to bottom + let last_delegation_in_top = self + .top_delegations + .pop() + .expect("self.top_delegations.len() >= T::Max exists >= 1 element in top"); + if amount > last_delegation_in_top.amount { + // update total_counted with positive difference + self.total_counted = self + .total_counted + .checked_add( + &amount + .checked_sub(&last_delegation_in_top.amount.into()) + .ok_or(Error::::MathError)?, + ) + .ok_or(Error::::MathError)?; + // last delegation already popped from top_delegations + // insert new delegation into top_delegations + self.add_top_delegation(Bond { + owner: acc, + amount, + liquidity_token: self.liquidity_token, + }); + self.add_bottom_delegation(last_delegation_in_top); + Ok(DelegatorAdded::AddedToTop { new_total: self.total_counted.into() }) + } else { + // >required push to previously popped last delegation into top_delegations + self.top_delegations.push(last_delegation_in_top); + self.add_bottom_delegation(Bond { + owner: acc, + amount, + liquidity_token: self.liquidity_token, + }); + Ok(DelegatorAdded::AddedToBottom) + } + } + } + /// Return Ok((if_total_counted_changed, delegation_amount)) + pub fn rm_delegator( + &mut self, + delegator: A, + ) -> Result<(bool, Balance), DispatchError> { + ensure!(self.delegators.remove(&delegator), Error::::DelegatorDNEInDelegatorSet); + let mut delegation_amt: Option = None; + self.top_delegations = self + .top_delegations + .clone() + .into_iter() + .filter_map(|d| { + if d.owner != delegator { + Some(d) + } else { + delegation_amt = Some(d.amount); + None + } + }) + .collect(); + // item removed from the top => highest bottom is popped from bottom and pushed to top + if let Some(amount) = delegation_amt { + // last element has largest amount as per ordering + if let Some(last) = self.bottom_delegations.pop() { + self.total_counted = self + .total_counted + .checked_sub( + &amount.checked_sub(&last.amount).ok_or(Error::::MathError)?, + ) + .ok_or(Error::::MathError)?; + self.add_top_delegation(last); + } else { + // no item in bottom delegations so no item from bottom to pop and push up + self.total_counted = + self.total_counted.checked_sub(&amount).ok_or(Error::::MathError)?; + } + self.total_backing = + self.total_backing.checked_sub(&amount).ok_or(Error::::MathError)?; + return Ok((true, amount)) + } + // else (no item removed from the top) + self.bottom_delegations = self + .bottom_delegations + .clone() + .into_iter() + .filter_map(|d| { + if d.owner != delegator { + Some(d) + } else { + delegation_amt = Some(d.amount); + None + } + }) + .collect(); + // if err, no item with account exists in top || bottom + let amount = delegation_amt.ok_or(Error::::DelegatorDNEinTopNorBottom)?; + self.total_backing = + self.total_backing.checked_sub(&amount).ok_or(Error::::MathError)?; + Ok((false, amount)) + } + /// Return true if in_top after call + /// Caller must verify before call that account is a delegator + fn increase_delegation( + &mut self, + delegator: A, + more: Balance, + ) -> Result { + let mut in_top = false; + for x in &mut self.top_delegations { + if x.owner == delegator { + x.amount = x.amount.checked_add(&more).ok_or(Error::::MathError)?; + self.total_counted = + self.total_counted.checked_add(&more).ok_or(Error::::MathError)?; + self.total_backing = + self.total_backing.checked_add(&more).ok_or(Error::::MathError)?; + in_top = true; + break + } + } + // if delegator was increased in top delegations + if in_top { + self.sort_top_delegations(); + return Ok(true) + } + // else delegator to increase must exist in bottom + // >pop requires push later on to reset in case it isn't used + let lowest_top = self + .top_delegations + .pop() + .expect("any bottom delegations => must exist max top delegations"); + let mut move_2_top = false; + for x in &mut self.bottom_delegations { + if x.owner == delegator { + x.amount = x.amount.checked_add(&more).ok_or(Error::::MathError)?; + self.total_backing = + self.total_backing.checked_add(&more).ok_or(Error::::MathError)?; + move_2_top = x.amount > lowest_top.amount; + break + } + } + if move_2_top { + self.sort_bottom_delegations(); + let highest_bottom = self.bottom_delegations.pop().expect("updated => exists"); + self.total_counted = self + .total_counted + .checked_add( + &highest_bottom + .amount + .checked_sub(&lowest_top.amount) + .ok_or(Error::::MathError)?, + ) + .ok_or(Error::::MathError)?; + self.add_top_delegation(highest_bottom); + self.add_bottom_delegation(lowest_top); + Ok(true) + } else { + // >required push to reset top_delegations from earlier pop + self.top_delegations.push(lowest_top); + self.sort_bottom_delegations(); + Ok(false) + } + } + /// Return true if in_top after call + pub fn decrease_delegation( + &mut self, + delegator: A, + less: Balance, + ) -> Result { + let mut in_top = false; + let mut new_lowest_top: Option> = None; + for x in &mut self.top_delegations { + if x.owner == delegator { + x.amount = x.amount.checked_sub(&less).ok_or(Error::::MathError)?; + // if there is at least 1 delegator in bottom delegators, compare it to check + // if it should be swapped with lowest top delegation and put in top + // >pop requires push later on to reset in case it isn't used + if let Some(highest_bottom) = self.bottom_delegations.pop() { + if highest_bottom.amount > x.amount { + new_lowest_top = Some(highest_bottom); + } else { + // >required push to reset self.bottom_delegations + self.bottom_delegations.push(highest_bottom); + } + } + in_top = true; + break + } + } + if in_top { + self.sort_top_delegations(); + if let Some(highest_bottom) = new_lowest_top { + // pop last in top to swap it with top bottom + let lowest_top = self + .top_delegations + .pop() + .expect("must have >1 item to update, assign in_top = true"); + self.total_counted = self + .total_counted + .checked_sub( + &lowest_top.amount.checked_add(&less).ok_or(Error::::MathError)?, + ) + .ok_or(Error::::MathError)?; + self.total_counted = self + .total_counted + .checked_add(&highest_bottom.amount) + .ok_or(Error::::MathError)?; + self.total_backing = + self.total_backing.checked_sub(&less).ok_or(Error::::MathError)?; + self.add_top_delegation(highest_bottom); + self.add_bottom_delegation(lowest_top); + return Ok(false) + } else { + // no existing bottom delegators so update both counters the same magnitude + self.total_counted = + self.total_counted.checked_sub(&less).ok_or(Error::::MathError)?; + self.total_backing = + self.total_backing.checked_sub(&less).ok_or(Error::::MathError)?; + return Ok(true) + } + } + for x in &mut self.bottom_delegations { + if x.owner == delegator { + x.amount = x.amount.checked_sub(&less).ok_or(Error::::MathError)?; + self.total_backing = + self.total_backing.checked_sub(&less).ok_or(Error::::MathError)?; + break + } + } + self.sort_bottom_delegations(); + Ok(false) + } + pub fn go_offline(&mut self) { + self.state = CollatorStatus::Idle; + } + pub fn go_online(&mut self) { + self.state = CollatorStatus::Active; + } + pub fn leave(&mut self) -> Result<(RoundIndex, RoundIndex), DispatchError> { + ensure!(!self.is_leaving(), Error::::CandidateAlreadyLeaving); + let now = >::get().current; + let when = now.saturating_add(T::LeaveCandidatesDelay::get()); + self.state = CollatorStatus::Leaving(when); + Ok((now, when)) + } + } + + impl From> + for CollatorSnapshot + { + fn from( + other: CollatorCandidate, + ) -> CollatorSnapshot { + CollatorSnapshot { + bond: other.bond, + delegations: other.top_delegations, + total: other.total_counted, + liquidity_token: other.liquidity_token, + } + } + } + + #[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub enum DelegatorStatus { + /// Active with no scheduled exit + Active, + /// Schedule exit to revoke all ongoing delegations + Leaving(RoundIndex), + } + + impl Default for DelegatorStatus { + fn default() -> DelegatorStatus { + DelegatorStatus::Active + } + } + + #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Delegator state + pub struct Delegator { + /// Delegator account + pub id: AccountId, + /// All current delegations + pub delegations: OrderedSet>, + /// Requests to change delegations, relevant iff active + pub requests: PendingDelegationRequests, + /// Status for this delegator + pub status: DelegatorStatus, + } + + impl Default + for Delegator + { + fn default() -> Self { + Self { + id: AccountId::from_zeros(), + delegations: Default::default(), + requests: Default::default(), + status: Default::default(), + } + } + } + + impl Delegator + where + A: Ord + Clone, + Balance: Ord + Copy + Saturating + CheckedAdd + CheckedSub, + CurrencyId: Copy, + { + pub fn new(id: A, collator: A, amount: Balance, liquidity_token: CurrencyId) -> Self { + Delegator { + id, + delegations: OrderedSet::from(vec![Bond { + owner: collator, + amount, + liquidity_token, + }]), + requests: PendingDelegationRequests::new(), + status: DelegatorStatus::Active, + } + } + + pub fn requests(&self) -> BTreeMap> { + self.requests.requests.clone() + } + + pub fn is_active(&self) -> bool { + matches!(self.status, DelegatorStatus::Active) + } + + pub fn is_leaving(&self) -> bool { + matches!(self.status, DelegatorStatus::Leaving(_)) + } + + /// Can only leave if the current round is less than or equal to scheduled execution round + /// - returns None if not in leaving state + pub fn can_execute_leave(&self, delegation_weight_hint: u32) -> DispatchResult { + ensure!( + delegation_weight_hint >= (self.delegations.0.len() as u32), + Error::::TooLowDelegationCountToLeaveDelegators + ); + if let DelegatorStatus::Leaving(when) = self.status { + ensure!(>::get().current >= when, Error::::DelegatorCannotLeaveYet); + Ok(()) + } else { + Err(Error::::DelegatorNotLeaving.into()) + } + } + + /// Set status to leaving + pub(crate) fn set_leaving(&mut self, when: RoundIndex) { + self.status = DelegatorStatus::Leaving(when); + } + + /// Schedule status to exit + pub fn schedule_leave(&mut self) -> (RoundIndex, RoundIndex) { + let now = >::get().current; + let when = now.saturating_add(T::LeaveDelegatorsDelay::get()); + self.set_leaving(when); + (now, when) + } + + /// Set delegator status to active + pub fn cancel_leave(&mut self) { + self.status = DelegatorStatus::Active + } + + pub fn add_delegation(&mut self, bond: Bond) -> bool { + if self.delegations.insert(bond) { + true + } else { + false + } + } + + // Return Some(remaining balance), must be more than MinDelegatorStk + // Return None if delegation not found + pub fn rm_delegation(&mut self, collator: A) -> Option { + let mut amt: Option = None; + let delegations = self + .delegations + .0 + .iter() + .filter_map(|x| { + if x.owner == collator { + amt = Some(x.amount); + None + } else { + Some(x.clone()) + } + }) + .collect(); + if let Some(_) = amt { + self.delegations = OrderedSet::from(delegations); + Some(self.delegations.0.len()) + } else { + None + } + } + + /// Schedule increase delegation + pub fn schedule_increase_delegation( + &mut self, + collator: A, + more: Balance, + use_balance_from: Option, + ) -> Result + where + T::AccountId: From, + BalanceOf: From, + CurrencyIdOf: From, + { + let Bond { liquidity_token, .. } = self + .delegations + .0 + .iter() + .find(|b| b.owner == collator) + .ok_or(Error::::DelegationDNE)?; + let delegator_id: T::AccountId = self.id.clone().into(); + ensure!( + ::StakingReservesProvider::can_bond( + (*liquidity_token).into(), + &delegator_id, + more.into(), + use_balance_from + ), + Error::::InsufficientBalance + ); + let when = >::get().current.saturating_add(T::DelegationBondDelay::get()); + self.requests.bond_more::(collator, more, when)?; + Ok(when) + } + + /// Schedule decrease delegation + pub fn schedule_decrease_delegation( + &mut self, + collator: A, + less: Balance, + ) -> Result + where + BalanceOf: Into, + { + // get delegation amount + let Bond { amount, .. } = self + .delegations + .0 + .iter() + .find(|b| b.owner == collator) + .ok_or(Error::::DelegationDNE)?; + ensure!( + *amount >= T::MinDelegation::get().into().saturating_add(less), + Error::::DelegationBelowMin + ); + let when = >::get().current.saturating_add(T::DelegationBondDelay::get()); + self.requests.bond_less::(collator, less, when)?; + Ok(when) + } + + /// Schedule revocation for the given collator + pub fn schedule_revoke( + &mut self, + collator: A, + ) -> Result<(RoundIndex, RoundIndex), DispatchError> { + // get delegation amount + let Bond { amount, .. } = self + .delegations + .0 + .iter() + .find(|b| b.owner == collator) + .ok_or(Error::::DelegationDNE)?; + let now = >::get().current; + let when = now.saturating_add(T::RevokeDelegationDelay::get()); + // add revocation to pending requests + self.requests.revoke::(collator, *amount, when)?; + Ok((now, when)) + } + + /// Execute pending delegation change request + pub fn execute_pending_request( + &mut self, + candidate: A, + use_balance_from: Option, + ) -> DispatchResult + where + T::AccountId: From, + BalanceOf: From + Into, + CurrencyIdOf: From, + Delegator, CurrencyIdOf>: + From>, + { + let now = >::get().current; + let DelegationRequest { amount, action, when_executable, .. } = self + .requests + .requests + .remove(&candidate) + .ok_or(Error::::PendingDelegationRequestDNE)?; + ensure!(when_executable <= now, Error::::PendingDelegationRequestNotDueYet); + let (balance_amt, candidate_id, delegator_id): (Balance, T::AccountId, T::AccountId) = + (amount.into(), candidate.clone().into(), self.id.clone().into()); + match action { + DelegationChange::Revoke => { + // revoking last delegation => leaving set of delegators + let leaving = if self.delegations.0.len() == 1usize { true } else { false }; + // remove delegation from delegator state + self.rm_delegation(candidate.clone()); + // remove delegation from collator state delegations + Pallet::::delegator_leaves_collator( + delegator_id.clone(), + candidate_id.clone(), + )?; + Pallet::::deposit_event(Event::DelegationRevoked( + delegator_id.clone(), + candidate_id, + balance_amt.into(), + )); + if leaving { + >::remove(&delegator_id); + Pallet::::deposit_event(Event::DelegatorLeft( + delegator_id, + balance_amt.into(), + )); + } else { + let nom_st: Delegator, CurrencyIdOf> = + self.clone().into(); + >::insert(&delegator_id, nom_st); + } + Ok(()) + }, + DelegationChange::Increase => { + // increase delegation + for x in &mut self.delegations.0 { + if x.owner == candidate { + x.amount = + x.amount.checked_add(&amount).ok_or(Error::::MathError)?; + // update collator state delegation + let mut collator_state = >::get(&candidate_id) + .ok_or(Error::::CandidateDNE)?; + ::StakingReservesProvider::bond( + x.liquidity_token.into(), + &self.id.clone().into(), + balance_amt.into(), + use_balance_from, + )?; + let before = collator_state.total_counted; + let in_top = collator_state.increase_delegation::( + self.id.clone().into(), + balance_amt.into(), + )?; + let after = collator_state.total_counted; + if collator_state.is_active() && (before != after) { + Pallet::::update_active( + candidate_id.clone(), + after, + collator_state.liquidity_token, + ); + } + let new_total_staked = >::get(collator_state.liquidity_token) + .saturating_add(balance_amt.into()); + >::insert(collator_state.liquidity_token, new_total_staked); + >::insert(&candidate_id, collator_state); + let nom_st: Delegator, CurrencyIdOf> = + self.clone().into(); + >::insert(&delegator_id, nom_st); + Pallet::::deposit_event(Event::DelegationIncreased( + delegator_id, + candidate_id, + balance_amt.into(), + in_top, + )); + return Ok(()) + } + } + Err(Error::::DelegationDNE.into()) + }, + DelegationChange::Decrease => { + // decrease delegation + for x in &mut self.delegations.0 { + if x.owner == candidate { + if x.amount > amount.saturating_add(T::MinDelegation::get().into()) { + x.amount = + x.amount.checked_sub(&amount).ok_or(Error::::MathError)?; + let mut collator = >::get(&candidate_id) + .ok_or(Error::::CandidateDNE)?; + let debug_amount = + ::StakingReservesProvider::unbond( + x.liquidity_token.into(), + &delegator_id, + balance_amt.into(), + ); + if !debug_amount.is_zero() { + log::warn!( + "Unbond in staking returned non-zero value {:?}", + debug_amount + ); + } + let before = collator.total_counted; + // need to go into decrease_delegation + let in_top = collator.decrease_delegation::( + delegator_id.clone(), + balance_amt.into(), + )?; + let after = collator.total_counted; + if collator.is_active() && (before != after) { + Pallet::::update_active( + candidate_id.clone(), + after, + collator.liquidity_token, + ); + } + let new_total_staked = >::get(collator.liquidity_token) + .saturating_sub(balance_amt.into()); + >::insert(collator.liquidity_token, new_total_staked); + >::insert(&candidate_id, collator); + let nom_st: Delegator, CurrencyIdOf> = + self.clone().into(); + >::insert(&delegator_id, nom_st); + Pallet::::deposit_event(Event::DelegationDecreased( + delegator_id, + candidate_id, + balance_amt.into(), + in_top, + )); + return Ok(()) + } else { + // must rm entire delegation if x.amount <= less or cancel request + return Err(Error::::DelegationBelowMin.into()) + } + } + } + Err(Error::::DelegationDNE.into()) + }, + } + } + + /// Cancel pending delegation change request + pub fn cancel_pending_request( + &mut self, + candidate: A, + ) -> Result, DispatchError> { + let order = self + .requests + .requests + .remove(&candidate) + .ok_or(Error::::PendingDelegationRequestDNE)?; + Ok(order) + } + } + + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Changes requested by the delegator + /// - limit of 1 ongoing change per delegation + /// - no changes allowed if delegator is leaving + pub enum DelegationChange { + Revoke, + Increase, + Decrease, + } + + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub struct DelegationRequest { + pub collator: AccountId, + pub amount: Balance, + pub when_executable: RoundIndex, + pub action: DelegationChange, + } + + #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Pending requests to mutate delegations for each delegator + pub struct PendingDelegationRequests { + /// Map from collator -> Request (enforces at most 1 pending request per delegation) + pub requests: BTreeMap>, + } + + impl Default for PendingDelegationRequests { + fn default() -> PendingDelegationRequests { + PendingDelegationRequests { requests: BTreeMap::new() } + } + } + + impl PendingDelegationRequests { + /// New default (empty) pending requests + pub fn new() -> PendingDelegationRequests { + PendingDelegationRequests::default() + } + /// Add bond more order to pending requests + pub fn bond_more( + &mut self, + collator: A, + amount: Balance, + when_executable: RoundIndex, + ) -> DispatchResult { + ensure!( + self.requests.get(&collator).is_none(), + Error::::PendingDelegationRequestAlreadyExists + ); + self.requests.insert( + collator.clone(), + DelegationRequest { + collator, + amount, + when_executable, + action: DelegationChange::Increase, + }, + ); + Ok(()) + } + /// Add bond less order to pending requests, only succeeds if returns true + /// - limit is the maximum amount allowed that can be subtracted from the delegation + /// before it would be below the minimum delegation amount + pub fn bond_less( + &mut self, + collator: A, + amount: Balance, + when_executable: RoundIndex, + ) -> DispatchResult { + ensure!( + self.requests.get(&collator).is_none(), + Error::::PendingDelegationRequestAlreadyExists + ); + self.requests.insert( + collator.clone(), + DelegationRequest { + collator, + amount, + when_executable, + action: DelegationChange::Decrease, + }, + ); + Ok(()) + } + /// Add revoke order to pending requests + /// - limit is the maximum amount allowed that can be subtracted from the delegation + /// before it would be below the minimum delegation amount + pub fn revoke( + &mut self, + collator: A, + amount: Balance, + when_executable: RoundIndex, + ) -> DispatchResult { + ensure!( + self.requests.get(&collator).is_none(), + Error::::PendingDelegationRequestAlreadyExists + ); + self.requests.insert( + collator.clone(), + DelegationRequest { + collator, + amount, + when_executable, + action: DelegationChange::Revoke, + }, + ); + Ok(()) + } + } + + #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] + /// The current round index and transition information + pub struct RoundInfo { + /// Current round index + pub current: RoundIndex, + /// The first block of the current round + pub first: BlockNumber, + /// The length of the current round in number of blocks + pub length: u32, + } + impl< + B: Copy + + sp_std::ops::Add + + sp_std::ops::Sub + + From + + PartialOrd + + One + + Zero + + Saturating + + CheckedMul, + > RoundInfo + { + pub fn new(current: RoundIndex, first: B, length: u32) -> RoundInfo { + RoundInfo { current, first, length } + } + /// Check if the round should be updated + pub fn should_update(&self, now: B) -> bool { + now.saturating_add(One::one()) >= self.first.saturating_add(self.length.into()) + } + /// New round + pub fn update(&mut self, now: B) { + self.current = self.current.saturating_add(1u32); + self.first = now; + } + } + impl< + B: Copy + + sp_std::ops::Add + + sp_std::ops::Sub + + From + + PartialOrd + + One + + Zero + + Saturating + + CheckedMul, + > Default for RoundInfo + { + fn default() -> RoundInfo { + RoundInfo::new(0u32, Zero::zero(), 20u32) + } + } + + pub(crate) type RoundIndex = u32; + type RewardPoint = u32; + + #[cfg(feature = "runtime-benchmarks")] + pub trait StakingBenchmarkConfig: pallet_session::Config + pallet_issuance::Config { + type Balance; + type CurrencyId; + type RewardsApi: ProofOfStakeRewardsApi; + type Xyk: XykFunctionsTrait; + } + + #[cfg(not(feature = "runtime-benchmarks"))] + pub trait StakingBenchmarkConfig {} + + pub type BalanceOf = <::Currency as MultiTokenCurrency< + ::AccountId, + >>::Balance; + + pub type CurrencyIdOf = <::Currency as MultiTokenCurrency< + ::AccountId, + >>::CurrencyId; + + /// Configuration trait of this pallet. + #[pallet::config] + pub trait Config: frame_system::Config + StakingBenchmarkConfig { + /// Overarching event type + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// Multipurpose-liquidity + type StakingReservesProvider: StakingReservesProviderTrait< + Self::AccountId, + BalanceOf, + CurrencyIdOf, + >; + /// The currency type + type Currency: MultiTokenCurrency + + MultiTokenReservableCurrency + + MultiTokenCurrencyExtended; + /// The origin for monetary governance + type MonetaryGovernanceOrigin: EnsureOrigin; + /// Default number of blocks per round at genesis + #[pallet::constant] + type BlocksPerRound: Get; + /// Number of rounds that candidates remain bonded before exit request is executable + #[pallet::constant] + type LeaveCandidatesDelay: Get; + /// Number of rounds that candidate requests to adjust self-bond must wait to be executable + #[pallet::constant] + type CandidateBondDelay: Get; + /// Number of rounds that delegators remain bonded before exit request is executable + #[pallet::constant] + type LeaveDelegatorsDelay: Get; + /// Number of rounds that delegations remain bonded before revocation request is executable + #[pallet::constant] + type RevokeDelegationDelay: Get; + /// Number of rounds that delegation {more, less} requests must wait before executable + #[pallet::constant] + type DelegationBondDelay: Get; + /// Number of rounds after which block authors are rewarded + #[pallet::constant] + type RewardPaymentDelay: Get; + /// Minimum number of selected candidates every round + #[pallet::constant] + type MinSelectedCandidates: Get; + /// Maximum collator candidates allowed + #[pallet::constant] + type MaxCollatorCandidates: Get; + /// Maximum delegators allowed per candidate + #[pallet::constant] + type MaxTotalDelegatorsPerCandidate: Get; + /// Maximum delegators counted per candidate + #[pallet::constant] + type MaxDelegatorsPerCandidate: Get; + #[pallet::constant] + type DefaultPayoutLimit: Get; + /// Maximum delegations per delegator + #[pallet::constant] + type MaxDelegationsPerDelegator: Get; + /// Default commission due to collators, is `CollatorCommission` storage value in genesis + #[pallet::constant] + type DefaultCollatorCommission: Get; + /// Minimum stake required for any candidate to be in `SelectedCandidates` for the round + #[pallet::constant] + type MinCollatorStk: Get>; + /// Minimum stake required for any account to be a collator candidate + #[pallet::constant] + type MinCandidateStk: Get>; + /// Minimum stake for any registered on-chain account to delegate + #[pallet::constant] + type MinDelegation: Get>; + /// The native token used for payouts + #[pallet::constant] + type NativeTokenId: Get>; + /// The valuator for our staking liquidity tokens, i.e., XYK + /// This should never return (_, Zero::zero()) + type StakingLiquidityTokenValuator: Valuate, CurrencyIdOf>; + /// The module used for computing and getting issuance + type Issuance: ComputeIssuance + GetIssuance>; + #[pallet::constant] + /// The account id that holds the liquidity mining issuance + type StakingIssuanceVault: Get; + /// The module that provides the set of fallback accounts + type FallbackProvider: GetMembers; + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + } + + #[pallet::error] + pub enum Error { + DelegatorDNE, + DelegatorDNEinTopNorBottom, + DelegatorDNEInDelegatorSet, + CandidateDNE, + DelegationDNE, + DelegatorExists, + CandidateExists, + CandidateBondBelowMin, + InsufficientBalance, + DelegationBelowMin, + AlreadyOffline, + AlreadyActive, + DelegatorAlreadyLeaving, + DelegatorNotLeaving, + DelegatorCannotLeaveYet, + CannotDelegateIfLeaving, + CandidateAlreadyLeaving, + CandidateNotLeaving, + CandidateCannotLeaveYet, + CannotGoOnlineIfLeaving, + ExceedMaxDelegationsPerDelegator, + AlreadyDelegatedCandidate, + InvalidSchedule, + CannotSetBelowMin, + NoWritingSameValue, + TooLowCandidateCountWeightHintJoinCandidates, + TooLowCandidateCountWeightHintCancelLeaveCandidates, + TooLowCandidateCountToLeaveCandidates, + TooLowDelegationCountToDelegate, + TooLowCandidateDelegationCountToDelegate, + TooLowDelegationCountToLeaveDelegators, + PendingCandidateRequestsDNE, + PendingCandidateRequestAlreadyExists, + PendingCandidateRequestNotDueYet, + PendingDelegationRequestDNE, + PendingDelegationRequestAlreadyExists, + PendingDelegationRequestNotDueYet, + StakingLiquidityTokenNotListed, + TooLowCurrentStakingLiquidityTokensCount, + StakingLiquidityTokenAlreadyListed, + ExceedMaxCollatorCandidates, + ExceedMaxTotalDelegatorsPerCandidate, + CandidateNotAggregating, + CandidateNotAggregatingUnderAggregator, + CandidateAlreadyApprovedByAggregator, + AggregatorExists, + CollatorRoundRewardsDNE, + DelegatorRewardsDNE, + AggregatorDNE, + TargettedAggregatorSameAsCurrent, + CandidateNotApprovedByAggregator, + AggregatorLiquidityTokenTaken, + IncorrectRewardDelegatorCount, + MathError, + } + + #[pallet::event] + #[pallet::generate_deposit(pub(crate) fn deposit_event)] + pub enum Event { + /// Starting Block, Round, Number of Collators Selected, Total Balance + NewRound(BlockNumberFor, RoundIndex, u32, BalanceOf), + /// Account, Amount Locked, New Total Amt Locked + JoinedCollatorCandidates(T::AccountId, BalanceOf, BalanceOf), + /// Round, Collator Account, Total Exposed Amount (includes all delegations) + CollatorChosen(RoundIndex, T::AccountId, BalanceOf), + /// Candidate, Amount To Increase, Round at which request can be executed by caller + CandidateBondMoreRequested(T::AccountId, BalanceOf, RoundIndex), + /// Candidate, Amount To Decrease, Round at which request can be executed by caller + CandidateBondLessRequested(T::AccountId, BalanceOf, RoundIndex), + /// Candidate, Amount, New Bond Total + CandidateBondedMore(T::AccountId, BalanceOf, BalanceOf), + /// Candidate, Amount, New Bond + CandidateBondedLess(T::AccountId, BalanceOf, BalanceOf), + /// Round Offline, Candidate + CandidateWentOffline(RoundIndex, T::AccountId), + /// Round Online, Candidate + CandidateBackOnline(RoundIndex, T::AccountId), + /// Round At Which Exit Is Allowed, Candidate, Scheduled Exit + CandidateScheduledExit(RoundIndex, T::AccountId, RoundIndex), + /// Candidate + CancelledCandidateExit(T::AccountId), + /// Candidate, Cancelled Request + CancelledCandidateBondChange(T::AccountId, CandidateBondRequest>), + /// Ex-Candidate, Amount Unlocked, New Total Amt Locked + CandidateLeft(T::AccountId, BalanceOf, BalanceOf), + /// Delegator, Candidate, Amount to be increased, Round at which can be executed + DelegationIncreaseScheduled(T::AccountId, T::AccountId, BalanceOf, RoundIndex), + /// Delegator, Candidate, Amount to be decreased, Round at which can be executed + DelegationDecreaseScheduled(T::AccountId, T::AccountId, BalanceOf, RoundIndex), + // Delegator, Candidate, Amount, If in top delegations for candidate after increase + DelegationIncreased(T::AccountId, T::AccountId, BalanceOf, bool), + // Delegator, Candidate, Amount, If in top delegations for candidate after decrease + DelegationDecreased(T::AccountId, T::AccountId, BalanceOf, bool), + /// Round, Delegator, Scheduled Exit + DelegatorExitScheduled(RoundIndex, T::AccountId, RoundIndex), + /// Round, Delegator, Candidate, Scheduled Exit + DelegationRevocationScheduled(RoundIndex, T::AccountId, T::AccountId, RoundIndex), + /// Delegator, Amount Unstaked + DelegatorLeft(T::AccountId, BalanceOf), + /// Delegator, Candidate, Amount Unstaked + DelegationRevoked(T::AccountId, T::AccountId, BalanceOf), + /// Delegator + DelegatorExitCancelled(T::AccountId), + /// Delegator, Cancelled Request + CancelledDelegationRequest(T::AccountId, DelegationRequest>), + /// Delegator, Amount Locked, Candidate, Delegator Position with New Total Counted if in Top + Delegation(T::AccountId, BalanceOf, T::AccountId, DelegatorAdded>), + /// Delegator, Candidate, Amount Unstaked, New Total Amt Staked for Candidate + DelegatorLeftCandidate(T::AccountId, T::AccountId, BalanceOf, BalanceOf), + /// Session index, Delegator, Collator, Due reward (as per counted delegation for collator) + DelegatorDueReward(RoundIndex, T::AccountId, T::AccountId, BalanceOf), + /// Paid the account (delegator or collator) the balance as liquid rewards + Rewarded(RoundIndex, T::AccountId, BalanceOf), + /// Notify about reward periods that has been paid (collator, payout rounds, any rewards left) + CollatorRewardsDistributed(T::AccountId, PayoutRounds), + /// Staking expectations set + StakeExpectationsSet(BalanceOf, BalanceOf, BalanceOf), + /// Set total selected candidates to this value [old, new] + TotalSelectedSet(u32, u32), + /// Set collator commission to this value [old, new] + CollatorCommissionSet(Perbill, Perbill), + /// A candidate updated aggregator + CandidateAggregatorUpdated(T::AccountId, Option), + /// An agggregator's metadata has been updated + AggregatorMetadataUpdated(T::AccountId), + } + + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_idle(_now: BlockNumberFor, remaining_weight: Weight) -> Weight { + // some extra offset on top + let claim_cost = ::WeightInfo::payout_collator_rewards(); + if remaining_weight.ref_time() > claim_cost.ref_time() { + if let Some((collator, _round)) = RoundCollatorRewardInfo::::iter_keys().next() { + let _ = Self::do_payout_collator_rewards(collator, Some(1)); + } + } + + claim_cost + } + } + + #[pallet::storage] + #[pallet::getter(fn collator_commission)] + /// Commission percent taken off of rewards for all collators + type CollatorCommission = StorageValue<_, Perbill, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn total_selected)] + /// The total candidates selected every round + pub(crate) type TotalSelected = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn round)] + /// Current round index and next round scheduled transition + pub(crate) type Round = StorageValue<_, RoundInfo>, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn delegator_state)] + /// Get delegator state associated with an account if account is delegating else None + pub(crate) type DelegatorState = StorageMap< + _, + Twox64Concat, + T::AccountId, + Delegator, CurrencyIdOf>, + OptionQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn candidate_state)] + /// Get collator candidate state associated with an account if account is a candidate else None + pub(crate) type CandidateState = StorageMap< + _, + Twox64Concat, + T::AccountId, + CollatorCandidate, CurrencyIdOf>, + OptionQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn selected_candidates)] + /// The collator candidates selected for the current round + /// Block authors selection algorithm details [`Pallet::select_top_candidates`] + type SelectedCandidates = StorageValue<_, Vec, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn total)] + /// Total capital locked by this staking pallet + type Total = StorageMap<_, Twox64Concat, CurrencyIdOf, BalanceOf, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn candidate_pool)] + /// The pool of collator candidates, each with their total backing stake + type CandidatePool = + StorageValue<_, OrderedSet, CurrencyIdOf>>, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn at_stake)] + /// Snapshot of collator delegation stake at the start of the round + pub type AtStake = StorageDoubleMap< + _, + Twox64Concat, + RoundIndex, + Twox64Concat, + T::AccountId, + CollatorSnapshot, CurrencyIdOf>, + ValueQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn points)] + /// Total points awarded to collators for block production in the round + pub type Points = StorageMap<_, Twox64Concat, RoundIndex, RewardPoint, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn awarded_pts)] + /// Points for each collator per round + pub type AwardedPts = StorageDoubleMap< + _, + Twox64Concat, + RoundIndex, + Twox64Concat, + T::AccountId, + RewardPoint, + ValueQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn staking_liquidity_tokens)] + pub type StakingLiquidityTokens = StorageValue< + _, + BTreeMap, Option<(BalanceOf, BalanceOf)>>, + ValueQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn get_candidate_aggregator)] + /// Maps collator to its aggregator + pub type CandidateAggregator = + StorageValue<_, BTreeMap, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn get_aggregator_metadata)] + /// Stores information about approved candidates for aggregation + pub type AggregatorMetadata = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + AggregatorMetadataType>, + OptionQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn get_round_aggregator_info)] + /// Stored once per session, maps aggregator to list of assosiated candidates + pub type RoundAggregatorInfo = StorageMap< + _, + Twox64Concat, + RoundIndex, + BTreeMap>>, + OptionQuery, + >; + + #[pallet::storage] + #[pallet::getter(fn get_round_collator_reward_info)] + /// Stores information about rewards per each session + pub type RoundCollatorRewardInfo = StorageDoubleMap< + _, + Blake2_128Concat, + T::AccountId, + Twox64Concat, + RoundIndex, + RoundCollatorRewardInfoType>, + OptionQuery, + >; + + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub struct RoundCollatorRewardInfoType { + pub collator_reward: Balance, + pub delegator_rewards: BTreeMap, + } + + impl Default for RoundCollatorRewardInfoType { + fn default() -> RoundCollatorRewardInfoType { + Self { collator_reward: Default::default(), delegator_rewards: Default::default() } + } + } + + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub struct AggregatorMetadataType { + pub token_collator_map: BTreeMap, + pub approved_candidates: BTreeSet, + } + + impl Default for AggregatorMetadataType { + fn default() -> AggregatorMetadataType { + Self { token_collator_map: Default::default(), approved_candidates: Default::default() } + } + } + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub candidates: Vec<(T::AccountId, BalanceOf, CurrencyIdOf)>, + pub delegations: Vec<(T::AccountId, T::AccountId, BalanceOf)>, + } + + impl Default for GenesisConfig { + fn default() -> Self { + Self { candidates: vec![], delegations: vec![] } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) { + let mut liquidity_token_list: Vec> = self + .candidates + .iter() + .cloned() + .map(|(_, _, l)| l) + .collect::>>(); + liquidity_token_list.sort(); + liquidity_token_list.dedup(); + let liquidity_token_count: u32 = liquidity_token_list.len().try_into().unwrap(); + for (i, liquidity_token) in liquidity_token_list.iter().enumerate() { + if let Err(error) = >::add_staking_liquidity_token( + RawOrigin::Root.into(), + PairedOrLiquidityToken::Liquidity(*liquidity_token), + i as u32, + ) { + log::warn!( + "Adding staking liquidity token failed in genesis with error {:?}", + error + ); + } + } + let mut candidate_count = 0u32; + // Initialize the candidates + for &(ref candidate, balance, liquidity_token) in &self.candidates { + assert!( + ::Currency::available_balance( + liquidity_token.into(), + candidate + ) >= balance, + "Account does not have enough balance to bond as a candidate." + ); + candidate_count = candidate_count.saturating_add(1u32); + if let Err(error) = >::join_candidates( + T::RuntimeOrigin::from(Some(candidate.clone()).into()), + balance, + liquidity_token, + None, + candidate_count, + liquidity_token_count, + ) { + log::warn!("Join candidates failed in genesis with error {:?}", error); + } else { + candidate_count = candidate_count.saturating_add(1u32); + } + } + let mut col_delegator_count: BTreeMap = BTreeMap::new(); + let mut del_delegation_count: BTreeMap = BTreeMap::new(); + // Initialize the delegations + for &(ref delegator, ref target, balance) in &self.delegations { + let associated_collator = self.candidates.iter().find(|b| b.0 == *target); + let collator_liquidity_token = + associated_collator.expect("Delegation to non-existant collator").2; + assert!( + ::Currency::available_balance( + collator_liquidity_token.into(), + delegator + ) >= balance, + "Account does not have enough balance to place delegation." + ); + let cd_count = + if let Some(x) = col_delegator_count.get(target) { *x } else { 0u32 }; + let dd_count = + if let Some(x) = del_delegation_count.get(delegator) { *x } else { 0u32 }; + if let Err(error) = >::delegate( + T::RuntimeOrigin::from(Some(delegator.clone()).into()), + target.clone(), + balance, + None, + cd_count, + dd_count, + ) { + log::warn!("Delegate failed in genesis with error {:?}", error); + } else { + if let Some(x) = col_delegator_count.get_mut(target) { + *x = x.saturating_add(1u32); + } else { + col_delegator_count.insert(target.clone(), 1u32); + }; + if let Some(x) = del_delegation_count.get_mut(delegator) { + *x = x.saturating_add(1u32); + } else { + del_delegation_count.insert(delegator.clone(), 1u32); + }; + } + } + // Set collator commission to default config + >::put(T::DefaultCollatorCommission::get()); + // Set total selected candidates to minimum config + >::put(T::MinSelectedCandidates::get()); + // Choose top TotalSelected collator candidates + let (v_count, _, total_relevant_exposure) = >::select_top_candidates(1u32); + // Start Round 1 at Block 0 + let round: RoundInfo> = + RoundInfo::new(0u32, 0u32.into(), ::BlocksPerRound::get()); + >::put(round); + // So that round 0 can be rewarded + for atstake in >::iter_prefix(1u32) { + >::insert(0u32, atstake.0, atstake.1); + } + >::deposit_event(Event::NewRound( + BlockNumberFor::::zero(), + 0u32, + v_count, + total_relevant_exposure, + )); + } + } + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(::WeightInfo::set_total_selected())] + /// Set the total number of collator candidates selected per round + /// - changes are not applied until the start of the next round + pub fn set_total_selected(origin: OriginFor, new: u32) -> DispatchResultWithPostInfo { + frame_system::ensure_root(origin)?; + ensure!(new >= T::MinSelectedCandidates::get(), Error::::CannotSetBelowMin); + let old = >::get(); + ensure!(old != new, Error::::NoWritingSameValue); + >::put(new); + Self::deposit_event(Event::TotalSelectedSet(old, new)); + Ok(().into()) + } + + #[pallet::call_index(1)] + #[pallet::weight(::WeightInfo::set_collator_commission())] + /// Set the commission for all collators + pub fn set_collator_commission( + origin: OriginFor, + new: Perbill, + ) -> DispatchResultWithPostInfo { + frame_system::ensure_root(origin)?; + let old = >::get(); + ensure!(old != new, Error::::NoWritingSameValue); + >::put(new); + Self::deposit_event(Event::CollatorCommissionSet(old, new)); + Ok(().into()) + } + + #[pallet::call_index(2)] + #[pallet::weight(::WeightInfo::join_candidates(*candidate_count, *liquidity_token_count))] + /// Join the set of collator candidates + pub fn join_candidates( + origin: OriginFor, + bond: BalanceOf, + liquidity_token: CurrencyIdOf, + use_balance_from: Option, + candidate_count: u32, + liquidity_token_count: u32, + ) -> DispatchResultWithPostInfo { + let acc = ensure_signed(origin)?; + ensure!(!Self::is_candidate(&acc), Error::::CandidateExists); + ensure!(!Self::is_delegator(&acc), Error::::DelegatorExists); + ensure!(!Self::is_aggregator(&acc), Error::::AggregatorExists); + let staking_liquidity_tokens = >::get(); + + ensure!( + liquidity_token_count as usize >= staking_liquidity_tokens.len(), + Error::::TooLowCurrentStakingLiquidityTokensCount + ); + ensure!( + staking_liquidity_tokens.contains_key(&liquidity_token) || + liquidity_token == T::NativeTokenId::get(), + Error::::StakingLiquidityTokenNotListed + ); + + ensure!( + Self::valuate_bond(liquidity_token, bond) >= T::MinCandidateStk::get(), + Error::::CandidateBondBelowMin + ); + let mut candidates = >::get(); + let old_count = candidates.0.len() as u32; + // This is a soft check + // Reinforced by similar check in go_online and cancel_leave_candidates + ensure!( + old_count < T::MaxCollatorCandidates::get(), + Error::::ExceedMaxCollatorCandidates + ); + ensure!( + candidate_count >= old_count, + Error::::TooLowCandidateCountWeightHintJoinCandidates + ); + ensure!( + candidates.insert(Bond { owner: acc.clone(), amount: bond, liquidity_token }), + Error::::CandidateExists + ); + // reserve must be called before storage changes + // and before any unsafe math operations with `bond: Balance` + ::StakingReservesProvider::bond( + liquidity_token, + &acc, + bond, + use_balance_from, + )?; + let candidate = CollatorCandidate::new(acc.clone(), bond, liquidity_token); + >::insert(&acc, candidate); + >::put(candidates); + let new_total = >::get(liquidity_token).saturating_add(bond); + >::insert(liquidity_token, new_total); + Self::deposit_event(Event::JoinedCollatorCandidates(acc, bond, new_total)); + Ok(().into()) + } + + #[pallet::call_index(3)] + #[pallet::weight(::WeightInfo::schedule_leave_candidates(*candidate_count))] + /// Request to leave the set of candidates. If successful, the account is immediately + /// removed from the candidate pool to prevent selection as a collator. + pub fn schedule_leave_candidates( + origin: OriginFor, + candidate_count: u32, + ) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + let (now, when) = state.leave::()?; + let mut candidates = >::get(); + ensure!( + candidate_count >= candidates.0.len() as u32, + Error::::TooLowCandidateCountToLeaveCandidates + ); + if candidates.remove(&Bond::from_owner(collator.clone())) { + >::put(candidates); + } + >::insert(&collator, state); + Self::deposit_event(Event::CandidateScheduledExit(now, collator, when)); + Ok(().into()) + } + + #[pallet::call_index(4)] + #[pallet::weight(::WeightInfo::execute_leave_candidates(*candidate_delegation_count))] + /// Execute leave candidates request + pub fn execute_leave_candidates( + origin: OriginFor, + candidate: T::AccountId, + candidate_delegation_count: u32, + ) -> DispatchResultWithPostInfo { + ensure_signed(origin)?; + let state = >::get(&candidate).ok_or(Error::::CandidateDNE)?; + ensure!( + state.delegators.0.len() <= candidate_delegation_count as usize, + Error::::TooLowCandidateCountToLeaveCandidates + ); + state.can_leave::()?; + + let return_stake = |bond: Bond, CurrencyIdOf>| { + let debug_amount = ::StakingReservesProvider::unbond( + bond.liquidity_token.into(), + &bond.owner, + bond.amount, + ); + if !debug_amount.is_zero() { + log::warn!("Unbond in staking returned non-zero value {:?}", debug_amount); + } + // remove delegation from delegator state + let mut delegator = DelegatorState::::get(&bond.owner).expect( + "Collator state and delegator state are consistent. + Collator state has a record of this delegation. Therefore, + Delegator state also has a record. qed.", + ); + if let Some(remaining_delegations) = delegator.rm_delegation(candidate.clone()) { + if remaining_delegations.is_zero() { + >::remove(&bond.owner); + } else { + let _ = delegator.requests.requests.remove(&candidate); + >::insert(&bond.owner, delegator); + } + } + }; + // return all top delegations + for bond in state.top_delegations { + return_stake(bond); + } + // return all bottom delegations + for bond in state.bottom_delegations { + return_stake(bond); + } + // return stake to collator + let debug_amount = ::StakingReservesProvider::unbond( + state.liquidity_token.into(), + &state.id, + state.bond, + ); + if !debug_amount.is_zero() { + log::warn!("Unbond in staking returned non-zero value {:?}", debug_amount); + } + + let res = Self::do_update_candidate_aggregator(&candidate, None); + match res { + Err(e) if e == DispatchError::from(Error::::CandidateNotAggregating) => {}, + Err(_) => { + log::error!("do_update_candidate_aggregator failed with error {:?}", res); + }, + Ok(_) => {}, + } + + >::remove(&candidate); + let new_total_staked = + >::get(state.liquidity_token).saturating_sub(state.total_backing); + >::insert(state.liquidity_token, new_total_staked); + Self::deposit_event(Event::CandidateLeft( + candidate, + state.total_backing, + new_total_staked, + )); + Ok(().into()) + } + + #[pallet::call_index(5)] + #[pallet::weight(::WeightInfo::cancel_leave_candidates(*candidate_count))] + /// Cancel open request to leave candidates + /// - only callable by collator account + /// - result upon successful call is the candidate is active in the candidate pool + pub fn cancel_leave_candidates( + origin: OriginFor, + candidate_count: u32, + ) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + ensure!(state.is_leaving(), Error::::CandidateNotLeaving); + state.go_online(); + let mut candidates = >::get(); + // Reinforcement for the soft check in join_candiates + ensure!( + candidates.0.len() < T::MaxCollatorCandidates::get() as usize, + Error::::ExceedMaxCollatorCandidates + ); + ensure!( + candidates.0.len() as u32 <= candidate_count, + Error::::TooLowCandidateCountWeightHintCancelLeaveCandidates + ); + ensure!( + candidates.insert(Bond { + owner: collator.clone(), + amount: state.total_counted, + liquidity_token: state.liquidity_token + }), + Error::::AlreadyActive + ); + >::put(candidates); + >::insert(&collator, state); + Self::deposit_event(Event::CancelledCandidateExit(collator)); + Ok(().into()) + } + + #[pallet::call_index(6)] + #[pallet::weight(::WeightInfo::go_offline())] + /// Temporarily leave the set of collator candidates without unbonding + pub fn go_offline(origin: OriginFor) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + ensure!(state.is_active(), Error::::AlreadyOffline); + state.go_offline(); + let mut candidates = >::get(); + if candidates.remove(&Bond::from_owner(collator.clone())) { + >::put(candidates); + } + >::insert(&collator, state); + Self::deposit_event(Event::CandidateWentOffline(>::get().current, collator)); + Ok(().into()) + } + + #[pallet::call_index(7)] + #[pallet::weight(::WeightInfo::go_online())] + /// Rejoin the set of collator candidates if previously had called `go_offline` + pub fn go_online(origin: OriginFor) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + ensure!(!state.is_active(), Error::::AlreadyActive); + ensure!(!state.is_leaving(), Error::::CannotGoOnlineIfLeaving); + state.go_online(); + let mut candidates = >::get(); + // Reinforcement for the soft check in join_candiates + ensure!( + candidates.0.len() < T::MaxCollatorCandidates::get() as usize, + Error::::ExceedMaxCollatorCandidates + ); + ensure!( + candidates.insert(Bond { + owner: collator.clone(), + amount: state.total_counted, + liquidity_token: state.liquidity_token + }), + Error::::AlreadyActive + ); + >::put(candidates); + >::insert(&collator, state); + Self::deposit_event(Event::CandidateBackOnline(>::get().current, collator)); + Ok(().into()) + } + + #[pallet::call_index(8)] + #[pallet::weight(::WeightInfo::schedule_candidate_bond_more())] + /// Request by collator candidate to increase self bond by `more` + pub fn schedule_candidate_bond_more( + origin: OriginFor, + more: BalanceOf, + use_balance_from: Option, + ) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + let when = state.schedule_bond_more::(more, use_balance_from)?; + >::insert(&collator, state); + Self::deposit_event(Event::CandidateBondMoreRequested(collator, more, when)); + Ok(().into()) + } + + #[pallet::call_index(9)] + #[pallet::weight(::WeightInfo::schedule_candidate_bond_less())] + /// Request by collator candidate to decrease self bond by `less` + pub fn schedule_candidate_bond_less( + origin: OriginFor, + less: BalanceOf, + ) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + let when = state.schedule_bond_less::(less)?; + >::insert(&collator, state); + Self::deposit_event(Event::CandidateBondLessRequested(collator, less, when)); + Ok(().into()) + } + + #[pallet::call_index(10)] + #[pallet::weight(::WeightInfo::execute_candidate_bond_more())] + /// Execute pending request to adjust the collator candidate self bond + pub fn execute_candidate_bond_request( + origin: OriginFor, + candidate: T::AccountId, + use_balance_from: Option, + ) -> DispatchResultWithPostInfo { + ensure_signed(origin)?; // we may want to reward this if caller != candidate + let mut state = >::get(&candidate).ok_or(Error::::CandidateDNE)?; + let event = state.execute_pending_request::(use_balance_from)?; + >::insert(&candidate, state); + Self::deposit_event(event); + Ok(().into()) + } + + #[pallet::call_index(11)] + #[pallet::weight(::WeightInfo::cancel_candidate_bond_more())] + /// Cancel pending request to adjust the collator candidate self bond + pub fn cancel_candidate_bond_request(origin: OriginFor) -> DispatchResultWithPostInfo { + let collator = ensure_signed(origin)?; + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + let event = state.cancel_pending_request::()?; + >::insert(&collator, state); + Self::deposit_event(event); + Ok(().into()) + } + + #[pallet::call_index(12)] + #[pallet::weight( + ::WeightInfo::delegate( + *candidate_delegation_count, + *delegation_count, + ) + )] + /// If caller is not a delegator and not a collator, then join the set of delegators + /// If caller is a delegator, then makes delegation to change their delegation state + pub fn delegate( + origin: OriginFor, + collator: T::AccountId, + amount: BalanceOf, + use_balance_from: Option, + candidate_delegation_count: u32, + delegation_count: u32, + ) -> DispatchResultWithPostInfo { + let acc = ensure_signed(origin)?; + ensure!(!Self::is_aggregator(&acc), Error::::AggregatorExists); + let mut collator_state = + >::get(&collator).ok_or(Error::::CandidateDNE)?; + let delegator_state = if let Some(mut state) = >::get(&acc) { + ensure!(state.is_active(), Error::::CannotDelegateIfLeaving); + // delegation after first + ensure!( + Self::valuate_bond(collator_state.liquidity_token, amount) >= + T::MinDelegation::get(), + Error::::DelegationBelowMin + ); + ensure!( + delegation_count >= state.delegations.0.len() as u32, + Error::::TooLowDelegationCountToDelegate + ); + ensure!( + (state.delegations.0.len() as u32) < T::MaxDelegationsPerDelegator::get(), + Error::::ExceedMaxDelegationsPerDelegator + ); + ensure!( + state.add_delegation(Bond { + owner: collator.clone(), + amount, + liquidity_token: collator_state.liquidity_token, + }), + Error::::AlreadyDelegatedCandidate + ); + state + } else { + ensure!(amount >= T::MinDelegation::get(), Error::::DelegationBelowMin); + ensure!(!Self::is_candidate(&acc), Error::::CandidateExists); + Delegator::new( + acc.clone(), + collator.clone(), + amount, + collator_state.liquidity_token, + ) + }; + // This check is hard + // There is no other way to add to a collators delegation count + ensure!( + collator_state.delegators.0.len() < + T::MaxTotalDelegatorsPerCandidate::get() as usize, + Error::::ExceedMaxTotalDelegatorsPerCandidate + ); + ensure!( + candidate_delegation_count >= collator_state.delegators.0.len() as u32, + Error::::TooLowCandidateDelegationCountToDelegate + ); + let delegator_position = collator_state.add_delegation::(acc.clone(), amount)?; + ::StakingReservesProvider::bond( + collator_state.liquidity_token.into(), + &acc, + amount, + use_balance_from, + )?; + if let DelegatorAdded::AddedToTop { new_total } = delegator_position { + if collator_state.is_active() { + // collator in candidate pool + Self::update_active( + collator.clone(), + new_total, + collator_state.liquidity_token, + ); + } + } + let new_total_locked = + >::get(collator_state.liquidity_token).saturating_add(amount); + >::insert(collator_state.liquidity_token, new_total_locked); + >::insert(&collator, collator_state); + >::insert(&acc, delegator_state); + Self::deposit_event(Event::Delegation(acc, amount, collator, delegator_position)); + Ok(().into()) + } + + #[pallet::call_index(13)] + #[pallet::weight(::WeightInfo::schedule_leave_delegators())] + /// Request to leave the set of delegators. If successful, the caller is scheduled + /// to be allowed to exit. Success forbids future delegator actions until the request is + /// invoked or cancelled. + pub fn schedule_leave_delegators(origin: OriginFor) -> DispatchResultWithPostInfo { + let acc = ensure_signed(origin)?; + let mut state = >::get(&acc).ok_or(Error::::DelegatorDNE)?; + ensure!(!state.is_leaving(), Error::::DelegatorAlreadyLeaving); + let (now, when) = state.schedule_leave::(); + >::insert(&acc, state); + Self::deposit_event(Event::DelegatorExitScheduled(now, acc, when)); + Ok(().into()) + } + + #[pallet::call_index(14)] + #[pallet::weight(::WeightInfo::execute_leave_delegators(*delegation_count))] + /// Execute the right to exit the set of delegators and revoke all ongoing delegations. + pub fn execute_leave_delegators( + origin: OriginFor, + delegator: T::AccountId, + delegation_count: u32, + ) -> DispatchResultWithPostInfo { + ensure_signed(origin)?; + let state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + state.can_execute_leave::(delegation_count)?; + let mut amount_unstaked: BalanceOf = Zero::zero(); + for bond in state.delegations.0 { + amount_unstaked = amount_unstaked.saturating_add(bond.amount); + if let Err(error) = + Self::delegator_leaves_collator(delegator.clone(), bond.owner.clone()) + { + log::warn!( + "STORAGE CORRUPTED \nDelegator leaving collator failed with error: {:?}", + error + ); + } + } + >::remove(&delegator); + Self::deposit_event(Event::DelegatorLeft(delegator, amount_unstaked)); + Ok(().into()) + } + + #[pallet::call_index(15)] + #[pallet::weight(::WeightInfo::cancel_leave_delegators())] + /// Cancel a pending request to exit the set of delegators. Success clears the pending exit + /// request (thereby resetting the delay upon another `leave_delegators` call). + pub fn cancel_leave_delegators(origin: OriginFor) -> DispatchResultWithPostInfo { + let delegator = ensure_signed(origin)?; + // ensure delegator state exists + let mut state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + // ensure state is leaving + ensure!(state.is_leaving(), Error::::DelegatorDNE); + // cancel exit request + state.cancel_leave(); + >::insert(&delegator, state); + Self::deposit_event(Event::DelegatorExitCancelled(delegator)); + Ok(().into()) + } + + #[pallet::call_index(16)] + #[pallet::weight(::WeightInfo::schedule_revoke_delegation())] + /// Request to revoke an existing delegation. If successful, the delegation is scheduled + /// to be allowed to be revoked via the `execute_delegation_request` extrinsic. + pub fn schedule_revoke_delegation( + origin: OriginFor, + collator: T::AccountId, + ) -> DispatchResultWithPostInfo { + let delegator = ensure_signed(origin)?; + let mut state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + let (now, when) = state.schedule_revoke::(collator.clone())?; + >::insert(&delegator, state); + Self::deposit_event(Event::DelegationRevocationScheduled( + now, delegator, collator, when, + )); + Ok(().into()) + } + + #[pallet::call_index(17)] + #[pallet::weight(::WeightInfo::schedule_delegator_bond_more())] + /// Request to bond more for delegators wrt a specific collator candidate. + pub fn schedule_delegator_bond_more( + origin: OriginFor, + candidate: T::AccountId, + more: BalanceOf, + use_balance_from: Option, + ) -> DispatchResultWithPostInfo { + let delegator = ensure_signed(origin)?; + let mut state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + let when = state.schedule_increase_delegation::( + candidate.clone(), + more, + use_balance_from, + )?; + >::insert(&delegator, state); + Self::deposit_event(Event::DelegationIncreaseScheduled( + delegator, candidate, more, when, + )); + Ok(().into()) + } + + #[pallet::call_index(18)] + #[pallet::weight(::WeightInfo::schedule_delegator_bond_less())] + /// Request bond less for delegators wrt a specific collator candidate. + pub fn schedule_delegator_bond_less( + origin: OriginFor, + candidate: T::AccountId, + less: BalanceOf, + ) -> DispatchResultWithPostInfo { + let caller = ensure_signed(origin)?; + let mut state = >::get(&caller).ok_or(Error::::DelegatorDNE)?; + let when = state.schedule_decrease_delegation::(candidate.clone(), less)?; + >::insert(&caller, state); + Self::deposit_event(Event::DelegationDecreaseScheduled(caller, candidate, less, when)); + Ok(().into()) + } + + #[pallet::call_index(19)] + #[pallet::weight(::WeightInfo::execute_delegator_bond_more())] + /// Execute pending request to change an existing delegation + pub fn execute_delegation_request( + origin: OriginFor, + delegator: T::AccountId, + candidate: T::AccountId, + use_balance_from: Option, + ) -> DispatchResultWithPostInfo { + ensure_signed(origin)?; // we may want to reward caller if caller != delegator + let mut state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + state.execute_pending_request::(candidate, use_balance_from)?; + Ok(().into()) + } + + #[pallet::call_index(20)] + #[pallet::weight(::WeightInfo::cancel_delegator_bond_more())] + /// Cancel request to change an existing delegation. + pub fn cancel_delegation_request( + origin: OriginFor, + candidate: T::AccountId, + ) -> DispatchResultWithPostInfo { + let delegator = ensure_signed(origin)?; + let mut state = >::get(&delegator).ok_or(Error::::DelegatorDNE)?; + let request = state.cancel_pending_request::(candidate)?; + >::insert(&delegator, state); + Self::deposit_event(Event::CancelledDelegationRequest(delegator, request)); + Ok(().into()) + } + + #[pallet::call_index(21)] + #[pallet::weight(::WeightInfo::add_staking_liquidity_token(*current_liquidity_tokens))] + /// Enables new staking token to be used for staking. Only tokens paired with MGX can be + /// used. Caller can pass the id of token for which MGX paired pool already exists or + /// liquidity token id itself. **Root only** + pub fn add_staking_liquidity_token( + origin: OriginFor, + paired_or_liquidity_token: PairedOrLiquidityToken>, + current_liquidity_tokens: u32, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + + let added_liquidity_token: CurrencyIdOf = match paired_or_liquidity_token { + PairedOrLiquidityToken::Paired(x) => + T::StakingLiquidityTokenValuator::get_liquidity_asset( + x.into(), + T::NativeTokenId::get().into(), + )?, + PairedOrLiquidityToken::Liquidity(x) => { + T::StakingLiquidityTokenValuator::get_liquidity_token_mga_pool(x.into())?; + x + }, + }; + + StakingLiquidityTokens::::try_mutate( + |staking_liquidity_tokens| -> DispatchResult { + ensure!( + current_liquidity_tokens as usize >= staking_liquidity_tokens.len(), + Error::::TooLowCurrentStakingLiquidityTokensCount + ); + ensure!( + staking_liquidity_tokens.insert(added_liquidity_token, None).is_none(), + Error::::StakingLiquidityTokenAlreadyListed + ); + + Ok(()) + }, + )?; + Ok(().into()) + } + + #[pallet::call_index(22)] + #[pallet::weight(::WeightInfo::remove_staking_liquidity_token(*current_liquidity_tokens))] + /// Removes previously added liquidity token + pub fn remove_staking_liquidity_token( + origin: OriginFor, + paired_or_liquidity_token: PairedOrLiquidityToken>, + current_liquidity_tokens: u32, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + + let removed_liquidity_token: CurrencyIdOf = match paired_or_liquidity_token { + PairedOrLiquidityToken::Paired(x) => + T::StakingLiquidityTokenValuator::get_liquidity_asset( + x.into(), + T::NativeTokenId::get().into(), + )?, + PairedOrLiquidityToken::Liquidity(x) => x, + }; + + StakingLiquidityTokens::::try_mutate( + |staking_liquidity_tokens| -> DispatchResult { + ensure!( + current_liquidity_tokens as usize >= staking_liquidity_tokens.len(), + Error::::TooLowCurrentStakingLiquidityTokensCount + ); + ensure!( + staking_liquidity_tokens.remove(&removed_liquidity_token).is_some(), + Error::::StakingLiquidityTokenNotListed + ); + + Ok(()) + }, + )?; + Ok(().into()) + } + + #[pallet::call_index(23)] + #[pallet::weight(T::DbWeight::get().reads_writes(20, 20))] + #[transactional] + /// Modifies aggregator metadata by extending or reducing list of approved candidates + /// Account may only become aggregator only if its not collator or delegator at the moment + pub fn aggregator_update_metadata( + origin: OriginFor, + collator_candidates: Vec, + action: MetadataUpdateAction, + ) -> DispatchResultWithPostInfo { + let aggregator = ensure_signed(origin)?; + + ensure!(!Self::is_candidate(&aggregator), Error::::CandidateExists); + ensure!(!Self::is_delegator(&aggregator), Error::::DelegatorExists); + + AggregatorMetadata::::try_mutate_exists( + aggregator.clone(), + |maybe_aggregator_metadata| -> DispatchResult { + let mut aggregator_metadata = + maybe_aggregator_metadata.take().unwrap_or_default(); + + match action { + MetadataUpdateAction::ExtendApprovedCollators => { + collator_candidates.iter().try_for_each( + |collator| -> DispatchResult { + Self::add_approved_candidate_for_collator_metadata( + collator, + &mut aggregator_metadata, + ) + }, + )?; + }, + MetadataUpdateAction::RemoveApprovedCollators => { + collator_candidates.iter().try_for_each( + |collator| -> DispatchResult { + Self::remove_approved_candidates_from_collator_metadata( + collator, + &aggregator, + &mut aggregator_metadata, + ) + }, + )?; + }, + } + + if !aggregator_metadata.approved_candidates.is_empty() { + *maybe_aggregator_metadata = Some(aggregator_metadata); + } + + Ok(()) + }, + )?; + + Self::deposit_event(Event::AggregatorMetadataUpdated(aggregator)); + Ok(().into()) + } + + #[pallet::call_index(24)] + #[pallet::weight(T::DbWeight::get().reads_writes(20, 20))] + /// Assigns/replaces the candidate that given collator wants to aggregate under + #[transactional] + pub fn update_candidate_aggregator( + origin: OriginFor, + maybe_aggregator: Option, + ) -> DispatchResultWithPostInfo { + let candidate = ensure_signed(origin)?; + + Self::do_update_candidate_aggregator(&candidate, maybe_aggregator.clone())?; + + Ok(().into()) + } + + /// This extrinsic should be used to distribute rewards for collator and assodiated + /// delegators. As round rewards are processed in random order its impossible predict + /// how many delegators (and assodiated transfer extrinsic calls) will be required so + /// worst case scenario (delegators_count = MaxCollatorCandidates) is assumed. + /// + /// params: + /// - collator - account id + /// - limit - number of rewards periods that should be processed within extrinsic. Note + /// that limit assumes worst case scenario of (delegators_count = MaxCollatorCandidates) + /// so as a result, `limit` or more session round rewards may be distributed + #[pallet::call_index(25)] + #[pallet::weight(number_of_sesisons.unwrap_or(T::DefaultPayoutLimit::get()) * ::WeightInfo::payout_collator_rewards())] + #[transactional] + pub fn payout_collator_rewards( + origin: OriginFor, + collator: T::AccountId, + number_of_sesisons: Option, + ) -> DispatchResultWithPostInfo { + let _caller = ensure_signed(origin)?; + Self::do_payout_collator_rewards(collator, number_of_sesisons) + } + + // TODO: use more precise benchmark + #[pallet::call_index(26)] + #[pallet::weight(::WeightInfo::payout_delegator_reward())] + #[transactional] + /// Payout delegator rewards only for particular round. Collators should rather use + /// [`Pallet::payout_collator_rewards`] but if collator is inresponsive one can claim + /// particular delegator rewards manually. + pub fn payout_delegator_reward( + origin: OriginFor, + round: RoundIndex, + collator: T::AccountId, + delegator: T::AccountId, + ) -> DispatchResultWithPostInfo { + let _caller = ensure_signed(origin)?; + + RoundCollatorRewardInfo::::try_mutate( + collator.clone(), + round, + |maybe_collator_payout_info| -> DispatchResult { + let collator_payout_info = maybe_collator_payout_info + .as_mut() + .ok_or(Error::::CollatorRoundRewardsDNE)?; + let delegator_reward = collator_payout_info + .delegator_rewards + .remove(&delegator) + .ok_or(Error::::DelegatorRewardsDNE)?; + Self::payout_reward( + round, + delegator, + delegator_reward, + RewardKind::Delegator(collator), + )?; + Ok(()) + }, + )?; + + Ok(().into()) + } + } + + impl Pallet { + fn add_approved_candidate_for_collator_metadata( + collator_candidate: &T::AccountId, + aggregator_metadata: &mut AggregatorMetadataType>, + ) -> DispatchResult { + ensure!(Self::is_candidate(&collator_candidate), Error::::CandidateDNE); + ensure!( + aggregator_metadata.approved_candidates.insert(collator_candidate.clone()), + Error::::CandidateAlreadyApprovedByAggregator + ); + Ok(()) + } + + fn remove_approved_candidates_from_collator_metadata( + collator_candidate: &T::AccountId, + aggregator: &T::AccountId, + aggregator_metadata: &mut AggregatorMetadataType>, + ) -> DispatchResult { + // Do not propagate the error if there's an error here + // Then it means that the aggregator wasn't aggregating for this candidate + // Or that the target is no longer a candidate, which can happen if the candidate has left + // removing all his aggregation details except for approvals from various aggregators + let _ = CandidateAggregator::::try_mutate( + |candidate_aggregator_map| -> DispatchResult { + let collator_candidate_state = >::get(&collator_candidate) + .ok_or(Error::::CandidateDNE)?; + ensure!( + Some(aggregator.clone()) == + candidate_aggregator_map.remove(collator_candidate), + Error::::CandidateNotAggregatingUnderAggregator + ); + + // If CandidateAggregator has the aggregator listed under this candidate then + // the aggregator metadata will have this candidate listed under its liquidity token + let res = aggregator_metadata + .token_collator_map + .remove(&collator_candidate_state.liquidity_token); + if res != Some(collator_candidate.clone()) { + log::error!( + "Inconsistent aggregator metadata: candidate - {:?}, aggregator - {:?}", + collator_candidate, + aggregator + ); + } + + Ok(()) + }, + ); + + ensure!( + aggregator_metadata.approved_candidates.remove(collator_candidate), + Error::::CandidateNotApprovedByAggregator + ); + + Ok(()) + } + + pub fn payout_reward( + round: RoundIndex, + to: T::AccountId, + amt: BalanceOf, + kind: RewardKind, + ) -> DispatchResult { + let _ = ::Currency::transfer( + T::NativeTokenId::get().into(), + &::StakingIssuanceVault::get(), + &to, + amt, + ExistenceRequirement::AllowDeath, + )?; + match kind { + RewardKind::Collator => + Self::deposit_event(Event::Rewarded(round, to.clone(), amt)), + RewardKind::Delegator(collator) => Self::deposit_event(Event::DelegatorDueReward( + round, + collator.clone(), + to.clone(), + amt, + )), + }; + Ok(()) + } + pub fn is_delegator(acc: &T::AccountId) -> bool { + >::get(acc).is_some() + } + pub fn is_candidate(acc: &T::AccountId) -> bool { + >::get(acc).is_some() + } + pub fn is_aggregator(acc: &T::AccountId) -> bool { + >::get(acc).is_some() + } + pub fn is_selected_candidate(acc: &T::AccountId) -> bool { + >::get().binary_search(acc).is_ok() + } + + fn remove_aggregator_for_collator(candidate: &T::AccountId) -> DispatchResult { + CandidateAggregator::::try_mutate(|candidate_aggregator_info| -> DispatchResult { + let detached_aggregator = candidate_aggregator_info + .remove(&candidate) + .ok_or(Error::::CandidateNotAggregating)?; + + AggregatorMetadata::::try_mutate( + detached_aggregator.clone(), + |maybe_aggregator_metadata| -> DispatchResult { + let aggregator_metadata = + maybe_aggregator_metadata.as_mut().ok_or(Error::::AggregatorDNE)?; + let candidate_state = + >::get(&candidate).ok_or(Error::::CandidateDNE)?; + let res = aggregator_metadata + .token_collator_map + .remove(&candidate_state.liquidity_token); + if res != Some(candidate.clone()) { + log::error!( + "Inconsistent aggregator metadata: candidate - {:?}, aggregator - {:?}", + candidate, + detached_aggregator + ); + } + + Ok(()) + }, + )?; + + Ok(()) + })?; + Ok(()) + } + + fn corelate_collator_with_aggregator( + candidate: &T::AccountId, + new_aggregator: T::AccountId, + ) -> DispatchResult { + AggregatorMetadata::::try_mutate( + new_aggregator, + |maybe_aggregator_metadata| -> DispatchResult { + let aggregator_metadata = + maybe_aggregator_metadata.as_mut().ok_or(Error::::AggregatorDNE)?; + ensure!( + aggregator_metadata.approved_candidates.contains(candidate), + Error::::CandidateNotApprovedByAggregator + ); + let candidate_state = + >::get(candidate).ok_or(Error::::CandidateDNE)?; + ensure!( + aggregator_metadata + .token_collator_map + .insert(candidate_state.liquidity_token, candidate.clone()) + .is_none(), + Error::::AggregatorLiquidityTokenTaken + ); + + Ok(()) + }, + )?; + Ok(()) + } + + fn replace_aggregator_for_collator( + candidate: &T::AccountId, + new_aggregator: T::AccountId, + prev_aggregator: T::AccountId, + ) -> DispatchResult { + ensure!( + prev_aggregator != new_aggregator, + Error::::TargettedAggregatorSameAsCurrent + ); + + AggregatorMetadata::::try_mutate( + prev_aggregator.clone(), + |maybe_prev_aggregator_metadata| -> DispatchResult { + let prev_aggregator_metadata = + maybe_prev_aggregator_metadata.as_mut().ok_or(Error::::AggregatorDNE)?; + let candidate_state = + >::get(candidate).ok_or(Error::::CandidateDNE)?; + let res = prev_aggregator_metadata + .token_collator_map + .remove(&candidate_state.liquidity_token); + if res != Some(candidate.clone()) { + log::error!( + "Inconsistent aggregator metadata: candidate - {:?}, aggregator - {:?}", + candidate, + prev_aggregator + ); + } + + Self::corelate_collator_with_aggregator(candidate, new_aggregator)?; + Ok(()) + }, + )?; + + Ok(()) + } + + fn assign_aggregator_for_collator( + candidate: &T::AccountId, + new_aggregator: T::AccountId, + ) -> DispatchResult { + CandidateAggregator::::try_mutate(|candidate_aggregator_info| -> DispatchResult { + match candidate_aggregator_info.insert(candidate.clone(), new_aggregator.clone()) { + Some(prev_aggregator) => { + Self::replace_aggregator_for_collator( + candidate, + new_aggregator, + prev_aggregator, + )?; + }, + None => { + Self::corelate_collator_with_aggregator(candidate, new_aggregator)?; + }, + } + Ok(()) + })?; + Ok(()) + } + + pub fn do_update_candidate_aggregator( + candidate: &T::AccountId, + maybe_aggregator: Option, + ) -> DispatchResult { + ensure!(Self::is_candidate(candidate), Error::::CandidateDNE); + + if let Some(ref new_aggregator) = maybe_aggregator { + Self::assign_aggregator_for_collator(candidate, new_aggregator.clone())?; + } else { + Self::remove_aggregator_for_collator(candidate)?; + } + + Self::deposit_event(Event::CandidateAggregatorUpdated( + candidate.clone(), + maybe_aggregator, + )); + Ok(()) + } + /// Caller must ensure candidate is active before calling + fn update_active( + candidate: T::AccountId, + total: BalanceOf, + candidate_liquidity_token: CurrencyIdOf, + ) { + let mut candidates = >::get(); + candidates.remove(&Bond::from_owner(candidate.clone())); + candidates.insert(Bond { + owner: candidate, + amount: total, + liquidity_token: candidate_liquidity_token, + }); + >::put(candidates); + } + fn delegator_leaves_collator( + delegator: T::AccountId, + collator: T::AccountId, + ) -> DispatchResult { + let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; + let (total_changed, delegator_stake) = state.rm_delegator::(delegator.clone())?; + let debug_amount = ::StakingReservesProvider::unbond( + state.liquidity_token.into(), + &delegator, + delegator_stake, + ); + if !debug_amount.is_zero() { + log::warn!("Unbond in staking returned non-zero value {:?}", debug_amount); + } + if state.is_active() && total_changed { + Self::update_active(collator.clone(), state.total_counted, state.liquidity_token); + } + let new_total_locked = + >::get(state.liquidity_token).saturating_sub(delegator_stake); + >::insert(state.liquidity_token, new_total_locked); + let new_total = state.total_counted; + >::insert(&collator, state); + Self::deposit_event(Event::DelegatorLeftCandidate( + delegator, + collator, + delegator_stake, + new_total, + )); + Ok(()) + } + + fn process_collator_with_rewards( + round_to_payout: u32, + collator: T::AccountId, + reward: BalanceOf, + ) { + let state = >::take(round_to_payout, &collator); + let collator_commission_perbill = >::get(); + let mut collator_payout_info = + RoundCollatorRewardInfoType::>::default(); + if state.delegations.is_empty() { + // solo collator with no delegators + collator_payout_info.collator_reward = reward; + RoundCollatorRewardInfo::::insert( + collator, + round_to_payout, + collator_payout_info, + ); + } else { + let collator_commission = collator_commission_perbill.mul_floor(reward); + let reward_less_commission = reward.saturating_sub(collator_commission); + + let collator_perbill = Perbill::from_rational(state.bond, state.total); + let collator_reward_less_commission = + collator_perbill.mul_floor(reward_less_commission); + + collator_payout_info.collator_reward = + collator_reward_less_commission.saturating_add(collator_commission); + + match state + .delegations + .iter() + .cloned() + .try_fold(state.bond, |acc, x| acc.checked_add(&x.amount)) + { + Some(total) if total <= state.total => { + state.delegations.iter().for_each(|delegator_bond| { + collator_payout_info.delegator_rewards.insert( + delegator_bond.owner.clone(), + multiply_by_rational_with_rounding( + reward_less_commission.into(), + delegator_bond.amount.into(), + state.total.into(), + Rounding::Down, + ) + .map(SaturatedConversion::saturated_into) + .unwrap_or(BalanceOf::::zero()), + ); + }); + }, + _ => { + // unexpected overflow has occured and rewards will now distributed evenly amongst + let delegator_count = state.delegations.len() as u32; + let delegator_reward = reward + .saturating_sub(collator_payout_info.collator_reward) + .checked_div(&delegator_count.into()) + .unwrap_or(Zero::zero()); + state.delegations.iter().for_each(|delegator_bond| { + collator_payout_info + .delegator_rewards + .insert(delegator_bond.owner.clone(), delegator_reward); + }); + }, + } + + RoundCollatorRewardInfo::::insert( + collator, + round_to_payout, + collator_payout_info, + ); + } + } + + fn process_aggregator_with_rewards_and_dist( + round_to_payout: u32, + _aggregator: T::AccountId, + author_rewards: BalanceOf, + distribution: &BTreeMap>, + ) { + match distribution + .values() + .cloned() + .try_fold(BalanceOf::::zero(), |acc, x| acc.checked_add(&x)) + { + Some(aggregator_total_valuation) => { + distribution.iter().for_each(|(collator, contribution)| { + Self::process_collator_with_rewards( + round_to_payout, + collator.clone(), + multiply_by_rational_with_rounding( + author_rewards.into(), + contribution.clone().into(), + aggregator_total_valuation.into(), + Rounding::Down, + ) + .map(SaturatedConversion::saturated_into) + .unwrap_or(BalanceOf::::zero()), + ) + }); + }, + None => { + // unexpected overflow has occured and rewards will now distributed evenly amongst + let collator_count = distribution.keys().cloned().count() as u32; + let collator_reward = author_rewards + .checked_div(&collator_count.into()) + .unwrap_or(BalanceOf::::zero()); + distribution.keys().for_each(|collator| { + Self::process_collator_with_rewards( + round_to_payout, + collator.clone(), + collator_reward, + ) + }); + }, + } + } + + fn pay_stakers(now: RoundIndex) { + // payout is now - duration rounds ago => now - duration > 0 else return early + let duration = T::RewardPaymentDelay::get(); + if now < duration { + return + } + let round_to_payout = now.saturating_sub(duration); + let total = >::take(round_to_payout); + if total.is_zero() { + return + } + let total_issuance = + T::Issuance::get_staking_issuance(round_to_payout).unwrap_or(Zero::zero()); + + // unwrap_or_default here is to ensure backward compatibility during the upgrade + let round_aggregator_info = + RoundAggregatorInfo::::take(round_to_payout).unwrap_or_default(); + + for (author, pts) in >::drain_prefix(round_to_payout) { + let author_issuance_perbill = Perbill::from_rational(pts, total); + + let author_rewards = author_issuance_perbill.mul_floor(total_issuance); + + match round_aggregator_info.get(&author) { + Some(aggregator_distribution) => + Self::process_aggregator_with_rewards_and_dist( + round_to_payout, + author, + author_rewards, + aggregator_distribution, + ), + None => + Self::process_collator_with_rewards(round_to_payout, author, author_rewards), + } + } + } + + pub fn calculate_collators_valuations<'a, I>( + valuated_bond_it: I, + ) -> BTreeMap> + where + I: Iterator< + Item = (&'a Bond, CurrencyIdOf>, BalanceOf), + >, + I: Clone, + { + let aggregator_info = >::get(); + // collect aggregated bonds + let mut valuated_bonds = valuated_bond_it + .clone() + .filter_map(|(bond, valuation)| { + aggregator_info.get(&bond.owner).map(|aggregator| (bond, valuation, aggregator)) + }) + .fold( + BTreeMap::>::new(), + |mut acc, (_bond, valuation, aggregator)| { + acc.entry(aggregator.clone()) + .and_modify(|total| *total = total.saturating_add(valuation)) + .or_insert_with(|| valuation); + acc + }, + ); + + // extend with non agregated bonds + valuated_bonds.extend(valuated_bond_it.filter_map(|(bond, valuation)| { + if let None = aggregator_info.get(&bond.owner) { + Some((bond.owner.clone(), valuation)) + } else { + None + } + })); + + valuated_bonds + } + + pub fn calculate_aggregators_collator_info<'a, I>( + valuated_bond_it: I, + ) -> BTreeMap>> + where + I: Iterator< + Item = (&'a Bond, CurrencyIdOf>, BalanceOf), + >, + { + let aggregator_info = >::get(); + + valuated_bond_it + .filter_map(|(bond, valuation)| { + aggregator_info.get(&bond.owner).map(|aggregator| (bond, valuation, aggregator)) + }) + .fold( + BTreeMap::>>::new(), + |mut acc, (bond, valuation, aggregator)| { + acc.entry(aggregator.clone()) + .and_modify(|x| { + x.insert(bond.owner.clone(), valuation); + }) + .or_insert(BTreeMap::from([(bond.owner.clone(), valuation)])); + acc + }, + ) + } + + pub fn calculate_valuations_and_aggregation_info() -> ( + BTreeMap>, + BTreeMap>>, + ) { + let candidates = >::get().0; + + let liq_token_to_pool = >::get(); + let valuated_bond_it = candidates.iter().filter_map(|bond| { + if bond.liquidity_token == T::NativeTokenId::get() { + Some((bond, bond.amount.checked_div(&2_u32.into()).unwrap_or_default())) + } else { + match liq_token_to_pool.get(&bond.liquidity_token) { + Some(Some((reserve1, reserve2))) if !reserve1.is_zero() => + multiply_by_rational_with_rounding( + bond.amount.into(), + (*reserve1).into(), + (*reserve2).into(), + Rounding::Down, + ) + .map(SaturatedConversion::saturated_into) + .map(|val| (bond, val)) + .or(Some((bond, BalanceOf::::max_value()))), + _ => None, + } + } + }); + + ( + Self::calculate_collators_valuations(valuated_bond_it.clone()), + Self::calculate_aggregators_collator_info(valuated_bond_it.clone()), + ) + } + // + /// Compute the top `TotalSelected` candidates in the CandidatePool and return + /// a vec of their AccountIds (in the order of selection) + pub fn compute_top_candidates() -> ( + Vec<(T::AccountId, BalanceOf)>, + Vec<(T::AccountId, BalanceOf)>, + BTreeMap>>, + ) { + let (valuated_author_candidates_btreemap, aggregators_collator_info) = + Self::calculate_valuations_and_aggregation_info(); + + let mut valuated_author_candidates_vec: Vec<(T::AccountId, BalanceOf)> = + valuated_author_candidates_btreemap.into_iter().collect::<_>(); + + // order candidates by stake (least to greatest so requires `rev()`) + valuated_author_candidates_vec.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap()); + let top_n = >::get() as usize; + // choose the top TotalSelected qualified candidates, ordered by stake + let mut selected_authors: Vec<(T::AccountId, BalanceOf)> = + valuated_author_candidates_vec + .into_iter() + .rev() + .take(top_n) + .filter(|x| x.1 >= T::MinCollatorStk::get()) + .collect::<_>(); + selected_authors.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap()); + + let mut all_selected_collators = Vec::<(T::AccountId, BalanceOf)>::new(); + for selected_author in selected_authors.iter() { + if let Some(aggregator_collator_info) = + aggregators_collator_info.get(&selected_author.0) + { + all_selected_collators.extend_from_slice( + &{ + aggregator_collator_info + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::)>>() + }[..], + ); + } else { + all_selected_collators.push(selected_author.clone()); + } + } + + (selected_authors, all_selected_collators, aggregators_collator_info) + } + + pub fn staking_liquidity_tokens_snapshot() { + let mut staking_liquidity_tokens = >::get(); + + for (token, valuation) in staking_liquidity_tokens.iter_mut() { + *valuation = T::StakingLiquidityTokenValuator::get_pool_state((*token).into()); + } + + >::put(staking_liquidity_tokens); + } + + #[aquamarine::aquamarine] + /// Best as in most cumulatively supported in terms of stake + /// Returns [collator_count, delegation_count, total staked] + /// ```mermaid + /// flowchart + /// A[Start] --> B{for all candidates} + /// B -- Is aggregating under Aggregator? --> C[increase Aggreagator valuation] + /// B -- Is solo collator? --> D[increase collator valuation] + /// C --> E[collect final valuations of solo collators and aggregators] + /// D --> E + /// E -- list of solo collators and aggregators only--> F[pick top N valuated accounts] + /// F --> G{for every block author} + /// G -- author --> Z[persist into SelectedCandidates runtime storage] + /// G -- author --> Y{Is solo collator or Aggregator} + /// Y -- is solo collator --> I[emit CollatorChosen event] + /// Y -- is aggregator --> H{for every associated collator} + /// H --> I + /// ``` + pub fn select_top_candidates(now: RoundIndex) -> (u32, u32, BalanceOf) { + let (mut collator_count, mut delegation_count, mut total_relevant_exposure) = + (0u32, 0u32, BalanceOf::::zero()); + Self::staking_liquidity_tokens_snapshot(); + // choose the top TotalSelected qualified candidates, ordered by stake + let (selected_authors, all_selected_collators, aggregators_collator_info) = + Self::compute_top_candidates(); + + RoundAggregatorInfo::::insert(now, aggregators_collator_info); + + // snapshot exposure for round for weighting reward distribution + for collator in all_selected_collators.iter() { + let state = >::get(&collator.0) + .expect("all members of CandidateQ must be candidates"); + collator_count = collator_count.saturating_add(1u32); + delegation_count = delegation_count.saturating_add(state.delegators.0.len() as u32); + let amount = collator.1; + total_relevant_exposure = total_relevant_exposure.saturating_add(amount); + let collator_snaphot: CollatorSnapshot< + T::AccountId, + BalanceOf, + CurrencyIdOf, + > = state.into(); + >::insert(now, collator.0.clone(), collator_snaphot); + Self::deposit_event(Event::CollatorChosen(now, collator.0.clone(), amount)); + } + + // insert canonical collator set + >::put( + selected_authors.iter().cloned().map(|x| x.0).collect::>(), + ); + (collator_count, delegation_count, total_relevant_exposure) + } + + fn valuate_bond(liquidity_token: CurrencyIdOf, bond: BalanceOf) -> BalanceOf { + if liquidity_token == T::NativeTokenId::get() { + bond.checked_div(&2_u32.into()).unwrap_or_default() + } else { + T::StakingLiquidityTokenValuator::valuate_liquidity_token( + liquidity_token.into(), + bond, + ) + } + } + + fn do_payout_collator_rewards( + collator: T::AccountId, + number_of_sesisons: Option, + ) -> DispatchResultWithPostInfo { + let mut rounds = Vec::::new(); + + let limit = number_of_sesisons.unwrap_or(T::DefaultPayoutLimit::get()); + let mut payouts_left = limit * (T::MaxDelegationsPerDelegator::get() + 1); + + for (id, (round, info)) in + RoundCollatorRewardInfo::::iter_prefix(collator.clone()).enumerate() + { + if payouts_left < (info.delegator_rewards.len() as u32 + 1u32) { + break + } + + Self::payout_reward( + round, + collator.clone(), + info.collator_reward, + RewardKind::Collator, + )?; + payouts_left -= 1u32; + + let _ = info.delegator_rewards.iter().try_for_each(|(d, r)| { + Self::payout_reward( + round, + d.clone(), + r.clone(), + RewardKind::Delegator(collator.clone()), + ) + })?; + RoundCollatorRewardInfo::::remove(collator.clone(), round); + rounds.push(round); + + payouts_left = payouts_left + .checked_sub(info.delegator_rewards.len() as u32) + .unwrap_or_default(); + + if (id as u32).checked_add(1u32).unwrap_or(u32::MAX) > limit { + // We can optimize number of rounds that can be processed as extrinsic weight + // was benchmarked assuming that collator have delegators count == T::MaxDelegatorsPerCandidate + // so if there are less or no delegators, we can use remaining weight for + // processing following block, the only extra const is single iteration that + // consumes 1 storage read. We can compensate that by sacrificing single transfer tx + // + // esitmated weight or payout_collator_rewards extrinsic with limit parm set to 1 is + // 1 storage read + (MaxDelegatorsPerCollator + 1) * transfer weight + // + // so if collator does not have any delegators only 1 transfer was actually + // executed leaving MaxDelegatorsPerCollator spare. We can use that remaining + // weight to payout rewards for following rounds. Each extra round requires: + // - 1 storage read (iteration) + // - N <= MaxDelegatorsPerCandidate transfers (depending on collators count) + // + // we can compansate storage read with 1 transfer and try to process following + // round if there are enought transfers left + payouts_left = payouts_left.checked_sub(1).unwrap_or_default(); + } + } + + ensure!(!rounds.is_empty(), Error::::CollatorRoundRewardsDNE); + + if let Some(_) = RoundCollatorRewardInfo::::iter_prefix(collator.clone()).next() { + Self::deposit_event(Event::CollatorRewardsDistributed( + collator, + PayoutRounds::Partial(rounds), + )); + } else { + Self::deposit_event(Event::CollatorRewardsDistributed(collator, PayoutRounds::All)); + } + + // possibly use PostDispatchInfo.actual_weight to return refund caller if delegators + // count was lower than assumed upper bound + Ok(().into()) + } + } + + /// Add reward points to block authors: + /// * 20 points to the block producer for producing a block in the chain + impl pallet_authorship::EventHandler> for Pallet { + fn note_author(author: T::AccountId) { + let now = >::get().current; + let score_plus_20 = >::get(now, &author).saturating_add(20); + >::insert(now, author, score_plus_20); + >::mutate(now, |x| *x = x.saturating_add(20)); + } + } + + impl pallet_session::SessionManager for Pallet { + fn new_session(_: SessionIndex) -> Option> { + let selected_canidates = Self::selected_candidates(); + if !selected_canidates.is_empty() { + Some(selected_canidates) + } else { + let fallback_canidates = T::FallbackProvider::get_members(); + if !fallback_canidates.is_empty() { + Some(fallback_canidates) + } else { + None + } + } + } + fn start_session(session_index: SessionIndex) { + if !session_index.is_zero() { + let n = >::block_number().saturating_add(One::one()); + let mut round = >::get(); + // println!("ROUND FINISHED {}", round.current.saturated_into::()); + // mutate round + round.update(n); + // pay all stakers for T::RewardPaymentDelay rounds ago + Self::pay_stakers(round.current); + // select top collator candidates for next round + let (collator_count, _delegation_count, total_relevant_exposure) = + Self::select_top_candidates(round.current.saturating_add(One::one())); + // Calculate the issuance for next round + // No issuance must happen after this point + T::Issuance::compute_issuance(round.current); + // start next round + >::put(round); + // Emit new round event + Self::deposit_event(Event::NewRound( + round.first, + round.current, + collator_count, + total_relevant_exposure, + )); + } + } + fn end_session(_: SessionIndex) { + // ignore + } + } + + impl pallet_session::ShouldEndSession> for Pallet { + fn should_end_session(now: BlockNumberFor) -> bool { + let round = >::get(); + round.should_update(now) + } + } + + impl EstimateNextSessionRotation> for Pallet { + fn average_session_length() -> BlockNumberFor { + >::get().length.into() + } + + fn estimate_current_session_progress(now: BlockNumberFor) -> (Option, Weight) { + let round = >::get(); + let passed_blocks = now.saturating_sub(round.first).saturating_add(One::one()); + + ( + Some(Permill::from_rational(passed_blocks, round.length.into())), + // One read for the round info, blocknumber is read free + T::DbWeight::get().reads(1), + ) + } + + fn estimate_next_session_rotation( + _now: BlockNumberFor, + ) -> (Option>, Weight) { + let round = >::get(); + + ( + Some(round.first.saturating_add(round.length.saturating_sub(One::one()).into())), + // One read for the round info, blocknumber is read free + T::DbWeight::get().reads(1), + ) + } + } +} diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs new file mode 100644 index 0000000000..13052b7e8f --- /dev/null +++ b/pallets/parachain-staking/src/mock.rs @@ -0,0 +1,662 @@ +// Copyright 2019-2021 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! Test utilities +use crate as stake; +use crate::{ + pallet, AwardedPts, BondKind, ComputeIssuance, Config, DispatchError, GetIssuance, Points, + RoundCollatorRewardInfo, StakingReservesProviderTrait, Valuate, +}; +use codec::{Decode, Encode}; +use frame_support::{ + assert_ok, construct_runtime, parameter_types, + traits::{ + Contains, Everything, MultiTokenCurrency, MultiTokenVestingSchedule, OnFinalize, + OnInitialize, + }, + PalletId, +}; +use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; +use orml_traits::parameter_type_with_key; +use scale_info::TypeInfo; +use sp_io; +use sp_runtime::{ + traits::{AccountIdConversion, Zero}, + BuildStorage, DispatchResult, Perbill, Percent, RuntimeDebug, +}; +use sp_std::{ + convert::{TryFrom, TryInto}, + marker::PhantomData, +}; + +pub(crate) type AccountId = u64; +pub(crate) type Amount = i128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; + +pub const MGA_TOKEN_ID: TokenId = 0; + +type Block = frame_system::mocking::MockBlock; + +// Configure a mock runtime to test the pallet. +construct_runtime!( + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + Stake: stake, + } +); + +parameter_types! { + pub const BlockHashCount: u64 = 250; + // pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + pub const SS58Prefix: u8 = 42; +} +impl frame_system::Config for Test { + type BaseCallFilter = Everything; + type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; + type RuntimeCall = RuntimeCall; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = sp_runtime::traits::IdentityLookup; + type RuntimeEvent = RuntimeEvent; + type Block = Block; + type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +parameter_types! { + pub const HistoryLimit: u32 = 10u32; + + pub const LiquidityMiningIssuanceVaultId: PalletId = PalletId(*b"py/lqmiv"); + pub LiquidityMiningIssuanceVault: AccountId = LiquidityMiningIssuanceVaultId::get().into_account_truncating(); + pub const StakingIssuanceVaultId: PalletId = PalletId(*b"py/stkiv"); + pub StakingIssuanceVault: AccountId = StakingIssuanceVaultId::get().into_account_truncating(); + + pub const TotalCrowdloanAllocation: Balance = 200_000_000; + pub const IssuanceCap: Balance = 4_000_000_000; + pub const LinearIssuanceBlocks: u32 = 13_140_000u32; // 5 years + pub const LiquidityMiningSplit: Perbill = Perbill::from_parts(555555556); + pub const StakingSplit: Perbill = Perbill::from_parts(444444444); + pub const ImmediateTGEReleasePercent: Percent = Percent::from_percent(20); + pub const TGEReleasePeriod: u32 = 5_256_000u32; // 2 years + pub const TGEReleaseBegin: u32 = 100_800u32; // Two weeks into chain start + + pub const TargetTge:u128 = 2_000_000_000u128; + +} + +pub struct MockIssuance; +impl ComputeIssuance for MockIssuance { + fn initialize() {} + fn compute_issuance(_n: u32) { + let staking_issuance = Self::get_staking_issuance(_n).unwrap(); + + let _ = StakeCurrency::mint( + MGA_TOKEN_ID.into(), + &StakingIssuanceVault::get(), + staking_issuance.into(), + ); + } +} + +impl GetIssuance for MockIssuance { + fn get_all_issuance(_n: u32) -> Option<(Balance, Balance)> { + unimplemented!() + } + fn get_liquidity_mining_issuance(_n: u32) -> Option { + unimplemented!() + } + fn get_staking_issuance(_n: u32) -> Option { + let to_be_issued: Balance = + IssuanceCap::get() - TargetTge::get() - TotalCrowdloanAllocation::get(); + let linear_issuance_sessions: u32 = LinearIssuanceBlocks::get() / BlocksPerRound::get(); + let linear_issuance_per_session = to_be_issued / linear_issuance_sessions as Balance; + let staking_issuance = StakingSplit::get() * linear_issuance_per_session; + Some(staking_issuance) + } +} + +pub struct TestVestingModule, B>( + PhantomData, + PhantomData, + PhantomData, +); +impl, B> MultiTokenVestingSchedule for TestVestingModule { + type Currency = C; + type Moment = B; + + fn vesting_balance( + _who: &A, + _token_id: >::CurrencyId, + ) -> Option<>::Balance> { + None + } + + fn add_vesting_schedule( + _who: &A, + _locked: >::Balance, + _per_block: >::Balance, + _starting_block: B, + _token_id: >::CurrencyId, + ) -> DispatchResult { + Ok(()) + } + + // Ensure we can call `add_vesting_schedule` without error. This should always + // be called prior to `add_vesting_schedule`. + fn can_add_vesting_schedule( + _who: &A, + _locked: >::Balance, + _per_block: >::Balance, + _starting_block: B, + _token_id: >::CurrencyId, + ) -> DispatchResult { + Ok(()) + } + + /// Remove a vesting schedule for a given account. + fn remove_vesting_schedule( + _who: &A, + _token_id: >::CurrencyId, + _schedule_index: u32, + ) -> DispatchResult { + Ok(()) + } +} + +parameter_type_with_key! { + pub ExistentialDeposits: |currency_id: TokenId| -> Balance { + match currency_id { + &MGA_TOKEN_ID => 0, + _ => 0, + } + }; +} + +parameter_types! { + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const BnbTreasurySubAccDerive: [u8; 4] = *b"bnbt"; + pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); + pub const MaxLocks: u32 = 50; + pub const MgaTokenId: TokenId = MGA_TOKEN_ID; +} + +pub struct DustRemovalWhitelist; +impl Contains for DustRemovalWhitelist { + fn contains(a: &AccountId) -> bool { + *a == TreasuryAccount::get() + } +} + +impl orml_tokens::Config for Test { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = TokenId; + type WeightInfo = (); + type ExistentialDeposits = ExistentialDeposits; + type MaxLocks = MaxLocks; + type DustRemovalWhitelist = DustRemovalWhitelist; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type CurrencyHooks = (); +} + +pub struct TokensStakingPassthrough(PhantomData); +impl StakingReservesProviderTrait + for TokensStakingPassthrough +where + T::Currency: MultiTokenReservableCurrency, +{ + fn can_bond( + token_id: TokenId, + account_id: &AccountId, + amount: Balance, + _use_balance_from: Option, + ) -> bool { + T::Currency::can_reserve(token_id, &account_id, amount) + } + + fn bond( + token_id: TokenId, + account_id: &AccountId, + amount: Balance, + _use_balance_from: Option, + ) -> DispatchResult { + T::Currency::reserve(token_id, account_id, amount) + } + + fn unbond(token_id: TokenId, account_id: &AccountId, amount: Balance) -> Balance { + T::Currency::unreserve(token_id, account_id, amount) + } +} + +impl crate::StakingBenchmarkConfig for Test {} + +parameter_types! { + pub const BlocksPerRound: u32 = 5; + pub const LeaveCandidatesDelay: u32 = 2; + pub const CandidateBondDelay: u32 = 2; + pub const LeaveDelegatorsDelay: u32 = 2; + pub const RevokeDelegationDelay: u32 = 2; + pub const DelegationBondDelay: u32 = 2; + pub const RewardPaymentDelay: u32 = 2; + pub const MinSelectedCandidates: u32 = 5; + pub const MaxCollatorCandidates: u32 = 10; + pub const MaxDelegatorsPerCandidate: u32 = 4; + pub const DefaultPayoutLimit: u32 = 15; + pub const MaxTotalDelegatorsPerCandidate: u32 = 10; + pub const MaxDelegationsPerDelegator: u32 = 4; + pub const DefaultCollatorCommission: Perbill = Perbill::from_percent(20); + pub const MinCollatorStk: u128 = 10; + pub const MinDelegation: u128 = 3; +} + +impl Config for Test { + type RuntimeEvent = RuntimeEvent; + type StakingReservesProvider = TokensStakingPassthrough; + type Currency = orml_tokens::MultiTokenCurrencyAdapter; + type MonetaryGovernanceOrigin = frame_system::EnsureRoot; + type BlocksPerRound = BlocksPerRound; + type LeaveCandidatesDelay = LeaveCandidatesDelay; + type CandidateBondDelay = CandidateBondDelay; + type LeaveDelegatorsDelay = LeaveDelegatorsDelay; + type RevokeDelegationDelay = RevokeDelegationDelay; + type DelegationBondDelay = DelegationBondDelay; + type RewardPaymentDelay = RewardPaymentDelay; + type MinSelectedCandidates = MinSelectedCandidates; + type MaxCollatorCandidates = MaxCollatorCandidates; + type MaxTotalDelegatorsPerCandidate = MaxTotalDelegatorsPerCandidate; + type MaxDelegatorsPerCandidate = MaxDelegatorsPerCandidate; + type DefaultPayoutLimit = DefaultPayoutLimit; + type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator; + type DefaultCollatorCommission = DefaultCollatorCommission; + type MinCollatorStk = MinCollatorStk; + type MinCandidateStk = MinCollatorStk; + type MinDelegation = MinDelegation; + type NativeTokenId = MgaTokenId; + type StakingLiquidityTokenValuator = TestTokenValuator; + type Issuance = MockIssuance; + type StakingIssuanceVault = StakingIssuanceVault; + type FallbackProvider = (); + type WeightInfo = (); +} + +#[derive(Default, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct TestTokenValuator {} + +impl Valuate for TestTokenValuator { + fn get_liquidity_asset( + first_asset_id: TokenId, + _second_asset_id: TokenId, + ) -> Result { + Ok(first_asset_id / 100) + } + + fn get_liquidity_token_mga_pool( + _liquidity_token_id: TokenId, + ) -> Result<(TokenId, TokenId), DispatchError> { + Ok((0_u32, 1_u32)) + } + + fn valuate_liquidity_token( + _liquidity_token_id: TokenId, + liquidity_token_amount: Balance, + ) -> Balance { + liquidity_token_amount + } + + fn scale_liquidity_by_mga_valuation( + _mga_valuation: Balance, + _liquidity_token_amount: Balance, + _mga_token_amount: Balance, + ) -> Balance { + unimplemented!("Not required in tests!") + } + + fn get_pool_state(liquidity_token_id: TokenId) -> Option<(Balance, Balance)> { + match liquidity_token_id { + 1 => Some((1, 1)), + 2 => Some((2, 1)), + 3 => Some((5, 1)), + 4 => Some((1, 1)), + 5 => Some((1, 2)), + 6 => Some((1, 5)), + _ => None, + } + } + + fn get_reserves( + _first_asset_id: TokenId, + _second_asset_id: TokenId, + ) -> Result<(Balance, Balance), DispatchError> { + todo!() + } +} + +pub(crate) struct ExtBuilder { + // tokens used for staking, these aren't backed in the xyk pallet and are just simply nominal tokens + staking_tokens: Vec<(AccountId, Balance, TokenId)>, + // [collator, amount] + collators: Vec<(AccountId, Balance, TokenId)>, + // [delegator, collator, delegation_amount] + delegations: Vec<(AccountId, AccountId, Balance)>, +} + +impl Default for ExtBuilder { + fn default() -> ExtBuilder { + ExtBuilder { staking_tokens: vec![], delegations: vec![], collators: vec![] } + } +} + +impl ExtBuilder { + pub(crate) fn with_staking_tokens( + mut self, + staking_tokens: Vec<(AccountId, Balance, TokenId)>, + ) -> Self { + self.staking_tokens = staking_tokens; + self + } + + pub(crate) fn with_default_staking_token( + mut self, + staking_tokens: Vec<(AccountId, Balance)>, + ) -> Self { + let mut init_staking_token = vec![(999u64, 10u128, 0u32), (999u64, 100u128, 1u32)]; + init_staking_token.append( + &mut staking_tokens + .iter() + .cloned() + .map(|(x, y)| (x, y, 1u32)) + .collect::>(), + ); + self.staking_tokens = init_staking_token; + self + } + + pub(crate) fn with_candidates(mut self, collators: Vec<(AccountId, Balance, TokenId)>) -> Self { + self.collators = collators; + self + } + + pub(crate) fn with_default_token_candidates( + mut self, + collators: Vec<(AccountId, Balance)>, + ) -> Self { + self.collators = collators.iter().cloned().map(|(x, y)| (x, y, 1u32)).collect(); + self + } + + pub(crate) fn with_delegations( + mut self, + delegations: Vec<(AccountId, AccountId, Balance)>, + ) -> Self { + self.delegations = delegations; + self + } + + pub(crate) fn build(self) -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::::default() + .build_storage() + .expect("Frame system builds valid default genesis config"); + + orml_tokens::GenesisConfig:: { + tokens_endowment: Default::default(), + created_tokens_for_staking: self + .staking_tokens + .iter() + .cloned() + .map(|(who, amount, token)| (who, token, amount)) + .collect(), + } + .assimilate_storage(&mut t) + .expect("Tokens storage can be assimilated"); + + stake::GenesisConfig:: { candidates: self.collators, delegations: self.delegations } + .assimilate_storage(&mut t) + .expect("Parachain Staking's storage can be assimilated"); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| { + System::set_block_number(1); + + if !StakeCurrency::exists(MGA_TOKEN_ID) { + assert_ok!(StakeCurrency::create(&99999, 100)); + } + + let current_issuance = StakeCurrency::total_issuance(MGA_TOKEN_ID); + assert!(current_issuance <= TargetTge::get()); + + assert_ok!(StakeCurrency::mint( + MGA_TOKEN_ID, + &99999, + TargetTge::get() - current_issuance + )); + }); + ext + } +} + +pub(crate) fn payout_collator_for_round(n: u64) { + let collators: Vec<::AccountId> = + RoundCollatorRewardInfo::::iter_keys() + .filter_map(|(account, round)| if round == (n as u32) { Some(account) } else { None }) + .collect(); + + for collator in collators.iter() { + Stake::payout_collator_rewards(RuntimeOrigin::signed(999), collator.clone(), None).unwrap(); + } +} + +pub(crate) fn roll_to(n: u64) { + while System::block_number() < n { + Stake::on_finalize(System::block_number()); + Tokens::on_finalize(System::block_number()); + System::on_finalize(System::block_number()); + System::set_block_number(System::block_number() + 1); + System::on_initialize(System::block_number()); + Tokens::on_initialize(System::block_number()); + Stake::on_initialize(System::block_number()); + println!("BLOCK NR: {} ", System::block_number()); + if >::should_end_session(System::block_number()) + { + if System::block_number().is_zero() { + >::start_session(Default::default()); + } else { + >::start_session(1); + } + } + } +} + +pub(crate) fn last_event() -> RuntimeEvent { + System::events().pop().expect("Event expected").event +} + +pub(crate) fn events() -> Vec> { + System::events() + .into_iter() + .map(|r| r.event) + .filter_map(|e| if let RuntimeEvent::Stake(inner) = e { Some(inner) } else { None }) + .collect::>() +} + +/// Assert input equal to the last event emitted +#[macro_export] +macro_rules! assert_last_event { + ($event:expr) => { + match &$event { + e => assert_eq!(*e, crate::mock::last_event()), + } + }; +} + +/// Compares the system events with passed in events +/// Prints highlighted diff iff assert_eq fails +#[macro_export] +macro_rules! assert_eq_events { + ($events:expr) => { + match &$events { + e => similar_asserts::assert_eq!(*e, crate::mock::events()), + } + }; +} + +/// Panics if an event is not found in the system log of events +#[macro_export] +macro_rules! assert_event_emitted { + ($event:expr) => { + match &$event { + e => { + assert!( + crate::mock::events().iter().find(|x| *x == e).is_some(), + "Event {:?} was not found in events: \n {:?}", + e, + crate::mock::events() + ); + }, + } + }; +} + +// Same storage changes as EventHandler::note_author impl +pub(crate) fn set_author(round: u32, acc: u64, pts: u32) { + >::mutate(round, |p| *p += pts); + >::mutate(round, acc, |p| *p += pts); +} + +pub type StakeCurrency = ::Currency; + +#[test] +fn geneses() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 1000, 1), + (2, 300, 2), + (3, 100, 1), + (4, 100, 1), + (5, 100, 2), + (6, 100, 2), + (7, 100, 3), + (8, 9, 3), + (9, 4, 3), + ]) + .with_candidates(vec![(1, 500, 1), (2, 200, 2)]) + .with_delegations(vec![(3, 1, 100), (4, 1, 100), (5, 2, 100), (6, 2, 100)]) + .build() + .execute_with(|| { + // collators + assert_eq!(StakeCurrency::reserved_balance(1, &1), 500); + assert_eq!(StakeCurrency::free_balance(1, &1), 500); + assert!(Stake::is_candidate(&1)); + assert_eq!(StakeCurrency::reserved_balance(2, &2), 200); + assert_eq!(StakeCurrency::free_balance(2, &2), 100); + assert!(Stake::is_candidate(&2)); + // delegators + for x in 3..5 { + assert!(Stake::is_delegator(&x)); + assert_eq!(StakeCurrency::free_balance(1, &x), 0); + assert_eq!(StakeCurrency::reserved_balance(1, &x), 100); + } + for x in 5..7 { + assert!(Stake::is_delegator(&x)); + assert_eq!(StakeCurrency::free_balance(2, &x), 0); + assert_eq!(StakeCurrency::reserved_balance(2, &x), 100); + } + // uninvolved + for x in 7..10 { + assert!(!Stake::is_delegator(&x)); + } + assert_eq!(StakeCurrency::free_balance(3, &7), 100); + assert_eq!(StakeCurrency::reserved_balance(3, &7), 0); + assert_eq!(StakeCurrency::free_balance(3, &8), 9); + assert_eq!(StakeCurrency::reserved_balance(3, &8), 0); + assert_eq!(StakeCurrency::free_balance(3, &9), 4); + assert_eq!(StakeCurrency::reserved_balance(3, &9), 0); + }); + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 1), + (4, 100, 3), + (5, 100, 3), + (6, 100, 1), + (7, 100, 1), + (8, 100, 1), + (8, 100, 2), + (9, 100, 2), + (10, 100, 1), + ]) + .with_candidates(vec![(1, 20, 1), (2, 20, 2), (3, 20, 1), (4, 20, 3), (5, 10, 3)]) + .with_delegations(vec![ + (6, 1, 10), + (7, 1, 10), + (8, 1, 10), + (8, 2, 10), + (9, 2, 10), + (10, 1, 10), + ]) + .build() + .execute_with(|| { + // collators + for x in [1, 3] { + assert!(Stake::is_candidate(&x)); + assert_eq!(StakeCurrency::free_balance(1, &x), 80); + assert_eq!(StakeCurrency::reserved_balance(1, &x), 20); + } + assert!(Stake::is_candidate(&2)); + assert_eq!(StakeCurrency::free_balance(2, &2), 80); + assert_eq!(StakeCurrency::reserved_balance(2, &2), 20); + for x in 4..5 { + assert!(Stake::is_candidate(&x)); + assert_eq!(StakeCurrency::free_balance(3, &x), 80); + assert_eq!(StakeCurrency::reserved_balance(3, &x), 20); + } + assert!(Stake::is_candidate(&5)); + assert_eq!(StakeCurrency::free_balance(3, &5), 90); + assert_eq!(StakeCurrency::reserved_balance(3, &5), 10); + // delegators + for x in [6, 7, 8, 10] { + assert!(Stake::is_delegator(&x)); + assert_eq!(StakeCurrency::free_balance(1, &x), 90); + assert_eq!(StakeCurrency::reserved_balance(1, &x), 10); + } + for x in [8, 9] { + assert!(Stake::is_delegator(&x)); + assert_eq!(StakeCurrency::free_balance(2, &x), 90); + assert_eq!(StakeCurrency::reserved_balance(2, &x), 10); + } + }); +} diff --git a/pallets/parachain-staking/src/set.rs b/pallets/parachain-staking/src/set.rs new file mode 100644 index 0000000000..f6ebc176b5 --- /dev/null +++ b/pallets/parachain-staking/src/set.rs @@ -0,0 +1,89 @@ +// Copyright 2019-2021 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +/* TODO: use orml_utilities::OrderedSet without leaking substrate v2.0 dependencies*/ +use codec::{Decode, Encode}; +use scale_info::TypeInfo; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; +use sp_runtime::RuntimeDebug; +use sp_std::prelude::*; + +/// An ordered set backed by `Vec` +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(RuntimeDebug, PartialEq, Eq, Encode, Decode, Default, Clone, TypeInfo)] +pub struct OrderedSet(pub Vec); + +impl OrderedSet { + /// Create a new empty set + pub fn new() -> Self { + Self(Vec::new()) + } + + /// Create a set from a `Vec`. + /// `v` will be sorted and dedup first. + pub fn from(mut v: Vec) -> Self { + v.sort(); + v.dedup(); + Self::from_sorted_set(v) + } + + /// Create a set from a `Vec`. + /// Assume `v` is sorted and contain unique elements. + pub fn from_sorted_set(v: Vec) -> Self { + Self(v) + } + + /// Insert an element. + /// Return true if insertion happened. + pub fn insert(&mut self, value: T) -> bool { + match self.0.binary_search(&value) { + Ok(_) => false, + Err(loc) => { + self.0.insert(loc, value); + true + }, + } + } + + /// Remove an element. + /// Return true if removal happened. + pub fn remove(&mut self, value: &T) -> bool { + match self.0.binary_search(value) { + Ok(loc) => { + self.0.remove(loc); + true + }, + Err(_) => false, + } + } + + /// Return if the set contains `value` + pub fn contains(&self, value: &T) -> bool { + self.0.binary_search(value).is_ok() + } + + /// Clear the set + pub fn clear(&mut self) { + self.0.clear(); + } +} + +impl From> for OrderedSet { + fn from(v: Vec) -> Self { + Self::from(v) + } +} diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs new file mode 100644 index 0000000000..54d7d11f7e --- /dev/null +++ b/pallets/parachain-staking/src/tests.rs @@ -0,0 +1,5086 @@ +// Copyright 2019-2021 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! # Staking Pallet Unit Tests +//! The unit tests are organized by the call they test. The order matches the order +//! of the calls in the `lib.rs`. +//! 1. Root +//! 2. Monetary Governance +//! 3. Public (Collator, Nominator) +//! 4. Miscellaneous Property-Based Tests + +use crate::mock::{ + payout_collator_for_round, roll_to, set_author, AccountId, Balance, ExtBuilder, + RuntimeEvent as MetaEvent, RuntimeOrigin as Origin, Stake, StakeCurrency, Test, MGA_TOKEN_ID, +}; + +use crate::{ + assert_eq_events, assert_event_emitted, assert_last_event, Bond, CandidateBondChange, + CandidateBondRequest, CollatorStatus, DelegationChange, DelegationRequest, DelegatorAdded, + Error, Event, MetadataUpdateAction, PairedOrLiquidityToken, PayoutRounds, RoundAggregatorInfo, + RoundCollatorRewardInfo, TotalSelected, +}; +use frame_support::{assert_noop, assert_ok, traits::tokens::currency::MultiTokenCurrency}; +use orml_tokens::MultiTokenReservableCurrency; +use sp_runtime::{traits::Zero, DispatchError, ModuleError, Perbill}; + +// ~~ ROOT ~~ + +#[test] +fn invalid_root_origin_fails() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::set_total_selected(Origin::signed(45), 6u32), + sp_runtime::DispatchError::BadOrigin + ); + assert_noop!( + Stake::set_collator_commission(Origin::signed(45), Perbill::from_percent(5)), + sp_runtime::DispatchError::BadOrigin + ); + }); +} + +// SET TOTAL SELECTED + +#[test] +fn set_total_selected_event_emits_correctly() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(Stake::set_total_selected(Origin::root(), 6u32)); + assert_last_event!(MetaEvent::Stake(Event::TotalSelectedSet(5u32, 6u32))); + }); +} + +#[test] +fn set_total_selected_storage_updates_correctly() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(Stake::total_selected(), 5u32); + assert_ok!(Stake::set_total_selected(Origin::root(), 6u32)); + assert_eq!(Stake::total_selected(), 6u32); + }); +} + +#[test] +fn cannot_set_total_selected_to_current_total_selected() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::set_total_selected(Origin::root(), 5u32), + Error::::NoWritingSameValue + ); + }); +} + +#[test] +fn cannot_set_total_selected_below_module_min() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::set_total_selected(Origin::root(), 4u32), + Error::::CannotSetBelowMin + ); + }); +} + +// SET COLLATOR COMMISSION + +#[test] +fn set_collator_commission_event_emits_correctly() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(Stake::set_collator_commission(Origin::root(), Perbill::from_percent(5))); + assert_last_event!(MetaEvent::Stake(Event::CollatorCommissionSet( + Perbill::from_percent(20), + Perbill::from_percent(5), + ))); + }); +} + +#[test] +fn set_collator_commission_storage_updates_correctly() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(Stake::collator_commission(), Perbill::from_percent(20)); + assert_ok!(Stake::set_collator_commission(Origin::root(), Perbill::from_percent(5))); + assert_eq!(Stake::collator_commission(), Perbill::from_percent(5)); + }); +} + +#[test] +fn cannot_set_collator_commission_to_current_collator_commission() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::set_collator_commission(Origin::root(), Perbill::from_percent(20)), + Error::::NoWritingSameValue + ); + }); +} + +// ~~ PUBLIC ~~ + +// JOIN CANDIDATES + +#[test] +fn join_candidates_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::join_candidates( + Origin::signed(1), + 10u128, + 1u32, + None, + 1u32, + 10000u32 + )); + assert_last_event!(MetaEvent::Stake(Event::JoinedCollatorCandidates( + 1, 10u128, 20u128, + ))); + }); +} + +#[test] +fn join_candidates_reserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &1), 0); + assert_eq!(StakeCurrency::free_balance(1, &1), 10); + assert_ok!(Stake::join_candidates( + Origin::signed(1), + 10u128, + 1u32, + None, + 1u32, + 10000u32 + )); + assert_eq!(StakeCurrency::reserved_balance(1, &1), 10); + assert_eq!(StakeCurrency::free_balance(1, &1), 0); + }); +} + +#[test] +fn join_candidates_increases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 10); + assert_ok!(Stake::join_candidates( + Origin::signed(1), + 10u128, + 1u32, + None, + 1u32, + 10000u32 + )); + assert_eq!(Stake::total(1u32), 20); + }); +} + +#[test] +fn join_candidates_creates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert!(Stake::candidate_state(1).is_none()); + assert_ok!(Stake::join_candidates( + Origin::signed(1), + 10u128, + 1u32, + None, + 1u32, + 10000u32 + )); + let candidate_state = Stake::candidate_state(1).expect("just joined => exists"); + assert_eq!(candidate_state.bond, 10u128); + }); +} + +#[test] +fn join_candidates_adds_to_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::candidate_pool().0.len(), 1usize); + assert_ok!(Stake::join_candidates( + Origin::signed(1), + 10u128, + 1u32, + None, + 1u32, + 10000u32 + )); + let candidate_pool = Stake::candidate_pool(); + assert_eq!( + candidate_pool.0[0], + Bond { owner: 1, amount: 10u128, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn cannot_join_candidates_if_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 1000)]) + .with_default_token_candidates(vec![(1, 500)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::join_candidates(Origin::signed(1), 11u128, 1u32, None, 100u32, 10000u32), + Error::::CandidateExists + ); + }); +} + +#[test] +fn cannot_join_candidates_if_delegator() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50), (2, 20)]) + .with_default_token_candidates(vec![(1, 50)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::join_candidates(Origin::signed(2), 10u128, 1u32, None, 1u32, 10000u32), + Error::::DelegatorExists + ); + }); +} + +#[test] +fn cannot_join_candidates_without_min_bond() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 1000)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::join_candidates(Origin::signed(1), 9u128, 1u32, None, 100u32, 10000u32), + Error::::CandidateBondBelowMin + ); + }); +} + +#[test] +fn cannot_join_candidates_with_more_than_available_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 500)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::join_candidates(Origin::signed(1), 501u128, 1u32, None, 100u32, 10000u32), + DispatchError::Module(ModuleError { + index: 1, + error: [0; 4], + message: Some("BalanceTooLow") + }) + ); + }); +} + +#[test] +fn insufficient_join_candidates_weight_hint_fails() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .build() + .execute_with(|| { + for i in 0..5 { + assert_noop!( + Stake::join_candidates(Origin::signed(6), 20, 1u32, None, i, 10000u32), + Error::::TooLowCandidateCountWeightHintJoinCandidates + ); + } + }); +} + +#[test] +fn sufficient_join_candidates_weight_hint_succeeds() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 20), + (2, 20), + (3, 20), + (4, 20), + (5, 20), + (6, 20), + (7, 20), + (8, 20), + (9, 20), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .build() + .execute_with(|| { + let mut count = 5u32; + for i in 6..10 { + assert_ok!(Stake::join_candidates( + Origin::signed(i), + 20, + 1u32, + None, + 10000u32, + count + )); + count += 1u32; + } + }); +} + +// SCHEDULE LEAVE CANDIDATES + +#[test] +fn leave_candidates_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_last_event!(MetaEvent::Stake(Event::CandidateScheduledExit(0, 1, 2))); + }); +} + +#[test] +fn leave_candidates_removes_candidate_from_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::candidate_pool().0.len(), 1); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert!(Stake::candidate_pool().0.is_empty()); + }); +} + +#[test] +fn cannot_leave_candidates_if_not_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_leave_candidates(Origin::signed(1), 1u32), + Error::::CandidateDNE + ); + }); +} + +#[test] +fn cannot_leave_candidates_if_already_leaving_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_noop!( + Stake::schedule_leave_candidates(Origin::signed(1), 1u32), + Error::::CandidateAlreadyLeaving + ); + }); +} + +#[test] +fn insufficient_leave_candidates_weight_hint_fails() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .build() + .execute_with(|| { + for i in 1..6 { + assert_noop!( + Stake::schedule_leave_candidates(Origin::signed(i), 4u32), + Error::::TooLowCandidateCountToLeaveCandidates + ); + } + }); +} + +#[test] +fn sufficient_leave_candidates_weight_hint_succeeds() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20)]) + .build() + .execute_with(|| { + let mut count = 5u32; + for i in 1..6 { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(i), count)); + count -= 1u32; + } + }); +} + +// EXECUTE LEAVE CANDIDATES + +#[test] +fn execute_leave_candidates_emits_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert_last_event!(MetaEvent::Stake(Event::CandidateLeft(1, 10, 0))); + }); +} + +#[test] +fn execute_leave_candidates_callable_by_any_signed() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(2), 1, 10000u32)); + }); +} + +#[test] +fn execute_leave_candidates_unreserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &1), 10); + assert_eq!(StakeCurrency::free_balance(1, &1), 0); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert_eq!(StakeCurrency::reserved_balance(1, &1), 0); + assert_eq!(StakeCurrency::free_balance(1, &1), 10); + }); +} + +#[test] +fn execute_leave_candidates_decreases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 10); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert_eq!(Stake::total(1u32), 0); + }); +} + +#[test] +fn execute_leave_candidates_removes_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + // candidate state is not immediately removed + let candidate_state = Stake::candidate_state(1).expect("just left => still exists"); + assert_eq!(candidate_state.bond, 10u128); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert!(Stake::candidate_state(1).is_none()); + }); +} + +#[test] +fn cannot_execute_leave_candidates_before_delay() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_noop!( + Stake::execute_leave_candidates(Origin::signed(3), 1, 10000u32), + Error::::CandidateCannotLeaveYet + ); + roll_to(8); + assert_noop!( + Stake::execute_leave_candidates(Origin::signed(3), 1, 10000u32), + Error::::CandidateCannotLeaveYet + ); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(3), 1, 10000u32)); + }); +} + +// CANCEL LEAVE CANDIDATES + +#[test] +fn cancel_leave_candidates_emits_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_ok!(Stake::cancel_leave_candidates(Origin::signed(1), 1)); + assert_last_event!(MetaEvent::Stake(Event::CancelledCandidateExit(1))); + }); +} + +#[test] +fn cancel_leave_candidates_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_ok!(Stake::cancel_leave_candidates(Origin::signed(1), 1)); + let candidate = Stake::candidate_state(&1).expect("just cancelled leave so exists"); + assert!(candidate.is_active()); + }); +} + +#[test] +fn cancel_leave_candidates_adds_to_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 10)]) + .with_default_token_candidates(vec![(1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1u32)); + assert_ok!(Stake::cancel_leave_candidates(Origin::signed(1), 1)); + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 10, liquidity_token: 1u32 } + ); + }); +} + +// GO OFFLINE + +#[test] +fn go_offline_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::go_offline(Origin::signed(1))); + assert_last_event!(MetaEvent::Stake(Event::CandidateWentOffline(0, 1))); + }); +} + +#[test] +fn go_offline_removes_candidate_from_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_eq!(Stake::candidate_pool().0.len(), 1); + assert_ok!(Stake::go_offline(Origin::signed(1))); + assert!(Stake::candidate_pool().0.is_empty()); + }); +} + +#[test] +fn go_offline_updates_candidate_state_to_idle() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + let candidate_state = Stake::candidate_state(1).expect("is active candidate"); + assert_eq!(candidate_state.state, CollatorStatus::Active); + assert_ok!(Stake::go_offline(Origin::signed(1))); + let candidate_state = Stake::candidate_state(1).expect("is candidate, just offline"); + assert_eq!(candidate_state.state, CollatorStatus::Idle); + }); +} + +#[test] +fn cannot_go_offline_if_not_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!(Stake::go_offline(Origin::signed(3)), Error::::CandidateDNE); + }); +} + +#[test] +fn cannot_go_offline_if_already_offline() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::go_offline(Origin::signed(1))); + assert_noop!(Stake::go_offline(Origin::signed(1)), Error::::AlreadyOffline); + }); +} + +// GO ONLINE + +#[test] +fn go_online_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::go_offline(Origin::signed(1))); + assert_ok!(Stake::go_online(Origin::signed(1))); + assert_last_event!(MetaEvent::Stake(Event::CandidateBackOnline(0, 1))); + }); +} + +#[test] +fn go_online_adds_to_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::go_offline(Origin::signed(1))); + assert!(Stake::candidate_pool().0.is_empty()); + assert_ok!(Stake::go_online(Origin::signed(1))); + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 20, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn go_online_storage_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::go_offline(Origin::signed(1))); + let candidate_state = Stake::candidate_state(1).expect("offline still exists"); + assert_eq!(candidate_state.state, CollatorStatus::Idle); + assert_ok!(Stake::go_online(Origin::signed(1))); + let candidate_state = Stake::candidate_state(1).expect("online so exists"); + assert_eq!(candidate_state.state, CollatorStatus::Active); + }); +} + +#[test] +fn cannot_go_online_if_not_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!(Stake::go_online(Origin::signed(3)), Error::::CandidateDNE); + }); +} + +#[test] +fn cannot_go_online_if_already_online() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_noop!(Stake::go_online(Origin::signed(1)), Error::::AlreadyActive); + }); +} + +#[test] +fn cannot_go_online_if_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_noop!( + Stake::go_online(Origin::signed(1)), + Error::::CannotGoOnlineIfLeaving + ); + }); +} + +// SCHEDULE CANDIDATE BOND MORE + +#[test] +fn schedule_candidate_bond_more_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + assert_last_event!(MetaEvent::Stake(Event::CandidateBondMoreRequested(1, 30, 2,))); + }); +} + +#[test] +fn schedule_candidate_bond_more_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + let state = Stake::candidate_state(&1).expect("request bonded more so exists"); + assert_eq!( + state.request, + Some(CandidateBondRequest { + amount: 30, + change: CandidateBondChange::Increase, + when_executable: 2, + }) + ); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_more_if_request_exists() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 40)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 5, None)); + assert_noop!( + Stake::schedule_candidate_bond_more(Origin::signed(1), 5, None), + Error::::PendingCandidateRequestAlreadyExists + ); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_more_if_not_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_candidate_bond_more(Origin::signed(6), 50, None), + Error::::CandidateDNE + ); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_more_if_insufficient_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_candidate_bond_more(Origin::signed(1), 1, None), + Error::::InsufficientBalance + ); + }); +} + +#[test] +fn can_schedule_candidate_bond_more_if_leaving_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_more_if_exited_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert_noop!( + Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None), + Error::::CandidateDNE + ); + }); +} + +// CANDIDATE BOND LESS + +#[test] +fn schedule_candidate_bond_less_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + assert_last_event!(MetaEvent::Stake(Event::CandidateBondLessRequested(1, 10, 2,))); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_less_if_request_exists() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 5)); + assert_noop!( + Stake::schedule_candidate_bond_less(Origin::signed(1), 5), + Error::::PendingCandidateRequestAlreadyExists + ); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_less_if_not_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_candidate_bond_less(Origin::signed(6), 50), + Error::::CandidateDNE + ); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_less_if_new_total_below_min_candidate_stk() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_candidate_bond_less(Origin::signed(1), 21), + Error::::CandidateBondBelowMin + ); + }); +} + +#[test] +fn can_schedule_candidate_bond_less_if_leaving_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + }); +} + +#[test] +fn cannot_schedule_candidate_bond_less_if_exited_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + roll_to(10); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert_noop!( + Stake::schedule_candidate_bond_less(Origin::signed(1), 10), + Error::::CandidateDNE + ); + }); +} + +// EXECUTE CANDIDATE BOND REQUEST +// 1. BOND MORE REQUEST + +#[test] +fn execute_candidate_bond_more_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_last_event!(MetaEvent::Stake(Event::CandidateBondedMore(1, 30, 50))); + }); +} + +#[test] +fn execute_candidate_bond_more_reserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &1), 20); + assert_eq!(StakeCurrency::free_balance(1, &1), 30); + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_eq!(StakeCurrency::reserved_balance(1, &1), 50); + assert_eq!(StakeCurrency::free_balance(1, &1), 0); + }); +} + +#[test] +fn execute_candidate_bond_more_increases_total() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + let mut total = Stake::total(1u32); + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + total += 30; + assert_eq!(Stake::total(1u32), total); + }); +} + +#[test] +fn execute_candidate_bond_more_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + let candidate_state = Stake::candidate_state(1).expect("updated => exists"); + assert_eq!(candidate_state.bond, 20); + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + let candidate_state = Stake::candidate_state(1).expect("updated => exists"); + assert_eq!(candidate_state.bond, 50); + }); +} + +#[test] +fn execute_candidate_bond_more_updates_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 20, liquidity_token: 1u32 } + ); + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 30, None)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 50, liquidity_token: 1u32 } + ); + }); +} + +// 2. BOND LESS REQUEST + +#[test] +fn execute_candidate_bond_less_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 50)]) + .with_default_token_candidates(vec![(1, 50)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 30)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_last_event!(MetaEvent::Stake(Event::CandidateBondedLess(1, 30, 20))); + }); +} + +#[test] +fn execute_candidate_bond_less_unreserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &1), 30); + assert_eq!(StakeCurrency::free_balance(1, &1), 0); + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_eq!(StakeCurrency::reserved_balance(1, &1), 20); + assert_eq!(StakeCurrency::free_balance(1, &1), 10); + }); +} + +#[test] +fn execute_candidate_bond_less_decreases_total() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + let mut total = Stake::total(1u32); + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + total -= 10; + assert_eq!(Stake::total(1u32), total); + }); +} + +#[test] +fn execute_candidate_bond_less_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + let candidate_state = Stake::candidate_state(1).expect("updated => exists"); + assert_eq!(candidate_state.bond, 30); + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + let candidate_state = Stake::candidate_state(1).expect("updated => exists"); + assert_eq!(candidate_state.bond, 20); + }); +} + +#[test] +fn execute_candidate_bond_less_updates_candidate_pool() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 30, liquidity_token: 1u32 } + ); + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + roll_to(10); + assert_ok!(Stake::execute_candidate_bond_request(Origin::signed(1), 1, None)); + assert_eq!( + Stake::candidate_pool().0[0], + Bond { owner: 1, amount: 20, liquidity_token: 1u32 } + ); + }); +} + +// CANCEL CANDIDATE BOND REQUEST +// 1. CANCEL CANDIDATE BOND MORE REQUEST + +#[test] +fn cancel_candidate_bond_more_emits_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 40)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 10, None)); + assert_ok!(Stake::cancel_candidate_bond_request(Origin::signed(1))); + assert_last_event!(MetaEvent::Stake(Event::CancelledCandidateBondChange( + 1, + CandidateBondRequest { + amount: 10, + change: CandidateBondChange::Increase, + when_executable: 2, + }, + ))); + }); +} + +#[test] +fn cancel_candidate_bond_more_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 40)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 10, None)); + assert_ok!(Stake::cancel_candidate_bond_request(Origin::signed(1))); + assert!(Stake::candidate_state(&1).unwrap().request.is_none()); + }); +} + +#[test] +fn only_candidate_can_cancel_candidate_bond_more_request() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 40)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_more(Origin::signed(1), 10, None)); + assert_noop!( + Stake::cancel_candidate_bond_request(Origin::signed(2)), + Error::::CandidateDNE + ); + }); +} + +// 2. CANCEL CANDIDATE BOND LESS REQUEST + +#[test] +fn cancel_candidate_bond_less_emits_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + assert_ok!(Stake::cancel_candidate_bond_request(Origin::signed(1))); + assert_last_event!(MetaEvent::Stake(Event::CancelledCandidateBondChange( + 1, + CandidateBondRequest { + amount: 10, + change: CandidateBondChange::Decrease, + when_executable: 2, + }, + ))); + }); +} + +#[test] +fn cancel_candidate_bond_less_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + assert_ok!(Stake::cancel_candidate_bond_request(Origin::signed(1))); + assert!(Stake::candidate_state(&1).unwrap().request.is_none()); + }); +} + +#[test] +fn only_candidate_can_cancel_candidate_bond_less_request() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_candidate_bond_less(Origin::signed(1), 10)); + assert_noop!( + Stake::cancel_candidate_bond_request(Origin::signed(2)), + Error::::CandidateDNE + ); + }); +} + +// NOMINATE + +#[test] +fn delegate_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_ok!(Stake::delegate(Origin::signed(2), 1, 10, None, 0, 0)); + assert_last_event!(MetaEvent::Stake(Event::Delegation( + 2, + 10, + 1, + DelegatorAdded::AddedToTop { new_total: 40 }, + ))); + }); +} + +#[test] +fn delegate_reserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &2), 0); + assert_eq!(StakeCurrency::free_balance(1, &2), 10); + assert_ok!(Stake::delegate(Origin::signed(2), 1, 10, None, 0, 0)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 10); + assert_eq!(StakeCurrency::free_balance(1, &2), 0); + }); +} + +#[test] +fn delegate_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert!(Stake::delegator_state(2).is_none()); + assert_ok!(Stake::delegate(Origin::signed(2), 1, 10, None, 0, 0)); + let delegator_state = Stake::delegator_state(2).expect("just delegated => exists"); + assert_eq!( + delegator_state.delegations.0[0], + Bond { owner: 1, amount: 10, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn delegate_updates_collator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + let candidate_state = Stake::candidate_state(1).expect("registered in genesis"); + assert_eq!(candidate_state.total_backing, 30); + assert_eq!(candidate_state.total_counted, 30); + assert!(candidate_state.top_delegations.is_empty()); + assert_ok!(Stake::delegate(Origin::signed(2), 1, 10, None, 0, 0)); + let candidate_state = Stake::candidate_state(1).expect("just delegated => exists"); + assert_eq!(candidate_state.total_backing, 40); + assert_eq!(candidate_state.total_counted, 40); + assert_eq!( + candidate_state.top_delegations[0], + Bond { owner: 2, amount: 10, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn can_delegate_immediately_after_other_join_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20)]) + .with_default_token_candidates(vec![(999, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::join_candidates(Origin::signed(1), 20, 1u32, None, 10000u32, 1)); + assert_ok!(Stake::delegate(Origin::signed(2), 1, 20, None, 0, 0)); + }); +} + +#[test] +fn can_delegate_if_revoking() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 30), (3, 20), (4, 20)]) + .with_default_token_candidates(vec![(1, 20), (3, 20), (4, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_ok!(Stake::delegate(Origin::signed(2), 4, 10, None, 0, 2)); + }); +} + +#[test] +fn cannot_delegate_if_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20)]) + .with_default_token_candidates(vec![(1, 20), (3, 20)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_noop!( + Stake::delegate(Origin::signed(2), 3, 10, None, 0, 1), + Error::::CannotDelegateIfLeaving + ); + }); +} + +#[test] +fn cannot_delegate_if_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20)]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::delegate(Origin::signed(2), 1, 10, None, 0, 0), + Error::::CandidateExists + ); + }); +} + +#[test] +fn cannot_delegate_if_already_delegated() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 30)]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(2, 1, 20)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::delegate(Origin::signed(2), 1, 10, None, 1, 1), + Error::::AlreadyDelegatedCandidate + ); + }); +} + +#[test] +fn cannot_delegate_more_than_max_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 50), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_default_token_candidates(vec![(1, 20), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10), (2, 4, 10), (2, 5, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::delegate(Origin::signed(2), 6, 10, None, 0, 4), + Error::::ExceedMaxDelegationsPerDelegator, + ); + }); +} + +#[test] +fn sufficient_delegate_weight_hint_succeeds() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 20), + (2, 20), + (3, 20), + (4, 20), + (5, 20), + (6, 20), + (7, 20), + (8, 20), + (9, 20), + (10, 20), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .with_delegations(vec![(3, 1, 10), (4, 1, 10), (5, 1, 10), (6, 1, 10)]) + .build() + .execute_with(|| { + let mut count = 4u32; + for i in 7..11 { + assert_ok!(Stake::delegate(Origin::signed(i), 1, 10, None, count, 0u32)); + count += 1u32; + } + let mut count = 0u32; + for i in 3..11 { + assert_ok!(Stake::delegate(Origin::signed(i), 2, 10, None, count, 1u32)); + count += 1u32; + } + }); +} + +#[test] +fn insufficient_delegate_weight_hint_fails() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 20), + (2, 20), + (3, 20), + (4, 20), + (5, 20), + (6, 20), + (7, 20), + (8, 20), + (9, 20), + (10, 20), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .with_delegations(vec![(3, 1, 10), (4, 1, 10), (5, 1, 10), (6, 1, 10)]) + .build() + .execute_with(|| { + let mut count = 3u32; + for i in 7..11 { + assert_noop!( + Stake::delegate(Origin::signed(i), 1, 10, None, count, 0u32), + Error::::TooLowCandidateDelegationCountToDelegate + ); + } + // to set up for next error test + count = 4u32; + for i in 7..11 { + assert_ok!(Stake::delegate(Origin::signed(i), 1, 10, None, count, 0u32)); + count += 1u32; + } + count = 0u32; + for i in 3..11 { + assert_noop!( + Stake::delegate(Origin::signed(i), 2, 10, None, count, 0u32), + Error::::TooLowDelegationCountToDelegate + ); + count += 1u32; + } + }); +} + +// SCHEDULE LEAVE DELEGATORS + +#[test] +fn schedule_leave_delegators_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_last_event!(MetaEvent::Stake(Event::DelegatorExitScheduled(0, 2, 2))); + }); +} + +#[test] +fn cannot_schedule_leave_delegators_if_already_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_noop!( + Stake::schedule_leave_delegators(Origin::signed(2)), + Error::::DelegatorAlreadyLeaving + ); + }); +} + +#[test] +fn cannot_schedule_leave_delegators_if_not_delegator() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_leave_delegators(Origin::signed(2)), + Error::::DelegatorDNE + ); + }); +} + +// EXECUTE LEAVE DELEGATORS + +#[test] +fn execute_leave_delegators_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(2), 2, 1)); + assert_event_emitted!(Event::DelegatorLeft(2, 10)); + }); +} + +#[test] +fn execute_leave_delegators_unreserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &2), 10); + assert_eq!(StakeCurrency::free_balance(1, &2), 0); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(2), 2, 1)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 0); + assert_eq!(StakeCurrency::free_balance(1, &2), 10); + }); +} + +#[test] +fn execute_leave_delegators_decreases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(2), 2, 1)); + assert_eq!(Stake::total(1u32), 30); + }); +} + +#[test] +fn execute_leave_delegators_removes_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert!(Stake::delegator_state(2).is_some()); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(2), 2, 1)); + assert!(Stake::delegator_state(2).is_none()); + }); +} + +#[test] +fn execute_leave_delegators_removes_delegations_from_collator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 100), (2, 20), (3, 20), (4, 20), (5, 20)]) + .with_default_token_candidates(vec![(2, 20), (3, 20), (4, 20), (5, 20)]) + .with_delegations(vec![(1, 2, 10), (1, 3, 10), (1, 4, 10), (1, 5, 10)]) + .build() + .execute_with(|| { + for i in 2..6 { + let candidate_state = + Stake::candidate_state(i).expect("initialized in ext builder"); + assert_eq!( + candidate_state.top_delegations[0], + Bond { owner: 1, amount: 10, liquidity_token: 1u32 } + ); + assert_eq!(candidate_state.delegators.0[0], 1); + assert_eq!(candidate_state.total_backing, 30); + } + assert_eq!(Stake::delegator_state(1).unwrap().delegations.0.len(), 4usize); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(1))); + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(1), 1, 10)); + for i in 2..6 { + let candidate_state = + Stake::candidate_state(i).expect("initialized in ext builder"); + assert!(candidate_state.top_delegations.is_empty()); + assert!(candidate_state.delegators.0.is_empty()); + assert_eq!(candidate_state.total_backing, 20); + } + }); +} + +#[test] +fn cannot_execute_leave_delegators_before_delay() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_noop!( + Stake::execute_leave_delegators(Origin::signed(2), 2, 1), + Error::::DelegatorCannotLeaveYet + ); + // can execute after delay + roll_to(10); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(2), 2, 1)); + }); +} + +#[test] +fn insufficient_execute_leave_delegators_weight_hint_fails() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(3, 1, 10), (4, 1, 10), (5, 1, 10), (6, 1, 10)]) + .build() + .execute_with(|| { + for i in 3..7 { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(i))); + } + roll_to(10); + for i in 3..7 { + assert_noop!( + Stake::execute_leave_delegators(Origin::signed(i), i, 0), + Error::::TooLowDelegationCountToLeaveDelegators + ); + } + }); +} + +#[test] +fn sufficient_execute_leave_delegators_weight_hint_succeeds() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(3, 1, 10), (4, 1, 10), (5, 1, 10), (6, 1, 10)]) + .build() + .execute_with(|| { + for i in 3..7 { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(i))); + } + roll_to(10); + for i in 3..7 { + assert_ok!(Stake::execute_leave_delegators(Origin::signed(i), i, 1)); + } + }); +} + +// CANCEL LEAVE DELEGATORS + +#[test] +fn cancel_leave_delegators_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_ok!(Stake::cancel_leave_delegators(Origin::signed(2))); + assert_last_event!(MetaEvent::Stake(Event::DelegatorExitCancelled(2))); + }); +} + +#[test] +fn cancel_leave_delegators_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_ok!(Stake::cancel_leave_delegators(Origin::signed(2))); + let delegator = Stake::delegator_state(&2).expect("just cancelled exit so exists"); + assert!(delegator.is_active()); + }); +} + +// SCHEDULE REVOKE DELEGATION + +#[test] +fn revoke_delegation_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_last_event!(MetaEvent::Stake(Event::DelegationRevocationScheduled(0, 2, 1, 2,))); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_event_emitted!(Event::DelegatorLeftCandidate(2, 1, 10, 30)); + }); +} + +#[test] +fn can_revoke_delegation_if_revoking_another_delegation() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + // this is an exit implicitly because last delegation revoked + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 3)); + }); +} + +#[test] +fn can_revoke_if_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 3)); + }); +} + +#[test] +fn cannot_revoke_delegation_if_not_delegator() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_revoke_delegation(Origin::signed(2), 1), + Error::::DelegatorDNE + ); + }); +} + +#[test] +fn cannot_revoke_delegation_that_dne() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_revoke_delegation(Origin::signed(2), 3), + Error::::DelegationDNE + ); + }); +} + +#[test] +// See `cannot_execute_revoke_delegation_below_min_delegator_stake` for where the "must be above +// MinDelegatorStk" rule is now enforced. +fn can_schedule_revoke_delegation_below_min_delegator_stake() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 8), (3, 20)]) + .with_default_token_candidates(vec![(1, 20), (3, 20)]) + .with_delegations(vec![(2, 1, 5), (2, 3, 3)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + }); +} + +// SCHEDULE DELEGATOR BOND MORE + +#[test] +fn delegator_bond_more_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + assert_last_event!(MetaEvent::Stake(Event::DelegationIncreaseScheduled(2, 1, 5, 2,))); + }); +} + +#[test] +fn delegator_bond_more_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + let state = Stake::delegator_state(&2).expect("just request bonded less so exists"); + assert_eq!( + state.requests().get(&1), + Some(&DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Increase + }) + ); + }); +} + +#[test] +fn can_delegator_bond_more_if_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + }); +} + +#[test] +fn cannot_delegator_bond_more_if_revoking() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 25), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None), + Error::::PendingDelegationRequestAlreadyExists + ); + }); +} + +#[test] +fn cannot_delegator_bond_more_if_not_delegator() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None), + Error::::DelegatorDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_more_if_candidate_dne() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 3, 5, None), + Error::::DelegationDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_more_if_delegation_dne() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 3, 5, None), + Error::::DelegationDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_more_if_insufficient_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None), + Error::::InsufficientBalance + ); + }); +} + +// DELEGATOR BOND LESS + +#[test] +fn delegator_bond_less_event_emits_correctly() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + assert_last_event!(MetaEvent::Stake(Event::DelegationDecreaseScheduled(2, 1, 5, 2,))); + }); +} + +#[test] +fn delegator_bond_less_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + let state = Stake::delegator_state(&2).expect("just request bonded less so exists"); + assert_eq!( + state.requests().get(&1), + Some(&DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Decrease + }) + ); + }); +} + +#[test] +fn can_delegator_bond_less_if_leaving() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(2))); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 1)); + }); +} + +#[test] +fn cannot_delegator_bond_less_if_revoking() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 25), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 1), + Error::::PendingDelegationRequestAlreadyExists + ); + }); +} + +#[test] +fn cannot_delegator_bond_less_if_not_delegator() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5), + Error::::DelegatorDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_less_if_candidate_dne() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 3, 5), + Error::::DelegationDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_less_if_delegation_dne() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 3, 5), + Error::::DelegationDNE + ); + }); +} + +#[test] +fn cannot_delegator_bond_less_more_than_total_delegation() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 11), + Error::::DelegationBelowMin + ); + }); +} + +#[test] +fn cannot_delegator_bond_less_below_min_delegation() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 8), + Error::::DelegationBelowMin + ); + }); +} + +// EXECUTE PENDING DELEGATION REQUEST + +// 1. REVOKE DELEGATION + +#[test] +fn execute_revoke_delegation_emits_exit_event_if_exit_happens() { + // last delegation is revocation + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_event_emitted!(Event::DelegatorLeftCandidate(2, 1, 10, 30)); + assert_event_emitted!(Event::DelegatorLeft(2, 10)); + }); +} + +#[test] +fn revoke_delegation_executes_exit_if_last_delegation() { + // last delegation is revocation + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_event_emitted!(Event::DelegatorLeftCandidate(2, 1, 10, 30)); + assert_event_emitted!(Event::DelegatorLeft(2, 10)); + }); +} + +#[test] +fn execute_revoke_delegation_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_event_emitted!(Event::DelegatorLeftCandidate(2, 1, 10, 30)); + }); +} + +#[test] +fn execute_revoke_delegation_unreserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &2), 10); + assert_eq!(StakeCurrency::free_balance(1, &2), 0); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 0); + assert_eq!(StakeCurrency::free_balance(1, &2), 10); + }); +} + +#[test] +fn execute_revoke_delegation_adds_revocation_to_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert!(Stake::delegator_state(2).expect("exists").requests.requests.get(&1).is_none()); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert!(Stake::delegator_state(2).expect("exists").requests.requests.get(&1).is_some()); + }); +} + +#[test] +fn execute_revoke_delegation_removes_revocation_from_delegator_state_upon_execution() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 20)]) + .with_default_token_candidates(vec![(1, 30), (3, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert!(Stake::delegator_state(2).expect("exists").requests.requests.get(&1).is_none()); + }); +} + +#[test] +fn execute_revoke_delegation_decreases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(Stake::total(1u32), 30); + }); +} + +#[test] +fn execute_revoke_delegation_for_last_delegation_removes_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert!(Stake::delegator_state(2).is_some()); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + // this will be confusing for people + // if status is leaving, then execute_delegation_request works if last delegation + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert!(Stake::delegator_state(2).is_none()); + }); +} + +#[test] +fn execute_revoke_delegation_removes_delegation_from_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::candidate_state(1).expect("exists").delegators.0.len(), 1usize); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert!(Stake::candidate_state(1).expect("exists").delegators.0.is_empty()); + }); +} + +#[test] +fn can_execute_revoke_delegation_for_leaving_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + // can execute delegation request for leaving candidate + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + }); +} + +#[test] +fn can_execute_leave_candidates_if_revoking_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + // revocation executes during execute leave candidates (callable by anyone) + assert_ok!(Stake::execute_leave_candidates(Origin::signed(1), 1, 10000u32)); + assert!(!Stake::is_delegator(&2)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 0); + assert_eq!(StakeCurrency::free_balance(1, &2), 10); + }); +} + +#[test] +fn delegator_bond_more_after_revoke_delegation_does_not_effect_exit() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 30), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_noop!( + Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 10, None), + Error::::PendingDelegationRequestAlreadyExists + ); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 3, 10, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 3, None)); + assert!(Stake::is_delegator(&2)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 20); + assert_eq!(StakeCurrency::free_balance(1, &2), 10); + }); +} + +#[test] +fn delegator_bond_less_after_revoke_delegation_does_not_effect_exit() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 30), (3, 30)]) + .with_default_token_candidates(vec![(1, 30), (3, 30)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_last_event!(MetaEvent::Stake(Event::DelegationRevocationScheduled(0, 2, 1, 2,))); + assert_noop!( + Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 2), + Error::::PendingDelegationRequestAlreadyExists + ); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 3, 2)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 3, None)); + assert_last_event!(MetaEvent::Stake(Event::DelegationDecreased(2, 3, 2, true))); + assert!(Stake::is_delegator(&2)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 8); + assert_eq!(StakeCurrency::free_balance(1, &2), 22); + }); +} + +// 2. EXECUTE BOND MORE + +#[test] +fn execute_delegator_bond_more_reserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &2), 10); + assert_eq!(StakeCurrency::free_balance(1, &2), 5); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 15); + assert_eq!(StakeCurrency::free_balance(1, &2), 0); + }); +} + +#[test] +fn execute_delegator_bond_more_increases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(Stake::total(1u32), 45); + }); +} + +#[test] +fn execute_delegator_bond_more_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + }); +} + +#[test] +fn execute_delegator_bond_more_updates_candidate_state_top_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!( + Stake::candidate_state(1).expect("exists").top_delegations[0], + Bond { owner: 2, amount: 10, liquidity_token: 1u32 } + ); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!( + Stake::candidate_state(1).expect("exists").top_delegations[0], + Bond { owner: 2, amount: 15, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn execute_delegator_bond_more_updates_candidate_state_bottom_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 20), (3, 20), (4, 20), (5, 20), (6, 20)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10), (3, 1, 20), (4, 1, 20), (5, 1, 20), (6, 1, 20)]) + .build() + .execute_with(|| { + assert_eq!( + Stake::candidate_state(1).expect("exists").bottom_delegations[0], + Bond { owner: 2, amount: 10, liquidity_token: 1u32 } + ); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_last_event!(MetaEvent::Stake(Event::DelegationIncreased(2, 1, 5, false))); + assert_eq!( + Stake::candidate_state(1).expect("exists").bottom_delegations[0], + Bond { owner: 2, amount: 15, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn execute_delegator_bond_more_increases_total() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(Stake::total(1u32), 45); + }); +} + +#[test] +fn can_execute_delegator_bond_more_for_leaving_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + roll_to(10); + // can execute bond more delegation request for leaving candidate + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + }); +} + +// 3, EXECUTE BOND LESS + +#[test] +fn execute_delegator_bond_less_unreserves_balance() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::reserved_balance(1, &2), 10); + assert_eq!(StakeCurrency::free_balance(1, &2), 0); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(StakeCurrency::reserved_balance(1, &2), 5); + assert_eq!(StakeCurrency::free_balance(1, &2), 5); + }); +} + +#[test] +fn execute_delegator_bond_less_decreases_total_staked() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(Stake::total(1u32), 35); + }); +} + +#[test] +fn execute_delegator_bond_less_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + }); +} + +#[test] +fn execute_delegator_bond_less_updates_candidate_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!( + Stake::candidate_state(1).expect("exists").top_delegations[0], + Bond { owner: 2, amount: 10, liquidity_token: 1u32 } + ); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!( + Stake::candidate_state(1).expect("exists").top_delegations[0], + Bond { owner: 2, amount: 5, liquidity_token: 1u32 } + ); + }); +} + +#[test] +fn execute_delegator_bond_less_decreases_total() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(Stake::total(1u32), 40); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_eq!(Stake::total(1u32), 35); + }); +} + +#[test] +fn execute_delegator_bond_less_updates_just_bottom_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 10), (3, 11), (4, 12), (5, 14), (6, 15)]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(2, 1, 10), (3, 1, 11), (4, 1, 12), (5, 1, 14), (6, 1, 15)]) + .build() + .execute_with(|| { + let pre_call_collator_state = + Stake::candidate_state(&1).expect("delegated by all so exists"); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 2)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + let post_call_collator_state = + Stake::candidate_state(&1).expect("delegated by all so exists"); + let mut not_equal = false; + for Bond { owner, amount, .. } in pre_call_collator_state.bottom_delegations { + for Bond { owner: post_owner, amount: post_amount, .. } in + &post_call_collator_state.bottom_delegations + { + if &owner == post_owner { + if &amount != post_amount { + not_equal = true; + break + } + } + } + } + assert!(not_equal); + let mut equal = true; + for Bond { owner, amount, .. } in pre_call_collator_state.top_delegations { + for Bond { owner: post_owner, amount: post_amount, .. } in + &post_call_collator_state.top_delegations + { + if &owner == post_owner { + if &amount != post_amount { + equal = false; + break + } + } + } + } + assert!(equal); + assert_eq!( + pre_call_collator_state.total_backing - 2, + post_call_collator_state.total_backing + ); + assert_eq!( + pre_call_collator_state.total_counted, + post_call_collator_state.total_counted + ); + }); +} + +#[test] +fn execute_delegator_bond_less_does_not_delete_bottom_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 10), (3, 11), (4, 12), (5, 14), (6, 15)]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(2, 1, 10), (3, 1, 11), (4, 1, 12), (5, 1, 14), (6, 1, 15)]) + .build() + .execute_with(|| { + let pre_call_collator_state = + Stake::candidate_state(&1).expect("delegated by all so exists"); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(6), 1, 4)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(6), 6, 1, None)); + let post_call_collator_state = + Stake::candidate_state(&1).expect("delegated by all so exists"); + let mut equal = true; + for Bond { owner, amount, .. } in pre_call_collator_state.bottom_delegations { + for Bond { owner: post_owner, amount: post_amount, .. } in + &post_call_collator_state.bottom_delegations + { + if &owner == post_owner { + if &amount != post_amount { + equal = false; + break + } + } + } + } + assert!(equal); + let mut not_equal = false; + for Bond { owner, amount, .. } in pre_call_collator_state.top_delegations { + for Bond { owner: post_owner, amount: post_amount, .. } in + &post_call_collator_state.top_delegations + { + if &owner == post_owner { + if &amount != post_amount { + not_equal = true; + break + } + } + } + } + assert!(not_equal); + assert_eq!( + pre_call_collator_state.total_backing - 4, + post_call_collator_state.total_backing + ); + assert_eq!( + pre_call_collator_state.total_counted - 4, + post_call_collator_state.total_counted + ); + }); +} + +#[test] +fn can_execute_delegator_bond_less_for_leaving_candidate() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 15)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(1), 1)); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + roll_to(10); + // can execute bond more delegation request for leaving candidate + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + }); +} + +// CANCEL PENDING DELEGATION REQUEST +// 1. CANCEL REVOKE DELEGATION + +#[test] +fn cancel_revoke_delegation_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + assert_last_event!(MetaEvent::Stake(Event::CancelledDelegationRequest( + 2, + DelegationRequest { + collator: 1, + amount: 10, + when_executable: 2, + action: DelegationChange::Revoke, + }, + ))); + }); +} + +#[test] +fn cancel_revoke_delegation_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 10)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + let state = Stake::delegator_state(&2).unwrap(); + assert_eq!( + state.requests().get(&1), + Some(&DelegationRequest { + collator: 1, + amount: 10, + when_executable: 2, + action: DelegationChange::Revoke, + }) + ); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + let state = Stake::delegator_state(&2).unwrap(); + assert!(state.requests().get(&1).is_none()); + }); +} + +// 2. CANCEL DELEGATOR BOND MORE + +#[test] +fn cancel_delegator_bond_more_emits_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + assert_last_event!(MetaEvent::Stake(Event::CancelledDelegationRequest( + 2, + DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Increase, + }, + ))); + }); +} + +#[test] +fn cancel_delegator_bond_more_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(2), 1, 5, None)); + let state = Stake::delegator_state(&2).unwrap(); + assert_eq!( + state.requests().get(&1), + Some(&DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Increase, + }) + ); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + let state = Stake::delegator_state(&2).unwrap(); + assert!(state.requests().get(&1).is_none()); + }); +} + +// 3. CANCEL DELEGATOR BOND LESS + +#[test] +fn cancel_delegator_bond_less_correct_event() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 15)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + assert_last_event!(MetaEvent::Stake(Event::CancelledDelegationRequest( + 2, + DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Decrease, + }, + ))); + }); +} + +#[test] +fn cancel_delegator_bond_less_updates_delegator_state() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 30), (2, 15)]) + .with_default_token_candidates(vec![(1, 30)]) + .with_delegations(vec![(2, 1, 15)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(2), 1, 5)); + let state = Stake::delegator_state(&2).unwrap(); + assert_eq!( + state.requests().get(&1), + Some(&DelegationRequest { + collator: 1, + amount: 5, + when_executable: 2, + action: DelegationChange::Decrease, + }) + ); + assert_ok!(Stake::cancel_delegation_request(Origin::signed(2), 1)); + let state = Stake::delegator_state(&2).unwrap(); + assert!(state.requests().get(&1).is_none()); + }); +} + +// ~~ PROPERTY-BASED TESTS ~~ + +#[test] +fn delegator_schedule_revocation() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 40), (3, 20), (4, 20), (5, 20)]) + .with_default_token_candidates(vec![(1, 20), (3, 20), (4, 20), (5, 20)]) + .with_delegations(vec![(2, 1, 10), (2, 3, 10), (2, 4, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 1)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 1, None)); + assert_ok!(Stake::delegate(Origin::signed(2), 5, 10, None, 0, 2)); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 3)); + assert_ok!(Stake::schedule_revoke_delegation(Origin::signed(2), 4)); + roll_to(20); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 3, None)); + assert_ok!(Stake::execute_delegation_request(Origin::signed(2), 2, 4, None)); + }); +} + +// #[ignore] +#[test] +fn reworked_deprecated_test() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 600, 0), + (1, 100, 1), + (2, 100, 1), + (3, 100, 1), + (4, 100, 1), + (5, 100, 1), + (6, 100, 1), + (7, 100, 1), + (8, 100, 1), + (9, 100, 1), + (10, 100, 1), + (11, 1, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) + .with_delegations(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) + .build() + .execute_with(|| { + assert_eq!(StakeCurrency::free_balance(1, &11), 1); + roll_to(8); + // chooses top TotalSelectedCandidates (5), in order + let mut expected = vec![ + Event::CollatorChosen(2, 1, 50), + Event::CollatorChosen(2, 2, 40), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::CollatorChosen(2, 5, 10), + Event::NewRound(5, 1, 5, 140), + ]; + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(1, &11), 1); + roll_to(10); + let mut new0 = vec![ + Event::CollatorChosen(3, 1, 50), + Event::CollatorChosen(3, 2, 40), + Event::CollatorChosen(3, 3, 20), + Event::CollatorChosen(3, 4, 20), + Event::CollatorChosen(3, 5, 10), + Event::NewRound(10, 2, 5, 140), + ]; + expected.append(&mut new0); + assert_eq_events!(expected.clone()); + // ~ set block author as 1 for all blocks this round + set_author(2, 1, 100); + roll_to(20); + payout_collator_for_round(2); + // distribute total issuance to collator 1 and its delegators 6, 7, 19 + let mut new = vec![ + Event::CollatorChosen(4, 1, 50), + Event::CollatorChosen(4, 2, 40), + Event::CollatorChosen(4, 3, 20), + Event::CollatorChosen(4, 4, 20), + Event::CollatorChosen(4, 5, 10), + Event::NewRound(15, 3, 5, 140), + Event::CollatorChosen(5, 1, 50), + Event::CollatorChosen(5, 2, 40), + Event::CollatorChosen(5, 3, 20), + Event::CollatorChosen(5, 4, 20), + Event::CollatorChosen(5, 5, 10), + Event::NewRound(20, 4, 5, 140), + Event::Rewarded(2, 1, 157), + Event::DelegatorDueReward(2, 1, 6, 48), + Event::DelegatorDueReward(2, 1, 7, 48), + Event::DelegatorDueReward(2, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + // ~ set block author as 1 for all blocks this round + set_author(3, 1, 100); + set_author(4, 1, 100); + set_author(5, 1, 100); + // 1. ensure delegators are paid for 2 rounds after they leave + assert_noop!( + Stake::schedule_leave_delegators(Origin::signed(66)), + Error::::DelegatorDNE + ); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(6))); + // fast forward to block in which delegator 6 exit executes + roll_to(30); + payout_collator_for_round(3); + payout_collator_for_round(4); + assert_ok!(Stake::execute_leave_delegators(Origin::signed(6), 6, 10)); + roll_to(35); + payout_collator_for_round(5); + let mut new2 = vec![ + Event::DelegatorExitScheduled(4, 6, 6), + Event::CollatorChosen(6, 1, 50), + Event::CollatorChosen(6, 2, 40), + Event::CollatorChosen(6, 3, 20), + Event::CollatorChosen(6, 4, 20), + Event::CollatorChosen(6, 5, 10), + Event::NewRound(25, 5, 5, 140), + Event::CollatorChosen(7, 1, 50), + Event::CollatorChosen(7, 2, 40), + Event::CollatorChosen(7, 3, 20), + Event::CollatorChosen(7, 4, 20), + Event::CollatorChosen(7, 5, 10), + Event::NewRound(30, 6, 5, 140), + Event::Rewarded(3, 1, 157), + Event::DelegatorDueReward(3, 1, 6, 48), + Event::DelegatorDueReward(3, 1, 7, 48), + Event::DelegatorDueReward(3, 1, 10, 48), + Event::Rewarded(4, 1, 157), + Event::DelegatorDueReward(4, 1, 6, 48), + Event::DelegatorDueReward(4, 1, 7, 48), + Event::DelegatorDueReward(4, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + Event::DelegatorLeftCandidate(6, 1, 10, 40), + Event::DelegatorLeft(6, 10), + Event::CollatorChosen(8, 1, 40), + Event::CollatorChosen(8, 2, 40), + Event::CollatorChosen(8, 3, 20), + Event::CollatorChosen(8, 4, 20), + Event::CollatorChosen(8, 5, 10), + Event::NewRound(35, 7, 5, 130), + Event::Rewarded(5, 1, 157), + Event::DelegatorDueReward(5, 1, 6, 48), + Event::DelegatorDueReward(5, 1, 7, 48), + Event::DelegatorDueReward(5, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new2); + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + // 6 won't be paid for this round because they left already + set_author(6, 1, 100); + roll_to(40); + payout_collator_for_round(6); + // keep paying 6 + let mut new3 = vec![ + Event::CollatorChosen(9, 1, 40), + Event::CollatorChosen(9, 2, 40), + Event::CollatorChosen(9, 3, 20), + Event::CollatorChosen(9, 4, 20), + Event::CollatorChosen(9, 5, 10), + Event::NewRound(40, 8, 5, 130), + Event::Rewarded(6, 1, 157), + Event::DelegatorDueReward(6, 1, 6, 48), + Event::DelegatorDueReward(6, 1, 7, 48), + Event::DelegatorDueReward(6, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new3); + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + set_author(7, 1, 100); + roll_to(45); + payout_collator_for_round(7); + // no more paying 6 + let mut new4 = vec![ + Event::CollatorChosen(10, 1, 40), + Event::CollatorChosen(10, 2, 40), + Event::CollatorChosen(10, 3, 20), + Event::CollatorChosen(10, 4, 20), + Event::CollatorChosen(10, 5, 10), + Event::NewRound(45, 9, 5, 130), + Event::Rewarded(7, 1, 157), + Event::DelegatorDueReward(7, 1, 6, 48), + Event::DelegatorDueReward(7, 1, 7, 48), + Event::DelegatorDueReward(7, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new4); + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + set_author(8, 1, 100); + assert_ok!(Stake::delegate(Origin::signed(8), 1, 10, None, 10, 10)); + roll_to(50); + payout_collator_for_round(8); + // new delegation is not rewarded yet + let mut new5 = vec![ + Event::Delegation(8, 10, 1, DelegatorAdded::AddedToTop { new_total: 50 }), + Event::CollatorChosen(11, 1, 50), + Event::CollatorChosen(11, 2, 40), + Event::CollatorChosen(11, 3, 20), + Event::CollatorChosen(11, 4, 20), + Event::CollatorChosen(11, 5, 10), + Event::NewRound(50, 10, 5, 140), + Event::Rewarded(8, 1, 182), + Event::DelegatorDueReward(8, 1, 7, 61), + Event::DelegatorDueReward(8, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new5); + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + set_author(9, 1, 100); + set_author(10, 1, 100); + roll_to(55); + payout_collator_for_round(9); + // new delegation is still not rewarded yet + let mut new6 = vec![ + Event::CollatorChosen(12, 1, 50), + Event::CollatorChosen(12, 2, 40), + Event::CollatorChosen(12, 3, 20), + Event::CollatorChosen(12, 4, 20), + Event::CollatorChosen(12, 5, 10), + Event::NewRound(55, 11, 5, 140), + Event::Rewarded(9, 1, 182), + Event::DelegatorDueReward(9, 1, 7, 61), + Event::DelegatorDueReward(9, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new6); + assert_eq_events!(expected.clone()); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + roll_to(60); + payout_collator_for_round(10); + // new delegation is rewarded, 2 rounds after joining (`RewardPaymentDelay` is 2) + let mut new7 = vec![ + Event::CollatorChosen(13, 1, 50), + Event::CollatorChosen(13, 2, 40), + Event::CollatorChosen(13, 3, 20), + Event::CollatorChosen(13, 4, 20), + Event::CollatorChosen(13, 5, 10), + Event::NewRound(60, 12, 5, 140), + Event::Rewarded(10, 1, 182), + Event::DelegatorDueReward(10, 1, 7, 61), + Event::DelegatorDueReward(10, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new7); + assert_eq_events!(expected); + assert_eq!(StakeCurrency::free_balance(0, &11), 0); + }); +} + +#[test] +fn paid_collator_commission_matches_config() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 600, 0), + (1, 100, 1), + (2, 100, 1), + (3, 100, 1), + (4, 100, 1), + (5, 100, 1), + (6, 100, 1), + ]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![(2, 1, 10), (3, 1, 10)]) + .build() + .execute_with(|| { + roll_to(7); + // chooses top TotalSelectedCandidates (5), in order + let mut expected = vec![Event::CollatorChosen(2, 1, 40), Event::NewRound(5, 1, 1, 40)]; + assert_eq_events!(expected.clone()); + assert_ok!(Stake::join_candidates( + Origin::signed(4), + 20u128, + 1u32, + None, + 100u32, + 10000u32 + )); + assert_last_event!(MetaEvent::Stake(Event::JoinedCollatorCandidates( + 4, 20u128, 60u128, + ))); + roll_to(8); + assert_ok!(Stake::delegate(Origin::signed(5), 4, 10, None, 10, 10)); + assert_ok!(Stake::delegate(Origin::signed(6), 4, 10, None, 10, 10)); + roll_to(10); + let mut new = vec![ + Event::JoinedCollatorCandidates(4, 20, 60), + Event::Delegation(5, 10, 4, DelegatorAdded::AddedToTop { new_total: 30 }), + Event::Delegation(6, 10, 4, DelegatorAdded::AddedToTop { new_total: 40 }), + Event::CollatorChosen(3, 1, 40), + Event::CollatorChosen(3, 4, 40), + Event::NewRound(10, 2, 2, 80), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + roll_to(15); + let mut new1 = vec![ + Event::CollatorChosen(4, 1, 40), + Event::CollatorChosen(4, 4, 40), + Event::NewRound(15, 3, 2, 80), + ]; + expected.append(&mut new1); + assert_eq_events!(expected.clone()); + // only reward author with id 4 + set_author(3, 4, 100); + roll_to(25); + payout_collator_for_round(3); + // 20% of 10 is commission + due_portion (4) = 2 + 4 = 6 + // all delegator payouts are 10-2 = 8 * stake_pct + let mut new2 = vec![ + Event::CollatorChosen(5, 1, 40), + Event::CollatorChosen(5, 4, 40), + Event::NewRound(20, 4, 2, 80), + Event::CollatorChosen(6, 1, 40), + Event::CollatorChosen(6, 4, 40), + Event::NewRound(25, 5, 2, 80), + Event::Rewarded(3, 4, 182), + Event::DelegatorDueReward(3, 4, 5, 61), + Event::DelegatorDueReward(3, 4, 6, 61), + Event::CollatorRewardsDistributed(4, PayoutRounds::All), + ]; + expected.append(&mut new2); + assert_eq_events!(expected); + }); +} + +#[test] +fn collator_exit_executes_after_delay() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 1000), + (2, 300), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + (8, 9), + (9, 4), + ]) + .with_default_token_candidates(vec![(1, 500), (2, 200)]) + .with_delegations(vec![(3, 1, 100), (4, 1, 100), (5, 2, 100), (6, 2, 100)]) + .build() + .execute_with(|| { + roll_to(11); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(2), 2)); + let info = Stake::candidate_state(&2).unwrap(); + assert_eq!(info.state, CollatorStatus::Leaving(4)); + roll_to(21); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(2), 2, 10000u32)); + // we must exclude leaving collators from rewards while + // holding them retroactively accountable for previous faults + // (within the last T::SlashingWindow blocks) + let expected = vec![ + Event::CollatorChosen(2, 1, 700), + Event::CollatorChosen(2, 2, 400), + Event::NewRound(5, 1, 2, 1100), + Event::CollatorChosen(3, 1, 700), + Event::CollatorChosen(3, 2, 400), + Event::NewRound(10, 2, 2, 1100), + Event::CandidateScheduledExit(2, 2, 4), + Event::CollatorChosen(4, 1, 700), + Event::NewRound(15, 3, 1, 700), + Event::CollatorChosen(5, 1, 700), + Event::NewRound(20, 4, 1, 700), + Event::CandidateLeft(2, 400, 700), + ]; + assert_eq_events!(expected); + }); +} + +#[test] +fn collator_selection_chooses_top_candidates() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 1000), + (2, 1000), + (3, 1000), + (4, 1000), + (5, 1000), + (6, 1000), + (7, 33), + (8, 33), + (9, 33), + ]) + .with_default_token_candidates(vec![(1, 100), (2, 90), (3, 80), (4, 70), (5, 60), (6, 50)]) + .build() + .execute_with(|| { + roll_to(8); + // should choose top TotalSelectedCandidates (5), in order + let expected = vec![ + Event::CollatorChosen(2, 1, 100), + Event::CollatorChosen(2, 2, 90), + Event::CollatorChosen(2, 3, 80), + Event::CollatorChosen(2, 4, 70), + Event::CollatorChosen(2, 5, 60), + Event::NewRound(5, 1, 5, 400), + ]; + assert_eq_events!(expected.clone()); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(6), 6)); + assert_last_event!(MetaEvent::Stake(Event::CandidateScheduledExit(1, 6, 3))); + roll_to(21); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(6), 6, 10000u32)); + assert_ok!(Stake::join_candidates( + Origin::signed(6), + 69u128, + 1u32, + None, + 100u32, + 10000u32 + )); + assert_last_event!(MetaEvent::Stake(Event::JoinedCollatorCandidates( + 6, 69u128, 469u128, + ))); + roll_to(27); + // should choose top TotalSelectedCandidates (5), in order + let expected = vec![ + Event::CollatorChosen(2, 1, 100), + Event::CollatorChosen(2, 2, 90), + Event::CollatorChosen(2, 3, 80), + Event::CollatorChosen(2, 4, 70), + Event::CollatorChosen(2, 5, 60), + Event::NewRound(5, 1, 5, 400), + Event::CandidateScheduledExit(1, 6, 3), + Event::CollatorChosen(3, 1, 100), + Event::CollatorChosen(3, 2, 90), + Event::CollatorChosen(3, 3, 80), + Event::CollatorChosen(3, 4, 70), + Event::CollatorChosen(3, 5, 60), + Event::NewRound(10, 2, 5, 400), + Event::CollatorChosen(4, 1, 100), + Event::CollatorChosen(4, 2, 90), + Event::CollatorChosen(4, 3, 80), + Event::CollatorChosen(4, 4, 70), + Event::CollatorChosen(4, 5, 60), + Event::NewRound(15, 3, 5, 400), + Event::CollatorChosen(5, 1, 100), + Event::CollatorChosen(5, 2, 90), + Event::CollatorChosen(5, 3, 80), + Event::CollatorChosen(5, 4, 70), + Event::CollatorChosen(5, 5, 60), + Event::NewRound(20, 4, 5, 400), + Event::CandidateLeft(6, 50, 400), + Event::JoinedCollatorCandidates(6, 69, 469), + Event::CollatorChosen(6, 1, 100), + Event::CollatorChosen(6, 2, 90), + Event::CollatorChosen(6, 3, 80), + Event::CollatorChosen(6, 4, 70), + Event::CollatorChosen(6, 6, 69), + Event::NewRound(25, 5, 5, 409), + ]; + assert_eq_events!(expected); + }); +} + +#[test] +fn payout_distribution_to_solo_collators() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 1000, 0), + (1, 1000, 1), + (2, 1000, 1), + (3, 1000, 1), + (4, 1000, 1), + (5, 1000, 1), + (6, 1000, 1), + (7, 33, 1), + (8, 33, 1), + (9, 33, 1), + ]) + .with_default_token_candidates(vec![(1, 100), (2, 90), (3, 80), (4, 70), (5, 60), (6, 50)]) + .build() + .execute_with(|| { + roll_to(8); + // should choose top TotalCandidatesSelected (5), in order + let mut expected = vec![ + Event::CollatorChosen(2, 1, 100), + Event::CollatorChosen(2, 2, 90), + Event::CollatorChosen(2, 3, 80), + Event::CollatorChosen(2, 4, 70), + Event::CollatorChosen(2, 5, 60), + Event::NewRound(5, 1, 5, 400), + ]; + assert_eq_events!(expected.clone()); + // ~ set block author as 1 for all blocks this round + set_author(2, 1, 100); + roll_to(16); + // pay total issuance to 1 + let mut new = vec![ + Event::CollatorChosen(3, 1, 100), + Event::CollatorChosen(3, 2, 90), + Event::CollatorChosen(3, 3, 80), + Event::CollatorChosen(3, 4, 70), + Event::CollatorChosen(3, 5, 60), + Event::NewRound(10, 2, 5, 400), + Event::CollatorChosen(4, 1, 100), + Event::CollatorChosen(4, 2, 90), + Event::CollatorChosen(4, 3, 80), + Event::CollatorChosen(4, 4, 70), + Event::CollatorChosen(4, 5, 60), + Event::NewRound(15, 3, 5, 400), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + // ~ set block author as 1 for 3 blocks this round + set_author(4, 1, 60); + // ~ set block author as 2 for 2 blocks this round + set_author(4, 2, 40); + roll_to(26); + payout_collator_for_round(2); + // pay 60% total issuance to 1 and 40% total issuance to 2 + let mut new1 = vec![ + Event::CollatorChosen(5, 1, 100), + Event::CollatorChosen(5, 2, 90), + Event::CollatorChosen(5, 3, 80), + Event::CollatorChosen(5, 4, 70), + Event::CollatorChosen(5, 5, 60), + Event::NewRound(20, 4, 5, 400), + Event::CollatorChosen(6, 1, 100), + Event::CollatorChosen(6, 2, 90), + Event::CollatorChosen(6, 3, 80), + Event::CollatorChosen(6, 4, 70), + Event::CollatorChosen(6, 5, 60), + Event::NewRound(25, 5, 5, 400), + Event::Rewarded(2, 1, 304), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new1); + assert_eq_events!(expected.clone()); + // ~ each collator produces 1 block this round + set_author(6, 1, 20); + set_author(6, 2, 20); + set_author(6, 3, 20); + set_author(6, 4, 20); + set_author(6, 5, 20); + roll_to(36); + payout_collator_for_round(4); + payout_collator_for_round(5); + // pay 20% issuance for all collators + let mut new2 = vec![ + Event::CollatorChosen(7, 1, 100), + Event::CollatorChosen(7, 2, 90), + Event::CollatorChosen(7, 3, 80), + Event::CollatorChosen(7, 4, 70), + Event::CollatorChosen(7, 5, 60), + Event::NewRound(30, 6, 5, 400), + Event::CollatorChosen(8, 1, 100), + Event::CollatorChosen(8, 2, 90), + Event::CollatorChosen(8, 3, 80), + Event::CollatorChosen(8, 4, 70), + Event::CollatorChosen(8, 5, 60), + Event::NewRound(35, 7, 5, 400), + Event::Rewarded(4, 1, 182), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + Event::Rewarded(4, 2, 121), + Event::CollatorRewardsDistributed(2, PayoutRounds::All), + ]; + expected.append(&mut new2); + assert_eq_events!(expected); + + roll_to(46); + payout_collator_for_round(6); + payout_collator_for_round(7); + // pay 20% issuance for all collators + let mut new3 = vec![ + Event::CollatorChosen(9, 1, 100), + Event::CollatorChosen(9, 2, 90), + Event::CollatorChosen(9, 3, 80), + Event::CollatorChosen(9, 4, 70), + Event::CollatorChosen(9, 5, 60), + Event::NewRound(40, 8, 5, 400), + Event::CollatorChosen(10, 1, 100), + Event::CollatorChosen(10, 2, 90), + Event::CollatorChosen(10, 3, 80), + Event::CollatorChosen(10, 4, 70), + Event::CollatorChosen(10, 5, 60), + Event::NewRound(45, 9, 5, 400), + Event::Rewarded(6, 5, 60), + Event::CollatorRewardsDistributed(5, PayoutRounds::All), + Event::Rewarded(6, 3, 60), + Event::CollatorRewardsDistributed(3, PayoutRounds::All), + Event::Rewarded(6, 1, 60), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + Event::Rewarded(6, 4, 60), + Event::CollatorRewardsDistributed(4, PayoutRounds::All), + Event::Rewarded(6, 2, 60), + Event::CollatorRewardsDistributed(2, PayoutRounds::All), + ]; + expected.append(&mut new3); + assert_eq_events!(expected); + // check that distributing rewards clears awarded pts + assert!(Stake::awarded_pts(1, 1).is_zero()); + assert!(Stake::awarded_pts(4, 1).is_zero()); + assert!(Stake::awarded_pts(4, 2).is_zero()); + assert!(Stake::awarded_pts(6, 1).is_zero()); + assert!(Stake::awarded_pts(6, 2).is_zero()); + assert!(Stake::awarded_pts(6, 3).is_zero()); + assert!(Stake::awarded_pts(6, 4).is_zero()); + assert!(Stake::awarded_pts(6, 5).is_zero()); + }); +} + +#[test] +fn multiple_delegations() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + (8, 100), + (9, 100), + (10, 100), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) + .with_delegations(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) + .build() + .execute_with(|| { + roll_to(8); + // chooses top TotalSelectedCandidates (5), in order + let mut expected = vec![ + Event::CollatorChosen(2, 1, 50), + Event::CollatorChosen(2, 2, 40), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::CollatorChosen(2, 5, 10), + Event::NewRound(5, 1, 5, 140), + ]; + assert_eq_events!(expected.clone()); + assert_ok!(Stake::delegate(Origin::signed(6), 2, 10, None, 10, 10)); + assert_ok!(Stake::delegate(Origin::signed(6), 3, 10, None, 10, 10)); + assert_ok!(Stake::delegate(Origin::signed(6), 4, 10, None, 10, 10)); + roll_to(16); + let mut new = vec![ + Event::Delegation(6, 10, 2, DelegatorAdded::AddedToTop { new_total: 50 }), + Event::Delegation(6, 10, 3, DelegatorAdded::AddedToTop { new_total: 30 }), + Event::Delegation(6, 10, 4, DelegatorAdded::AddedToTop { new_total: 30 }), + Event::CollatorChosen(3, 1, 50), + Event::CollatorChosen(3, 2, 50), + Event::CollatorChosen(3, 3, 30), + Event::CollatorChosen(3, 4, 30), + Event::CollatorChosen(3, 5, 10), + Event::NewRound(10, 2, 5, 170), + Event::CollatorChosen(4, 1, 50), + Event::CollatorChosen(4, 2, 50), + Event::CollatorChosen(4, 3, 30), + Event::CollatorChosen(4, 4, 30), + Event::CollatorChosen(4, 5, 10), + Event::NewRound(15, 3, 5, 170), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + roll_to(21); + assert_ok!(Stake::delegate(Origin::signed(7), 2, 80, None, 10, 10)); + assert_ok!(Stake::delegate(Origin::signed(10), 2, 10, None, 10, 10),); + roll_to(26); + let mut new2 = vec![ + Event::CollatorChosen(5, 1, 50), + Event::CollatorChosen(5, 2, 50), + Event::CollatorChosen(5, 3, 30), + Event::CollatorChosen(5, 4, 30), + Event::CollatorChosen(5, 5, 10), + Event::NewRound(20, 4, 5, 170), + Event::Delegation(7, 80, 2, DelegatorAdded::AddedToTop { new_total: 130 }), + Event::Delegation(10, 10, 2, DelegatorAdded::AddedToBottom), + Event::CollatorChosen(6, 1, 50), + Event::CollatorChosen(6, 2, 130), + Event::CollatorChosen(6, 3, 30), + Event::CollatorChosen(6, 4, 30), + Event::CollatorChosen(6, 5, 10), + Event::NewRound(25, 5, 5, 250), + ]; + expected.append(&mut new2); + assert_eq_events!(expected.clone()); + assert_ok!(Stake::schedule_leave_candidates(Origin::signed(2), 5)); + assert_last_event!(MetaEvent::Stake(Event::CandidateScheduledExit(5, 2, 7))); + roll_to(31); + let mut new3 = vec![ + Event::CandidateScheduledExit(5, 2, 7), + Event::CollatorChosen(7, 1, 50), + Event::CollatorChosen(7, 3, 30), + Event::CollatorChosen(7, 4, 30), + Event::CollatorChosen(7, 5, 10), + Event::NewRound(30, 6, 4, 120), + ]; + expected.append(&mut new3); + assert_eq_events!(expected); + // verify that delegations are removed after collator leaves, not before + assert_eq!(Stake::delegator_state(7).unwrap().delegations.0.len(), 2usize); + assert_eq!(Stake::delegator_state(6).unwrap().delegations.0.len(), 4usize); + assert_eq!(StakeCurrency::reserved_balance(1, &6), 40); + assert_eq!(StakeCurrency::reserved_balance(1, &7), 90); + assert_eq!(StakeCurrency::free_balance(1, &6), 60); + assert_eq!(StakeCurrency::free_balance(1, &7), 10); + roll_to(40); + assert_ok!(Stake::execute_leave_candidates(Origin::signed(2), 2, 10000u32)); + assert_eq!(Stake::delegator_state(7).unwrap().delegations.0.len(), 1usize); + assert_eq!(Stake::delegator_state(6).unwrap().delegations.0.len(), 3usize); + assert_eq!(StakeCurrency::reserved_balance(1, &6), 30); + assert_eq!(StakeCurrency::reserved_balance(1, &7), 10); + assert_eq!(StakeCurrency::free_balance(1, &6), 70); + assert_eq!(StakeCurrency::free_balance(1, &7), 90); + }); +} + +#[test] +fn payouts_follow_delegation_changes() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 1000, 0), + (1, 100, 1), + (2, 100, 1), + (3, 100, 1), + (4, 100, 1), + (5, 100, 1), + (6, 100, 1), + (7, 100, 1), + (8, 100, 1), + (9, 100, 1), + (10, 100, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) + .with_delegations(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) + .build() + .execute_with(|| { + roll_to(10); + // chooses top TotalSelectedCandidates (5), in order + let mut expected = vec![ + Event::CollatorChosen(2, 1, 50), + Event::CollatorChosen(2, 2, 40), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::CollatorChosen(2, 5, 10), + Event::NewRound(5, 1, 5, 140), + Event::CollatorChosen(3, 1, 50), + Event::CollatorChosen(3, 2, 40), + Event::CollatorChosen(3, 3, 20), + Event::CollatorChosen(3, 4, 20), + Event::CollatorChosen(3, 5, 10), + Event::NewRound(10, 2, 5, 140), + ]; + assert_eq_events!(expected.clone()); + // ~ set block author as 1 for all blocks this round + set_author(2, 1, 100); + roll_to(16); + // distribute total issuance to collator 1 and its delegators 6, 7, 19 + let mut new = vec![ + Event::CollatorChosen(4, 1, 50), + Event::CollatorChosen(4, 2, 40), + Event::CollatorChosen(4, 3, 20), + Event::CollatorChosen(4, 4, 20), + Event::CollatorChosen(4, 5, 10), + Event::NewRound(15, 3, 5, 140), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + + // ~ set block author as 1 for all blocks this round + set_author(3, 1, 100); + set_author(4, 1, 100); + set_author(5, 1, 100); + set_author(6, 1, 100); + // 1. ensure delegators are paid for 2 rounds after they leave + assert_noop!( + Stake::schedule_leave_delegators(Origin::signed(66)), + Error::::DelegatorDNE + ); + assert_ok!(Stake::schedule_leave_delegators(Origin::signed(6))); + // fast forward to block in which delegator 6 exit executes + roll_to(25); + + println!("BLAH: {:?}", RoundCollatorRewardInfo::::iter().collect::>()); + payout_collator_for_round(2); + payout_collator_for_round(3); + + assert_ok!(Stake::execute_leave_delegators(Origin::signed(6), 6, 10)); + // keep paying 6 (note: inflation is in terms of total issuance so that's why 1 is 21) + let mut new2 = vec![ + Event::DelegatorExitScheduled(3, 6, 5), + Event::CollatorChosen(5, 1, 50), + Event::CollatorChosen(5, 2, 40), + Event::CollatorChosen(5, 3, 20), + Event::CollatorChosen(5, 4, 20), + Event::CollatorChosen(5, 5, 10), + Event::NewRound(20, 4, 5, 140), + Event::CollatorChosen(6, 1, 50), + Event::CollatorChosen(6, 2, 40), + Event::CollatorChosen(6, 3, 20), + Event::CollatorChosen(6, 4, 20), + Event::CollatorChosen(6, 5, 10), + Event::NewRound(25, 5, 5, 140), + Event::Rewarded(2, 1, 157), + Event::DelegatorDueReward(2, 1, 6, 48), + Event::DelegatorDueReward(2, 1, 7, 48), + Event::DelegatorDueReward(2, 1, 10, 48), + Event::Rewarded(3, 1, 157), + Event::DelegatorDueReward(3, 1, 6, 48), + Event::DelegatorDueReward(3, 1, 7, 48), + Event::DelegatorDueReward(3, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + Event::DelegatorLeftCandidate(6, 1, 10, 40), + Event::DelegatorLeft(6, 10), + ]; + expected.append(&mut new2); + assert_eq_events!(expected.clone()); + // 6 won't be paid for this round because they left already + set_author(7, 1, 100); + roll_to(35); + + payout_collator_for_round(4); + payout_collator_for_round(5); + + // keep paying 6 + let mut new3 = vec![ + Event::CollatorChosen(7, 1, 40), + Event::CollatorChosen(7, 2, 40), + Event::CollatorChosen(7, 3, 20), + Event::CollatorChosen(7, 4, 20), + Event::CollatorChosen(7, 5, 10), + Event::NewRound(30, 6, 5, 130), + Event::CollatorChosen(8, 1, 40), + Event::CollatorChosen(8, 2, 40), + Event::CollatorChosen(8, 3, 20), + Event::CollatorChosen(8, 4, 20), + Event::CollatorChosen(8, 5, 10), + Event::NewRound(35, 7, 5, 130), + Event::Rewarded(5, 1, 157), + Event::DelegatorDueReward(5, 1, 6, 48), + Event::DelegatorDueReward(5, 1, 7, 48), + Event::DelegatorDueReward(5, 1, 10, 48), + Event::Rewarded(4, 1, 157), + Event::DelegatorDueReward(4, 1, 6, 48), + Event::DelegatorDueReward(4, 1, 7, 48), + Event::DelegatorDueReward(4, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new3); + assert_eq_events!(expected.clone()); + set_author(8, 1, 100); + roll_to(40); + + payout_collator_for_round(6); + + // no more paying 6 + let mut new4 = vec![ + Event::CollatorChosen(9, 1, 40), + Event::CollatorChosen(9, 2, 40), + Event::CollatorChosen(9, 3, 20), + Event::CollatorChosen(9, 4, 20), + Event::CollatorChosen(9, 5, 10), + Event::NewRound(40, 8, 5, 130), + Event::Rewarded(6, 1, 157), + Event::DelegatorDueReward(6, 1, 6, 48), + Event::DelegatorDueReward(6, 1, 7, 48), + Event::DelegatorDueReward(6, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new4); + assert_eq_events!(expected.clone()); + set_author(9, 1, 100); + assert_ok!(Stake::delegate(Origin::signed(8), 1, 10, None, 10, 10)); + roll_to(45); + + payout_collator_for_round(7); + + // new delegation is not rewarded yet + let mut new5 = vec![ + Event::Delegation(8, 10, 1, DelegatorAdded::AddedToTop { new_total: 50 }), + Event::CollatorChosen(10, 1, 50), + Event::CollatorChosen(10, 2, 40), + Event::CollatorChosen(10, 3, 20), + Event::CollatorChosen(10, 4, 20), + Event::CollatorChosen(10, 5, 10), + Event::NewRound(45, 9, 5, 140), + Event::Rewarded(7, 1, 182), + Event::DelegatorDueReward(7, 1, 7, 61), + Event::DelegatorDueReward(7, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new5); + assert_eq_events!(expected.clone()); + set_author(10, 1, 100); + roll_to(50); + payout_collator_for_round(8); + // new delegation not rewarded yet + let mut new6 = vec![ + Event::CollatorChosen(11, 1, 50), + Event::CollatorChosen(11, 2, 40), + Event::CollatorChosen(11, 3, 20), + Event::CollatorChosen(11, 4, 20), + Event::CollatorChosen(11, 5, 10), + Event::NewRound(50, 10, 5, 140), + Event::Rewarded(8, 1, 182), + Event::DelegatorDueReward(8, 1, 7, 61), + Event::DelegatorDueReward(8, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new6); + assert_eq_events!(expected.clone()); + roll_to(55); + payout_collator_for_round(9); + // new delegation is rewarded for first time + // 2 rounds after joining (`RewardPaymentDelay` = 2) + let mut new7 = vec![ + Event::CollatorChosen(12, 1, 50), + Event::CollatorChosen(12, 2, 40), + Event::CollatorChosen(12, 3, 20), + Event::CollatorChosen(12, 4, 20), + Event::CollatorChosen(12, 5, 10), + Event::NewRound(55, 11, 5, 140), + Event::Rewarded(9, 1, 182), + Event::DelegatorDueReward(9, 1, 7, 61), + Event::DelegatorDueReward(9, 1, 10, 61), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new7); + assert_eq_events!(expected); + roll_to(60); + payout_collator_for_round(10); + // new delegation is rewarded for first time + // 2 rounds after joining (`RewardPaymentDelay` = 2) + let mut new8 = vec![ + Event::CollatorChosen(13, 1, 50), + Event::CollatorChosen(13, 2, 40), + Event::CollatorChosen(13, 3, 20), + Event::CollatorChosen(13, 4, 20), + Event::CollatorChosen(13, 5, 10), + Event::NewRound(60, 12, 5, 140), + Event::Rewarded(10, 1, 157), + Event::DelegatorDueReward(10, 1, 7, 48), + Event::DelegatorDueReward(10, 1, 8, 48), + Event::DelegatorDueReward(10, 1, 10, 48), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + expected.append(&mut new8); + assert_eq_events!(expected); + }); +} + +#[test] +fn delegations_merged_before_reward_payout() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 280, 0), + (1, 20, 1), + (2, 20, 1), + (3, 20, 1), + (4, 20, 1), + (5, 120, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)]) + .with_delegations(vec![(5, 1, 30), (5, 2, 30), (5, 3, 30), (5, 4, 30)]) + .build() + .execute_with(|| { + roll_to(8); + set_author(1, 1, 1); + set_author(1, 2, 1); + set_author(1, 3, 1); + set_author(1, 4, 1); + + roll_to(16); + + payout_collator_for_round(1); + + assert_eq!(StakeCurrency::free_balance(0u32, &1), 39); + let expected_events = vec![ + Event::CollatorChosen(2, 1, 50), + Event::CollatorChosen(2, 2, 50), + Event::CollatorChosen(2, 3, 50), + Event::CollatorChosen(2, 4, 50), + Event::NewRound(5, 1, 4, 200), + Event::CollatorChosen(3, 1, 50), + Event::CollatorChosen(3, 2, 50), + Event::CollatorChosen(3, 3, 50), + Event::CollatorChosen(3, 4, 50), + Event::NewRound(10, 2, 4, 200), + Event::CollatorChosen(4, 1, 50), + Event::CollatorChosen(4, 2, 50), + Event::CollatorChosen(4, 3, 50), + Event::CollatorChosen(4, 4, 50), + Event::NewRound(15, 3, 4, 200), + Event::Rewarded(1, 3, 39), + Event::DelegatorDueReward(1, 3, 5, 36), + Event::CollatorRewardsDistributed(3, PayoutRounds::All), + Event::Rewarded(1, 1, 39), + Event::DelegatorDueReward(1, 1, 5, 36), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + Event::Rewarded(1, 4, 39), + Event::DelegatorDueReward(1, 4, 5, 36), + Event::CollatorRewardsDistributed(4, PayoutRounds::All), + Event::Rewarded(1, 2, 39), + Event::DelegatorDueReward(1, 2, 5, 36), + Event::CollatorRewardsDistributed(2, PayoutRounds::All), + ]; + assert_eq_events!(expected_events); + }); +} + +#[test] +// MaxDelegatorsPerCandidate = 4 +fn bottom_delegations_are_empty_when_top_delegations_not_full() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 20), (2, 10), (3, 10), (4, 10), (5, 10)]) + .with_default_token_candidates(vec![(1, 20)]) + .build() + .execute_with(|| { + // no top delegators => no bottom delegators + let collator_state = Stake::candidate_state(1).unwrap(); + assert!(collator_state.top_delegations.is_empty()); + assert!(collator_state.bottom_delegations.is_empty()); + // 1 delegator => 1 top delegator, 0 bottom delegators + assert_ok!(Stake::delegate(Origin::signed(2), 1, 10, None, 10, 10)); + let collator_state = Stake::candidate_state(1).unwrap(); + assert_eq!(collator_state.top_delegations.len(), 1usize); + assert!(collator_state.bottom_delegations.is_empty()); + // 2 delegators => 2 top delegators, 0 bottom delegators + assert_ok!(Stake::delegate(Origin::signed(3), 1, 10, None, 10, 10)); + let collator_state = Stake::candidate_state(1).unwrap(); + assert_eq!(collator_state.top_delegations.len(), 2usize); + assert!(collator_state.bottom_delegations.is_empty()); + // 3 delegators => 3 top delegators, 0 bottom delegators + assert_ok!(Stake::delegate(Origin::signed(4), 1, 10, None, 10, 10)); + let collator_state = Stake::candidate_state(1).unwrap(); + assert_eq!(collator_state.top_delegations.len(), 3usize); + assert!(collator_state.bottom_delegations.is_empty()); + // 4 delegators => 4 top delegators, 0 bottom delegators + assert_ok!(Stake::delegate(Origin::signed(5), 1, 10, None, 10, 10)); + let collator_state = Stake::candidate_state(1).unwrap(); + assert_eq!(collator_state.top_delegations.len(), 4usize); + assert!(collator_state.bottom_delegations.is_empty()); + }); +} + +#[test] +// MaxDelegatorsPerCandidate = 4 +fn candidate_pool_updates_when_total_counted_changes() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 20), + (3, 19), + (4, 20), + (5, 21), + (6, 22), + (7, 15), + (8, 16), + (9, 17), + (10, 18), + ]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![ + (3, 1, 11), + (4, 1, 12), + (5, 1, 13), + (6, 1, 14), + (7, 1, 15), + (8, 1, 16), + (9, 1, 17), + (10, 1, 18), + ]) + .build() + .execute_with(|| { + fn is_candidate_pool_bond(account: u64, bond: u128) { + let pool = Stake::candidate_pool(); + for candidate in pool.0 { + if candidate.owner == account { + println!( + "Stake::candidate_state(candidate.owner): {:?}", + Stake::candidate_state(candidate.owner) + ); + assert_eq!(candidate.amount, bond); + } + } + } + // 15 + 16 + 17 + 18 + 20 = 86 (top 4 + self bond) + is_candidate_pool_bond(1, 86); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(3), 1, 8, None)); + roll_to(10); + // 3: 11 -> 19 => 3 is in top, bumps out 7 + assert_ok!(Stake::execute_delegation_request(Origin::signed(3), 3, 1, None)); + // 16 + 17 + 18 + 19 + 20 = 90 (top 4 + self bond) + is_candidate_pool_bond(1, 90); + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(4), 1, 8, None)); + roll_to(20); + // 4: 12 -> 20 => 4 is in top, bumps out 8 + assert_ok!(Stake::execute_delegation_request(Origin::signed(4), 4, 1, None)); + // 17 + 18 + 19 + 20 + 20 = 94 (top 4 + self bond) + is_candidate_pool_bond(1, 94); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(10), 1, 3)); + roll_to(30); + // 10: 18 -> 15 => 10 bumped to bottom, 8 bumped to top (- 18 + 16 = -2 for count) + assert_ok!(Stake::execute_delegation_request(Origin::signed(10), 10, 1, None)); + // 16 + 17 + 19 + 20 + 20 = 92 (top 4 + self bond) + is_candidate_pool_bond(1, 92); + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(9), 1, 4)); + roll_to(40); + assert_ok!(Stake::execute_delegation_request(Origin::signed(9), 9, 1, None)); + // 15 + 16 + 19 + 20 + 20 = 90 (top 4 + self bond) + is_candidate_pool_bond(1, 90); + }); +} + +#[test] +// MaxDelegatorsPerCandidate = 4 +fn only_top_collators_are_counted() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 20), + (3, 19), + (4, 20), + (5, 21), + (6, 22), + (7, 15), + (8, 16), + (9, 17), + (10, 18), + ]) + .with_default_token_candidates(vec![(1, 20)]) + .with_delegations(vec![ + (3, 1, 11), + (4, 1, 12), + (5, 1, 13), + (6, 1, 14), + (7, 1, 15), + (8, 1, 16), + (9, 1, 17), + (10, 1, 18), + ]) + .build() + .execute_with(|| { + // sanity check that 3-10 are delegators immediately + for i in 3..11 { + assert!(Stake::is_delegator(&i)); + } + let collator_state = Stake::candidate_state(1).unwrap(); + // 15 + 16 + 17 + 18 + 20 = 86 (top 4 + self bond) + assert_eq!(collator_state.total_counted, 86); + // 11 + 12 + 13 + 14 = 50 + assert_eq!(collator_state.total_counted + 50, collator_state.total_backing); + // bump bottom to the top + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(3), 1, 8, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(3, 1, 8, 2)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(3), 3, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(3, 1, 8, true)); + let collator_state = Stake::candidate_state(1).unwrap(); + // 16 + 17 + 18 + 19 + 20 = 90 (top 4 + self bond) + assert_eq!(collator_state.total_counted, 90); + // 12 + 13 + 14 + 15 = 54 + assert_eq!(collator_state.total_counted + 54, collator_state.total_backing); + // bump bottom to the top + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(4), 1, 8, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(4, 1, 8, 4)); + roll_to(20); + assert_ok!(Stake::execute_delegation_request(Origin::signed(4), 4, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(4, 1, 8, true)); + let collator_state = Stake::candidate_state(1).unwrap(); + // 17 + 18 + 19 + 20 + 20 = 94 (top 4 + self bond) + assert_eq!(collator_state.total_counted, 94); + // 13 + 14 + 15 + 16 = 58 + assert_eq!(collator_state.total_counted + 58, collator_state.total_backing); + // bump bottom to the top + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(5), 1, 8, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(5, 1, 8, 6)); + roll_to(30); + assert_ok!(Stake::execute_delegation_request(Origin::signed(5), 5, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(5, 1, 8, true)); + let collator_state = Stake::candidate_state(1).unwrap(); + // 18 + 19 + 20 + 21 + 20 = 98 (top 4 + self bond) + assert_eq!(collator_state.total_counted, 98); + // 14 + 15 + 16 + 17 = 62 + assert_eq!(collator_state.total_counted + 62, collator_state.total_backing); + // bump bottom to the top + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(6), 1, 8, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(6, 1, 8, 8)); + roll_to(40); + assert_ok!(Stake::execute_delegation_request(Origin::signed(6), 6, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(6, 1, 8, true)); + let collator_state = Stake::candidate_state(1).unwrap(); + // 19 + 20 + 21 + 22 + 20 = 102 (top 4 + self bond) + assert_eq!(collator_state.total_counted, 102); + // 15 + 16 + 17 + 18 = 66 + assert_eq!(collator_state.total_counted + 66, collator_state.total_backing); + }); +} + +#[test] +fn delegation_events_convey_correct_position() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + (8, 100), + (9, 100), + (10, 100), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .with_delegations(vec![(3, 1, 11), (4, 1, 12), (5, 1, 13), (6, 1, 14)]) + .build() + .execute_with(|| { + let collator1_state = Stake::candidate_state(1).unwrap(); + // 11 + 12 + 13 + 14 + 20 = 70 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 70); + assert_eq!(collator1_state.total_counted, collator1_state.total_backing); + // Top delegations are full, new highest delegation is made + assert_ok!(Stake::delegate(Origin::signed(7), 1, 15, None, 10, 10)); + assert_event_emitted!(Event::Delegation( + 7, + 15, + 1, + DelegatorAdded::AddedToTop { new_total: 74 }, + )); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 12 + 13 + 14 + 15 + 20 = 70 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 74); + // 11 = 11 + assert_eq!(collator1_state.total_counted + 11, collator1_state.total_backing); + // New delegation is added to the bottom + assert_ok!(Stake::delegate(Origin::signed(8), 1, 10, None, 10, 10)); + assert_event_emitted!(Event::Delegation(8, 10, 1, DelegatorAdded::AddedToBottom)); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 12 + 13 + 14 + 15 + 20 = 70 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 74); + // 10 + 11 = 21 + assert_eq!(collator1_state.total_counted + 21, collator1_state.total_backing); + // 8 increases delegation to the top + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(8), 1, 3, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(8, 1, 3, 2)); + roll_to(10); + assert_ok!(Stake::execute_delegation_request(Origin::signed(8), 8, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(8, 1, 3, true)); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 13 + 13 + 14 + 15 + 20 = 75 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 75); + // 11 + 12 = 23 + assert_eq!(collator1_state.total_counted + 23, collator1_state.total_backing); + // 3 increases delegation but stays in bottom + assert_ok!(Stake::schedule_delegator_bond_more(Origin::signed(3), 1, 1, None)); + assert_event_emitted!(Event::DelegationIncreaseScheduled(3, 1, 1, 4)); + roll_to(20); + assert_ok!(Stake::execute_delegation_request(Origin::signed(3), 3, 1, None)); + assert_event_emitted!(Event::DelegationIncreased(3, 1, 1, false)); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 13 + 13 + 14 + 15 + 20 = 75 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 75); + // 12 + 12 = 24 + assert_eq!(collator1_state.total_counted + 24, collator1_state.total_backing); + // 6 decreases delegation but stays in top + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(6), 1, 2)); + assert_event_emitted!(Event::DelegationDecreaseScheduled(6, 1, 2, 6)); + roll_to(30); + assert_ok!(Stake::execute_delegation_request(Origin::signed(6), 6, 1, None)); + assert_event_emitted!(Event::DelegationDecreased(6, 1, 2, true)); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 12 + 13 + 13 + 15 + 20 = 73 (top 4 + self bond)ƒ + assert_eq!(collator1_state.total_counted, 73); + // 12 + 12 = 24 + assert_eq!(collator1_state.total_counted + 24, collator1_state.total_backing); + // 6 decreases delegation and is bumped to bottom + assert_ok!(Stake::schedule_delegator_bond_less(Origin::signed(6), 1, 1)); + assert_event_emitted!(Event::DelegationDecreaseScheduled(6, 1, 1, 8)); + roll_to(40); + assert_ok!(Stake::execute_delegation_request(Origin::signed(6), 6, 1, None)); + assert_event_emitted!(Event::DelegationDecreased(6, 1, 1, false)); + let collator1_state = Stake::candidate_state(1).unwrap(); + // 12 + 13 + 13 + 15 + 20 = 73 (top 4 + self bond) + assert_eq!(collator1_state.total_counted, 73); + // 11 + 12 = 23 + assert_eq!(collator1_state.total_counted + 23, collator1_state.total_backing); + }); +} + +#[test] +fn start_and_new_session_works() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .build() + .execute_with(|| { + let mut expected = vec![]; + assert_eq_events!(expected.clone()); + + assert_eq!(Stake::at_stake(0, 1).bond, 20); + assert_eq!(Stake::at_stake(0, 2).bond, 20); + + assert_eq!(Stake::at_stake(1, 1).bond, 20); + assert_eq!(Stake::at_stake(1, 2).bond, 20); + + roll_to(5); + + assert_eq!(Stake::at_stake(2, 1).bond, 20); + assert_eq!(Stake::at_stake(2, 2).bond, 20); + + assert_eq!( + >::new_session(Default::default()), + Some(vec![1, 2]) + ); + + let mut new = vec![ + Event::CollatorChosen(2, 1, 20), + Event::CollatorChosen(2, 2, 20), + Event::NewRound(5, 1, 2, 40), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + + assert_ok!(Stake::join_candidates( + Origin::signed(3), + 10u128, + 1u32, + None, + 2u32, + 10000u32 + )); + + roll_to(10); + + assert_eq!(Stake::at_stake(3, 1).bond, 20); + assert_eq!(Stake::at_stake(3, 2).bond, 20); + assert_eq!(Stake::at_stake(3, 3).bond, 10); + + assert_eq!( + >::new_session(Default::default()), + Some(vec![1, 2, 3]) + ); + + let mut new1 = vec![ + Event::JoinedCollatorCandidates(3, 10, 50), + Event::CollatorChosen(3, 1, 20), + Event::CollatorChosen(3, 2, 20), + Event::CollatorChosen(3, 3, 10), + Event::NewRound(10, 2, 3, 50), + ]; + expected.append(&mut new1); + assert_eq_events!(expected.clone()); + + assert_ok!(Stake::join_candidates( + Origin::signed(4), + 10u128, + 1u32, + None, + 3u32, + 10000u32 + )); + assert_ok!(Stake::join_candidates( + Origin::signed(5), + 10u128, + 1u32, + None, + 4u32, + 10000u32 + )); + + roll_to(15); + + assert_eq!(Stake::at_stake(4, 1).bond, 20); + assert_eq!(Stake::at_stake(4, 2).bond, 20); + assert_eq!(Stake::at_stake(4, 3).bond, 10); + assert_eq!(Stake::at_stake(4, 4).bond, 10); + assert_eq!(Stake::at_stake(4, 5).bond, 10); + + assert_eq!( + >::new_session(Default::default()), + Some(vec![1, 2, 3, 4, 5]) + ); + + let mut new2 = vec![ + Event::JoinedCollatorCandidates(4, 10, 60), + Event::JoinedCollatorCandidates(5, 10, 70), + Event::CollatorChosen(4, 1, 20), + Event::CollatorChosen(4, 2, 20), + Event::CollatorChosen(4, 3, 10), + Event::CollatorChosen(4, 4, 10), + Event::CollatorChosen(4, 5, 10), + Event::NewRound(15, 3, 5, 70), + ]; + expected.append(&mut new2); + assert_eq_events!(expected.clone()); + }); +} + +#[test] +fn adding_removing_staking_token_works() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 100, 6), + (7, 100, 7), + (8, 100, 1), + (9, 100, 2), + (10, 100, 3), + ]) + .with_candidates(vec![(1, 20, 1), (2, 20, 2)]) + .build() + .execute_with(|| { + assert_eq!(Stake::staking_liquidity_tokens().get(&1), Some(&Some((1u128, 1u128)))); + assert_eq!(Stake::staking_liquidity_tokens().get(&2), Some(&Some((2u128, 1u128)))); + + assert_eq!(Stake::staking_liquidity_tokens().get(&3), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&4), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&5), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&6), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&7), None); + + assert_ok!(Stake::join_candidates( + Origin::signed(8), + 10u128, + 1u32, + None, + 100u32, + 10000u32 + )); + assert_ok!(Stake::join_candidates( + Origin::signed(9), + 10u128, + 2u32, + None, + 100u32, + 10000u32 + )); + + assert_noop!( + Stake::join_candidates(Origin::signed(3), 10u128, 3u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(4), 10u128, 4u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(5), 10u128, 5u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(6), 10u128, 6u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(7), 10u128, 7u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + + // Add 3 as a staking token + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(3u32), + 100u32 + )); + assert_ok!(Stake::join_candidates( + Origin::signed(3), + 10u128, + 3u32, + None, + 100u32, + 10000u32 + )); + assert_eq!(Stake::staking_liquidity_tokens().get(&3), Some(&None)); + // Check that the rest remain the same + assert_eq!(Stake::staking_liquidity_tokens().get(&4), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&5), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&6), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&7), None); + assert_noop!( + Stake::join_candidates(Origin::signed(4), 10u128, 4u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(5), 10u128, 5u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(6), 10u128, 6u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(7), 10u128, 7u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + + roll_to(5); + + // Check that 3 gets valuated and others don't + assert_eq!(Stake::staking_liquidity_tokens().get(&3), Some(&Some((5u128, 1u128)))); + // Check that the rest remain the same + assert_eq!(Stake::staking_liquidity_tokens().get(&4), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&5), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&6), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&7), None); + assert_noop!( + Stake::join_candidates(Origin::signed(4), 10u128, 4u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(5), 10u128, 5u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(6), 10u128, 6u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + assert_noop!( + Stake::join_candidates(Origin::signed(7), 10u128, 7u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + + // Adding same liquidity token doesn't work + assert_noop!( + Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(3u32), + 100u32 + ), + Error::::StakingLiquidityTokenAlreadyListed + ); + // Remove a liquidity not yet added - noop + assert_noop!( + Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(4u32), + 100u32 + ), + Error::::StakingLiquidityTokenNotListed + ); + + // Remove a liquidity token + assert_ok!(Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(3u32), + 100u32 + )); + // Candidate cannot join using it. + assert_noop!( + Stake::join_candidates(Origin::signed(10), 10u128, 3u32, None, 100u32, 10000u32), + Error::::StakingLiquidityTokenNotListed + ); + + roll_to(10); + + // Removed token is no longer valuated + assert_eq!(Stake::staking_liquidity_tokens().get(&3), None); + + // Add more staking tokens + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(4u32), + 100u32 + )); + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(5u32), + 100u32 + )); + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(6u32), + 100u32 + )); + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(7u32), + 100u32 + )); + + // Candidates can join using the newly added tokens + assert_ok!(Stake::join_candidates( + Origin::signed(4), + 10u128, + 4u32, + None, + 100u32, + 10000u32 + )); + assert_ok!(Stake::join_candidates( + Origin::signed(6), + 10u128, + 6u32, + None, + 100u32, + 10000u32 + )); + assert_ok!(Stake::join_candidates( + Origin::signed(7), + 10u128, + 7u32, + None, + 100u32, + 10000u32 + )); + + roll_to(15); + + assert_eq!(Stake::staking_liquidity_tokens().get(&1), Some(&Some((1u128, 1u128)))); + assert_eq!(Stake::staking_liquidity_tokens().get(&2), Some(&Some((2u128, 1u128)))); + // No entry + assert_eq!(Stake::staking_liquidity_tokens().get(&3), None); + assert_eq!(Stake::staking_liquidity_tokens().get(&4), Some(&Some((1u128, 1u128)))); + // Valuated even though no candidates or delegates use it + assert_eq!(Stake::staking_liquidity_tokens().get(&5), Some(&Some((1u128, 2u128)))); + assert_eq!(Stake::staking_liquidity_tokens().get(&6), Some(&Some((1u128, 5u128)))); + // Valuated as zero + assert_eq!(Stake::staking_liquidity_tokens().get(&7), Some(&None)); + }); +} + +#[test] +fn delegation_tokens_work() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 100, 6), + (7, 100, 7), + (8, 100, 1), + (8, 100, 2), + (9, 100, 1), + (9, 100, 2), + (10, 100, 3), + (11, 100, 7), + ]) + .with_candidates(vec![ + (1, 10, 1), + (2, 10, 2), + (3, 20, 3), + (4, 20, 4), + (5, 20, 5), + (6, 20, 6), + (7, 20, 7), + ]) + .with_delegations(vec![(8, 1, 5), (8, 2, 10), (9, 1, 5), (10, 3, 10), (11, 7, 10)]) + .build() + .execute_with(|| { + assert_noop!( + Stake::delegate(Origin::signed(9), 3, 10, None, 100u32, 100u32), + DispatchError::Module(ModuleError { + index: 1, + error: [0; 4], + message: Some("BalanceTooLow") + }) + ); + }); +} + +#[test] +fn token_valuations_works() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 300, 6), + (7, 100, 7), + (8, 100, 1), + (8, 100, 2), + (9, 100, 1), + (9, 100, 2), + (10, 100, 3), + (11, 100, 7), + ]) + .with_candidates(vec![ + (1, 10, 1), + (2, 10, 2), + (3, 10, 3), + (4, 20, 4), + (5, 20, 5), + (6, 200, 6), + (7, 10, 7), + ]) + .with_delegations(vec![(8, 1, 5), (8, 2, 10), (9, 1, 5), (10, 3, 10), (11, 7, 10)]) + .build() + .execute_with(|| { + assert_ok!(Stake::set_total_selected(Origin::root(), 10)); + + assert_eq!( + Stake::candidate_pool().0, + vec![ + Bond { owner: 1, amount: 20, liquidity_token: 1 }, + Bond { owner: 2, amount: 20, liquidity_token: 2 }, + Bond { owner: 3, amount: 20, liquidity_token: 3 }, + Bond { owner: 4, amount: 20, liquidity_token: 4 }, + Bond { owner: 5, amount: 20, liquidity_token: 5 }, + Bond { owner: 6, amount: 200, liquidity_token: 6 }, + Bond { owner: 7, amount: 20, liquidity_token: 7 } + ] + ); + + assert_eq!(Stake::at_stake(0, 1).bond, 10); + assert_eq!(Stake::at_stake(0, 1).total, 20); + assert_eq!(Stake::at_stake(0, 2).bond, 10); + assert_eq!(Stake::at_stake(0, 2).total, 20); + assert_eq!(Stake::at_stake(0, 3).bond, 10); + assert_eq!(Stake::at_stake(0, 3).total, 20); + assert_eq!(Stake::at_stake(0, 4).bond, 20); + assert_eq!(Stake::at_stake(0, 4).total, 20); + assert_eq!(Stake::at_stake(0, 5).bond, 0); + assert_eq!(Stake::at_stake(0, 5).total, 0); + assert_eq!(Stake::at_stake(0, 6).bond, 200); + assert_eq!(Stake::at_stake(0, 6).total, 200); + + assert_eq!(Stake::at_stake(1, 1).bond, 10); + assert_eq!(Stake::at_stake(1, 1).total, 20); + assert_eq!(Stake::at_stake(1, 2).bond, 10); + assert_eq!(Stake::at_stake(1, 2).total, 20); + assert_eq!(Stake::at_stake(1, 3).bond, 10); + assert_eq!(Stake::at_stake(1, 3).total, 20); + assert_eq!(Stake::at_stake(1, 4).bond, 20); + assert_eq!(Stake::at_stake(1, 4).total, 20); + assert_eq!(Stake::at_stake(1, 5).bond, 0); + assert_eq!(Stake::at_stake(1, 5).total, 0); + assert_eq!(Stake::at_stake(1, 6).bond, 200); + assert_eq!(Stake::at_stake(1, 6).total, 200); + assert_eq!(Stake::at_stake(1, 7).bond, 0); + assert_eq!(Stake::at_stake(1, 7).total, 0); + + roll_to(5); + + assert_eq!(Stake::at_stake(2, 1).bond, 10); + assert_eq!(Stake::at_stake(2, 1).total, 20); + assert_eq!(Stake::at_stake(2, 2).bond, 10); + assert_eq!(Stake::at_stake(2, 2).total, 20); + assert_eq!(Stake::at_stake(2, 3).bond, 10); + assert_eq!(Stake::at_stake(2, 3).total, 20); + assert_eq!(Stake::at_stake(2, 4).bond, 20); + assert_eq!(Stake::at_stake(2, 4).total, 20); + assert_eq!(Stake::at_stake(2, 5).bond, 20); + assert_eq!(Stake::at_stake(2, 5).total, 20); + assert_eq!(Stake::at_stake(2, 6).bond, 200); + assert_eq!(Stake::at_stake(2, 6).total, 200); + assert_eq!(Stake::at_stake(2, 7).bond, 0); + assert_eq!(Stake::at_stake(2, 7).total, 0); + + let mut expected = vec![ + Event::TotalSelectedSet(5, 10), + Event::CollatorChosen(2, 1, 20), + Event::CollatorChosen(2, 2, 40), + Event::CollatorChosen(2, 3, 100), + Event::CollatorChosen(2, 4, 20), + Event::CollatorChosen(2, 5, 10), + Event::CollatorChosen(2, 6, 40), + Event::NewRound(5, 1, 6, 230), + ]; + assert_eq_events!(expected.clone()); + + assert_ok!(Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(3u32), + 100u32 + )); + + roll_to(10); + + assert_eq!(Stake::at_stake(3, 1).bond, 10); + assert_eq!(Stake::at_stake(3, 1).total, 20); + assert_eq!(Stake::at_stake(3, 2).bond, 10); + assert_eq!(Stake::at_stake(3, 2).total, 20); + assert_eq!(Stake::at_stake(3, 3).bond, 0); + assert_eq!(Stake::at_stake(3, 3).total, 0); + assert_eq!(Stake::at_stake(3, 4).bond, 20); + assert_eq!(Stake::at_stake(3, 4).total, 20); + assert_eq!(Stake::at_stake(3, 5).bond, 20); + assert_eq!(Stake::at_stake(3, 5).total, 20); + assert_eq!(Stake::at_stake(3, 6).bond, 200); + assert_eq!(Stake::at_stake(3, 6).total, 200); + assert_eq!(Stake::at_stake(3, 7).bond, 0); + assert_eq!(Stake::at_stake(3, 7).total, 0); + + let mut new = vec![ + Event::CollatorChosen(3, 1, 20), + Event::CollatorChosen(3, 2, 40), + Event::CollatorChosen(3, 4, 20), + Event::CollatorChosen(3, 5, 10), + Event::CollatorChosen(3, 6, 40), + Event::NewRound(10, 2, 5, 130), + ]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + }); +} + +#[test] +fn paired_or_liquidity_token_works() { + ExtBuilder::default() + .with_default_staking_token(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]) + .with_default_token_candidates(vec![(1, 20), (2, 20)]) + .build() + .execute_with(|| { + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Paired(7000u32), + 100u32 + )); + assert_eq!(Stake::staking_liquidity_tokens().get(&70), Some(&None)); + + assert_ok!(Stake::add_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(700u32), + 100u32 + )); + assert_eq!(Stake::staking_liquidity_tokens().get(&700), Some(&None)); + + assert_ok!(Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(70u32), + 100u32 + ),); + assert_eq!(Stake::staking_liquidity_tokens().get(&70), None); + + assert_ok!(Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Paired(70000u32), + 100u32 + )); + assert_eq!(Stake::staking_liquidity_tokens().get(&700), None); + }); +} + +// Agrregator must be selected instead of collators under that aggregator +// The aggregator must have total weight of all the collators under him +#[test] +fn token_valuations_works_with_aggregators() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 300, 6), + (7, 100, 7), + (8, 100, 1), + (8, 100, 2), + (9, 100, 1), + (9, 100, 2), + (10, 100, 3), + (11, 100, 7), + ]) + .with_candidates(vec![(1, 20, 1), (2, 30, 2), (3, 10, 3)]) + .with_delegations(vec![(8, 1, 5), (8, 2, 10), (9, 1, 5), (10, 3, 10)]) + .build() + .execute_with(|| { + >::put(1u32); + assert_eq!(>::get(), 1u32); + + assert_eq!( + Stake::candidate_pool().0, + vec![ + Bond { owner: 1, amount: 30, liquidity_token: 1 }, + Bond { owner: 2, amount: 40, liquidity_token: 2 }, + Bond { owner: 3, amount: 20, liquidity_token: 3 }, + ] + ); + + assert_ok!(Stake::aggregator_update_metadata( + Origin::signed(4), + vec![1, 2], + MetadataUpdateAction::ExtendApprovedCollators + )); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(1), Some(4))); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(2), Some(4))); + + roll_to(5); + + assert_eq!(Stake::at_stake(2, 1).bond, 20); + assert_eq!(Stake::at_stake(2, 1).total, 30); + assert_eq!(Stake::at_stake(2, 2).bond, 30); + assert_eq!(Stake::at_stake(2, 2).total, 40); + + roll_to(10); + + assert_eq!(Stake::at_stake(3, 1).bond, 20); + assert_eq!(Stake::at_stake(3, 1).total, 30); + assert_eq!(Stake::at_stake(3, 2).bond, 30); + assert_eq!(Stake::at_stake(3, 2).total, 40); + + let mut expected = vec![ + Event::AggregatorMetadataUpdated(4), + Event::CandidateAggregatorUpdated(1, Some(4)), + Event::CandidateAggregatorUpdated(2, Some(4)), + Event::CollatorChosen(2, 1, 30), + Event::CollatorChosen(2, 2, 80), + Event::NewRound(5, 1, 2, 110), + Event::CollatorChosen(3, 1, 30), + Event::CollatorChosen(3, 2, 80), + Event::NewRound(10, 2, 2, 110), + ]; + assert_eq_events!(expected.clone()); + + assert_ok!(Stake::remove_staking_liquidity_token( + Origin::root(), + PairedOrLiquidityToken::Liquidity(2u32), + 100u32 + )); + + roll_to(15); + + assert_eq!(Stake::at_stake(4, 3).bond, 10); + assert_eq!(Stake::at_stake(4, 3).total, 20); + + let mut new = vec![Event::CollatorChosen(4, 3, 100), Event::NewRound(15, 3, 1, 100)]; + expected.append(&mut new); + assert_eq_events!(expected.clone()); + }); +} + +// Agrregator must be selected instead of collators under that aggregator +// The aggregator must have total weight of all the collators under him +#[test] +fn round_aggregator_info_is_updated() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 300, 6), + (7, 100, 7), + (8, 100, 1), + (8, 100, 2), + (9, 100, 1), + (9, 100, 2), + (10, 100, 3), + (11, 100, 7), + ]) + .with_candidates(vec![(1, 20, 1), (2, 30, 2), (3, 10, 3)]) + .with_delegations(vec![(8, 1, 5), (8, 2, 10), (9, 1, 5), (10, 3, 10)]) + .build() + .execute_with(|| { + >::put(1u32); + assert_eq!(>::get(), 1u32); + + assert_eq!( + Stake::candidate_pool().0, + vec![ + Bond { owner: 1, amount: 30, liquidity_token: 1 }, + Bond { owner: 2, amount: 40, liquidity_token: 2 }, + Bond { owner: 3, amount: 20, liquidity_token: 3 }, + ] + ); + + assert_ok!(Stake::aggregator_update_metadata( + Origin::signed(4), + vec![1, 2], + MetadataUpdateAction::ExtendApprovedCollators + )); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(1), Some(4))); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(2), Some(4))); + + roll_to(5); + + assert_eq!(Stake::at_stake(2, 1).bond, 20); + assert_eq!(Stake::at_stake(2, 1).total, 30); + assert_eq!(Stake::at_stake(2, 2).bond, 30); + assert_eq!(Stake::at_stake(2, 2).total, 40); + + let agggregator_collator_info: Vec<( + ::AccountId, + Balance, + )> = RoundAggregatorInfo::::get(2) + .unwrap() + .get(&4) + .unwrap() + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::<_>(); + assert_eq!(agggregator_collator_info, [(1, 30), (2, 80)]); + }); +} + +// Agrregator must be selected instead of collators under that aggregator +// The aggregator must have total weight of all the collators under him +#[test] +fn payouts_with_aggregators_work() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 100, 0), + (1, 100, 1), + (2, 100, 2), + (3, 100, 3), + (4, 100, 4), + (5, 100, 5), + (6, 300, 6), + (7, 100, 7), + (8, 100, 1), + (8, 100, 2), + (9, 100, 1), + (9, 100, 2), + (10, 100, 3), + (11, 100, 7), + ]) + .with_candidates(vec![(1, 20, 1), (2, 30, 2), (3, 10, 3)]) + .with_delegations(vec![(8, 1, 5), (8, 2, 10), (9, 1, 5), (10, 3, 10)]) + .build() + .execute_with(|| { + >::put(2u32); + assert_eq!(>::get(), 2u32); + + assert_eq!( + Stake::candidate_pool().0, + vec![ + Bond { owner: 1, amount: 30, liquidity_token: 1 }, + Bond { owner: 2, amount: 40, liquidity_token: 2 }, + Bond { owner: 3, amount: 20, liquidity_token: 3 }, + ] + ); + + assert_ok!(Stake::aggregator_update_metadata( + Origin::signed(4), + vec![1, 2], + MetadataUpdateAction::ExtendApprovedCollators + )); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(1), Some(4))); + assert_ok!(Stake::update_candidate_aggregator(Origin::signed(2), Some(4))); + + roll_to(5); + + assert_eq!(Stake::at_stake(2, 1).bond, 20); + assert_eq!(Stake::at_stake(2, 1).total, 30); + assert_eq!(Stake::at_stake(2, 2).bond, 30); + assert_eq!(Stake::at_stake(2, 2).total, 40); + + let agggregator_collator_info: Vec<( + ::AccountId, + Balance, + )> = RoundAggregatorInfo::::get(2) + .unwrap() + .get(&4) + .unwrap() + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::<_>(); + assert_eq!(agggregator_collator_info, [(1, 30), (2, 80)]); + + roll_to(10); + + set_author(2, 4, 100); + set_author(2, 3, 100); + + roll_to(20); + + let collator_info_reward_info = RoundCollatorRewardInfo::::get(1, 2).unwrap(); + let collator_info_reward_info_delegators: Vec<(AccountId, Balance)> = + collator_info_reward_info + .delegator_rewards + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::<_>(); + assert_eq!(collator_info_reward_info.collator_reward, 29); + assert_eq!(collator_info_reward_info_delegators, [(8, 5), (9, 5)]); + + let collator_info_reward_info = RoundCollatorRewardInfo::::get(2, 2).unwrap(); + let collator_info_reward_info_delegators: Vec<(AccountId, Balance)> = + collator_info_reward_info + .delegator_rewards + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::<_>(); + assert_eq!(collator_info_reward_info.collator_reward, 88); + assert_eq!(collator_info_reward_info_delegators, [(8, 22)]); + + let collator_info_reward_info = RoundCollatorRewardInfo::::get(3, 2).unwrap(); + let collator_info_reward_info_delegators: Vec<(AccountId, Balance)> = + collator_info_reward_info + .delegator_rewards + .into_iter() + .map(|(a, b)| (a.clone(), b.clone())) + .collect::<_>(); + assert_eq!(collator_info_reward_info.collator_reward, 91); + assert_eq!(collator_info_reward_info_delegators, [(10, 61)]); + }); +} + +#[test] +fn can_join_candidates_and_be_selected_with_native_token() { + ExtBuilder::default() + .with_default_staking_token(vec![ + (1, 1000), + (2, 1000), + (3, 1000), + (4, 1000), + (5, 1000), + (6, 1000), + (7, 33), + (8, 33), + (9, 33), + ]) + .with_default_token_candidates(vec![(1, 100), (2, 90), (3, 80), (4, 70), (5, 60), (6, 50)]) + .build() + .execute_with(|| { + roll_to(8); + + let expected = vec![ + Event::CollatorChosen(2, 1, 100), + Event::CollatorChosen(2, 2, 90), + Event::CollatorChosen(2, 3, 80), + Event::CollatorChosen(2, 4, 70), + Event::CollatorChosen(2, 5, 60), + Event::NewRound(5, 1, 5, 400), + ]; + assert_eq_events!(expected); + + assert_ok!(Stake::join_candidates( + Origin::signed(99999), + 1_000_000u128, + 0u32, + None, + 6u32, + 10000u32 + )); + assert_last_event!(MetaEvent::Stake(Event::JoinedCollatorCandidates( + 99999, + 1_000_000u128, + 1_000_000u128, + ))); + + roll_to(9); + + let expected = vec![ + Event::CollatorChosen(2, 1, 100), + Event::CollatorChosen(2, 2, 90), + Event::CollatorChosen(2, 3, 80), + Event::CollatorChosen(2, 4, 70), + Event::CollatorChosen(2, 5, 60), + Event::NewRound(5, 1, 5, 400), + Event::JoinedCollatorCandidates(99999, 1000000, 1000000), + Event::CollatorChosen(3, 1, 100), + Event::CollatorChosen(3, 2, 90), + Event::CollatorChosen(3, 3, 80), + Event::CollatorChosen(3, 4, 70), + Event::CollatorChosen(3, 99999, 500000), + Event::NewRound(10, 2, 5, 500340), + ]; + assert_eq_events!(expected); + + assert_eq!(StakeCurrency::reserved_balance(MGA_TOKEN_ID, &99999), 1_000_000u128); + }); +} + +#[test] +fn test_claiming_rewards_for_more_periods_than_asked_due_to_optimization_based_on_delegators_count() +{ + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 280, 0), + (1, 20, 1), + (2, 20, 1), + (3, 20, 1), + (4, 20, 1), + (5, 30, 1), + (6, 30, 1), + (7, 30, 1), + (8, 30, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)]) + .with_delegations(vec![(5, 1, 30), (6, 1, 30), (7, 1, 30), (8, 1, 30)]) + .build() + .execute_with(|| { + set_author(1, 1, 1); + set_author(1, 2, 1); + set_author(1, 3, 1); + set_author(1, 4, 1); + roll_to(6); + set_author(2, 1, 1); + set_author(2, 2, 1); + set_author(2, 3, 1); + set_author(2, 4, 1); + roll_to(21); + + assert_eq!(2, RoundCollatorRewardInfo::::iter_prefix(2).count()); + + Stake::payout_collator_rewards(crate::mock::RuntimeOrigin::signed(999), 2, Some(1)) + .unwrap(); + + let expected_events = vec![ + Event::CollatorChosen(2, 1, 140), + Event::CollatorChosen(2, 2, 20), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::NewRound(5, 1, 4, 200), + Event::CollatorChosen(3, 1, 140), + Event::CollatorChosen(3, 2, 20), + Event::CollatorChosen(3, 3, 20), + Event::CollatorChosen(3, 4, 20), + Event::NewRound(10, 2, 4, 200), + Event::CollatorChosen(4, 1, 140), + Event::CollatorChosen(4, 2, 20), + Event::CollatorChosen(4, 3, 20), + Event::CollatorChosen(4, 4, 20), + Event::NewRound(15, 3, 4, 200), + Event::CollatorChosen(5, 1, 140), + Event::CollatorChosen(5, 2, 20), + Event::CollatorChosen(5, 3, 20), + Event::CollatorChosen(5, 4, 20), + Event::NewRound(20, 4, 4, 200), + Event::Rewarded(1, 2, 76), + Event::Rewarded(2, 2, 76), + Event::CollatorRewardsDistributed(2, PayoutRounds::All), + ]; + assert_eq_events!(expected_events); + }); +} + +#[test] +fn test_claiming_rewards_for_exactly_one_period_when_delegators_count_is_equal_to_max_available() { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 280, 0), + (1, 20, 1), + (2, 20, 1), + (3, 20, 1), + (4, 20, 1), + (5, 30, 1), + (6, 30, 1), + (7, 30, 1), + (8, 30, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)]) + .with_delegations(vec![(5, 1, 30), (6, 1, 30), (7, 1, 30), (8, 1, 30)]) + .build() + .execute_with(|| { + set_author(1, 1, 1); + set_author(1, 2, 1); + set_author(1, 3, 1); + set_author(1, 4, 1); + roll_to(6); + set_author(2, 1, 1); + set_author(2, 2, 1); + set_author(2, 3, 1); + set_author(2, 4, 1); + roll_to(21); + + println!("rewards {:?}", RoundCollatorRewardInfo::::iter().collect::>()); + assert_eq!(2, RoundCollatorRewardInfo::::iter_prefix(1).count()); + + Stake::payout_collator_rewards(crate::mock::RuntimeOrigin::signed(999), 1, Some(1)) + .unwrap(); + + let expected_events = vec![ + Event::CollatorChosen(2, 1, 140), + Event::CollatorChosen(2, 2, 20), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::NewRound(5, 1, 4, 200), + Event::CollatorChosen(3, 1, 140), + Event::CollatorChosen(3, 2, 20), + Event::CollatorChosen(3, 3, 20), + Event::CollatorChosen(3, 4, 20), + Event::NewRound(10, 2, 4, 200), + Event::CollatorChosen(4, 1, 140), + Event::CollatorChosen(4, 2, 20), + Event::CollatorChosen(4, 3, 20), + Event::CollatorChosen(4, 4, 20), + Event::NewRound(15, 3, 4, 200), + Event::CollatorChosen(5, 1, 140), + Event::CollatorChosen(5, 2, 20), + Event::CollatorChosen(5, 3, 20), + Event::CollatorChosen(5, 4, 20), + Event::NewRound(20, 4, 4, 200), + Event::Rewarded(1, 1, 23), + Event::DelegatorDueReward(1, 1, 5, 13), + Event::DelegatorDueReward(1, 1, 6, 13), + Event::DelegatorDueReward(1, 1, 7, 13), + Event::DelegatorDueReward(1, 1, 8, 13), + Event::CollatorRewardsDistributed(1, PayoutRounds::Partial(vec![1])), + ]; + assert_eq_events!(expected_events); + }); +} + +#[test] +fn test_claiming_rewards_for_all_periods_in_pesimistic_scenario_with_max_delegators_for_exactly_n_blocks( +) { + ExtBuilder::default() + .with_staking_tokens(vec![ + (999, 280, 0), + (1, 20, 1), + (2, 20, 1), + (3, 20, 1), + (4, 20, 1), + (5, 30, 1), + (6, 30, 1), + (7, 30, 1), + (8, 30, 1), + ]) + .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)]) + .with_delegations(vec![(5, 1, 30), (6, 1, 30), (7, 1, 30), (8, 1, 30)]) + .build() + .execute_with(|| { + set_author(1, 1, 1); + set_author(1, 2, 1); + set_author(1, 3, 1); + set_author(1, 4, 1); + roll_to(6); + set_author(2, 1, 1); + set_author(2, 2, 1); + set_author(2, 3, 1); + set_author(2, 4, 1); + roll_to(21); + + println!("rewards {:?}", RoundCollatorRewardInfo::::iter().collect::>()); + assert_eq!(2, RoundCollatorRewardInfo::::iter_prefix(1).count()); + + Stake::payout_collator_rewards(crate::mock::RuntimeOrigin::signed(999), 1, Some(2)) + .unwrap(); + + let expected_events = vec![ + Event::CollatorChosen(2, 1, 140), + Event::CollatorChosen(2, 2, 20), + Event::CollatorChosen(2, 3, 20), + Event::CollatorChosen(2, 4, 20), + Event::NewRound(5, 1, 4, 200), + Event::CollatorChosen(3, 1, 140), + Event::CollatorChosen(3, 2, 20), + Event::CollatorChosen(3, 3, 20), + Event::CollatorChosen(3, 4, 20), + Event::NewRound(10, 2, 4, 200), + Event::CollatorChosen(4, 1, 140), + Event::CollatorChosen(4, 2, 20), + Event::CollatorChosen(4, 3, 20), + Event::CollatorChosen(4, 4, 20), + Event::NewRound(15, 3, 4, 200), + Event::CollatorChosen(5, 1, 140), + Event::CollatorChosen(5, 2, 20), + Event::CollatorChosen(5, 3, 20), + Event::CollatorChosen(5, 4, 20), + Event::NewRound(20, 4, 4, 200), + Event::Rewarded(1, 1, 23), + Event::DelegatorDueReward(1, 1, 5, 13), + Event::DelegatorDueReward(1, 1, 6, 13), + Event::DelegatorDueReward(1, 1, 7, 13), + Event::DelegatorDueReward(1, 1, 8, 13), + Event::Rewarded(2, 1, 23), + Event::DelegatorDueReward(2, 1, 5, 13), + Event::DelegatorDueReward(2, 1, 6, 13), + Event::DelegatorDueReward(2, 1, 7, 13), + Event::DelegatorDueReward(2, 1, 8, 13), + Event::CollatorRewardsDistributed(1, PayoutRounds::All), + ]; + assert_eq_events!(expected_events); + }); +} + +#[test] +fn test_triggre_error_when_there_are_no_rewards_to_payout() { + ExtBuilder::default() + .with_staking_tokens(vec![(999, 280, 0), (1, 20, 1)]) + // .with_default_token_candidates(vec![(1, 20), (2, 20), (3, 20), (4, 20)]) + // .with_delegations(vec![(5, 1, 30), (6,1,30), (7,1,30), (8,1,30), ]) + .build() + .execute_with(|| { + assert_noop!( + Stake::payout_collator_rewards(crate::mock::RuntimeOrigin::signed(999), 33, None), + Error::::CollatorRoundRewardsDNE + ); + }); +} diff --git a/pallets/parachain-staking/src/traits.rs b/pallets/parachain-staking/src/traits.rs new file mode 100644 index 0000000000..f989fec9c8 --- /dev/null +++ b/pallets/parachain-staking/src/traits.rs @@ -0,0 +1,43 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! traits for parachain-staking + +pub trait OnCollatorPayout { + fn on_collator_payout( + for_round: crate::RoundIndex, + collator_id: AccountId, + amount: Balance, + ) -> frame_support::pallet_prelude::Weight; +} +impl OnCollatorPayout for () { + fn on_collator_payout( + _for_round: crate::RoundIndex, + _collator_id: AccountId, + _amount: Balance, + ) -> frame_support::pallet_prelude::Weight { + 0 + } +} + +pub trait OnNewRound { + fn on_new_round(round_index: crate::RoundIndex) -> frame_support::pallet_prelude::Weight; +} +impl OnNewRound for () { + fn on_new_round(_round_index: crate::RoundIndex) -> frame_support::pallet_prelude::Weight { + 0 + } +} diff --git a/pallets/parachain-staking/src/types.rs b/pallets/parachain-staking/src/types.rs new file mode 100644 index 0000000000..b5c0e02ea6 --- /dev/null +++ b/pallets/parachain-staking/src/types.rs @@ -0,0 +1,1545 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! Types for parachain-staking + +use crate::{ + set::OrderedSet, BalanceOf, BottomDelegations, CandidateInfo, Config, DelegatorState, Error, + Event, Pallet, Round, RoundIndex, TopDelegations, Total, +}; +use frame_support::{pallet_prelude::*, traits::ReservableCurrency}; +use parity_scale_codec::{Decode, Encode}; +use sp_runtime::{ + traits::{AtLeast32BitUnsigned, Saturating, Zero}, + Perbill, Percent, RuntimeDebug, +}; +use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; + +#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct Bond { + pub owner: AccountId, + pub amount: Balance, +} + +impl Default for Bond { + fn default() -> Bond { + Bond { + owner: A::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"), + amount: B::default(), + } + } +} + +impl Bond { + pub fn from_owner(owner: A) -> Self { + Bond { + owner, + amount: B::default(), + } + } +} + +impl Eq for Bond {} + +impl Ord for Bond { + fn cmp(&self, other: &Self) -> Ordering { + self.owner.cmp(&other.owner) + } +} + +impl PartialOrd for Bond { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl PartialEq for Bond { + fn eq(&self, other: &Self) -> bool { + self.owner == other.owner + } +} + +#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +/// The activity status of the collator +pub enum CollatorStatus { + /// Committed to be online and producing valid blocks (not equivocating) + Active, + /// Temporarily inactive and excused for inactivity + Idle, + /// Bonded until the inner round + Leaving(RoundIndex), +} + +impl Default for CollatorStatus { + fn default() -> CollatorStatus { + CollatorStatus::Active + } +} + +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +/// Snapshot of collator state at the start of the round for which they are selected +pub struct CollatorSnapshot { + /// The total value locked by the collator. + pub bond: Balance, + + /// The rewardable delegations. This list is a subset of total delegators, where certain + /// delegators are adjusted based on their scheduled + /// [DelegationChange::Revoke] or [DelegationChange::Decrease] action. + pub delegations: Vec>, + + /// The total counted value locked for the collator, including the self bond + total staked by + /// top delegators. + pub total: Balance, +} + +impl PartialEq for CollatorSnapshot { + fn eq(&self, other: &Self) -> bool { + let must_be_true = self.bond == other.bond && self.total == other.total; + if !must_be_true { + return false; + } + for ( + Bond { + owner: o1, + amount: a1, + }, + Bond { + owner: o2, + amount: a2, + }, + ) in self.delegations.iter().zip(other.delegations.iter()) + { + if o1 != o2 || a1 != a2 { + return false; + } + } + true + } +} + +impl Default for CollatorSnapshot { + fn default() -> CollatorSnapshot { + CollatorSnapshot { + bond: B::default(), + delegations: Vec::new(), + total: B::default(), + } + } +} + +#[derive(Default, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Info needed to make delayed payments to stakers after round end +pub struct DelayedPayout { + /// Total round reward (result of compute_issuance() at round end) + pub round_issuance: Balance, + /// The total inflation paid this round to stakers (e.g. less parachain bond fund) + pub total_staking_reward: Balance, + /// Snapshot of collator commission rate at the end of the round + pub collator_commission: Perbill, +} + +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +/// DEPRECATED +/// Collator state with commission fee, bonded stake, and delegations +pub struct Collator2 { + /// The account of this collator + pub id: AccountId, + /// This collator's self stake. + pub bond: Balance, + /// Set of all nominator AccountIds (to prevent >1 nomination per AccountId) + pub nominators: OrderedSet, + /// Top T::MaxDelegatorsPerCollator::get() nominators, ordered greatest to least + pub top_nominators: Vec>, + /// Bottom nominators (unbounded), ordered least to greatest + pub bottom_nominators: Vec>, + /// Sum of top delegations + self.bond + pub total_counted: Balance, + /// Sum of all delegations + self.bond = (total_counted + uncounted) + pub total_backing: Balance, + /// Current status of the collator + pub state: CollatorStatus, +} + +impl From> for CollatorCandidate { + fn from(other: Collator2) -> CollatorCandidate { + CollatorCandidate { + id: other.id, + bond: other.bond, + delegators: other.nominators, + top_delegations: other.top_nominators, + bottom_delegations: other.bottom_nominators, + total_counted: other.total_counted, + total_backing: other.total_backing, + request: None, + state: other.state, + } + } +} + +#[derive(PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Request scheduled to change the collator candidate self-bond +pub struct CandidateBondLessRequest { + pub amount: Balance, + pub when_executable: RoundIndex, +} + +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +/// DEPRECATED, replaced by `CandidateMetadata` and two storage instances of `Delegations` +/// Collator candidate state with self bond + delegations +pub struct CollatorCandidate { + /// The account of this collator + pub id: AccountId, + /// This collator's self stake. + pub bond: Balance, + /// Set of all delegator AccountIds (to prevent >1 delegation per AccountId) + pub delegators: OrderedSet, + /// Top T::MaxDelegatorsPerCollator::get() delegations, ordered greatest to least + pub top_delegations: Vec>, + /// Bottom delegations (unbounded), ordered least to greatest + pub bottom_delegations: Vec>, + /// Sum of top delegations + self.bond + pub total_counted: Balance, + /// Sum of all delegations + self.bond = (total_counted + uncounted) + pub total_backing: Balance, + /// Maximum 1 pending request to decrease candidate self bond at any given time + pub request: Option>, + /// Current status of the collator + pub state: CollatorStatus, +} + +#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Type for top and bottom delegation storage item +pub struct Delegations { + pub delegations: Vec>, + pub total: Balance, +} + +impl Default for Delegations { + fn default() -> Delegations { + Delegations { + delegations: Vec::new(), + total: B::default(), + } + } +} + +impl + Delegations +{ + pub fn sort_greatest_to_least(&mut self) { + self.delegations.sort_by(|a, b| b.amount.cmp(&a.amount)); + } + /// Insert sorted greatest to least and increase .total accordingly + /// Insertion respects first come first serve so new delegations are pushed after existing + /// delegations if the amount is the same + pub fn insert_sorted_greatest_to_least(&mut self, delegation: Bond) { + self.total = self.total.saturating_add(delegation.amount); + // if delegations nonempty && last_element == delegation.amount => push input and return + if !self.delegations.is_empty() { + // if last_element == delegation.amount => push the delegation and return early + if self.delegations[self.delegations.len() - 1].amount == delegation.amount { + self.delegations.push(delegation); + // early return + return; + } + } + // else binary search insertion + match self + .delegations + .binary_search_by(|x| delegation.amount.cmp(&x.amount)) + { + // sorted insertion on sorted vec + // enforces first come first serve for equal bond amounts + Ok(i) => { + let mut new_index = i + 1; + while new_index <= (self.delegations.len() - 1) { + if self.delegations[new_index].amount == delegation.amount { + new_index = new_index.saturating_add(1); + } else { + self.delegations.insert(new_index, delegation); + return; + } + } + self.delegations.push(delegation) + } + Err(i) => self.delegations.insert(i, delegation), + } + } + /// Return the capacity status for top delegations + pub fn top_capacity(&self) -> CapacityStatus { + match &self.delegations { + x if x.len() as u32 >= T::MaxTopDelegationsPerCandidate::get() => CapacityStatus::Full, + x if x.is_empty() => CapacityStatus::Empty, + _ => CapacityStatus::Partial, + } + } + /// Return the capacity status for bottom delegations + pub fn bottom_capacity(&self) -> CapacityStatus { + match &self.delegations { + x if x.len() as u32 >= T::MaxBottomDelegationsPerCandidate::get() => { + CapacityStatus::Full + } + x if x.is_empty() => CapacityStatus::Empty, + _ => CapacityStatus::Partial, + } + } + /// Return last delegation amount without popping the delegation + pub fn lowest_delegation_amount(&self) -> Balance { + self.delegations + .last() + .map(|x| x.amount) + .unwrap_or(Balance::zero()) + } + /// Return highest delegation amount + pub fn highest_delegation_amount(&self) -> Balance { + self.delegations + .first() + .map(|x| x.amount) + .unwrap_or(Balance::zero()) + } +} + +#[derive(PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Capacity status for top or bottom delegations +pub enum CapacityStatus { + /// Reached capacity + Full, + /// Empty aka contains no delegations + Empty, + /// Partially full (nonempty and not full) + Partial, +} + +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +/// All candidate info except the top and bottom delegations +pub struct CandidateMetadata { + /// This candidate's self bond amount + pub bond: Balance, + /// Total number of delegations to this candidate + pub delegation_count: u32, + /// Self bond + sum of top delegations + pub total_counted: Balance, + /// The smallest top delegation amount + pub lowest_top_delegation_amount: Balance, + /// The highest bottom delegation amount + pub highest_bottom_delegation_amount: Balance, + /// The smallest bottom delegation amount + pub lowest_bottom_delegation_amount: Balance, + /// Capacity status for top delegations + pub top_capacity: CapacityStatus, + /// Capacity status for bottom delegations + pub bottom_capacity: CapacityStatus, + /// Maximum 1 pending request to decrease candidate self bond at any given time + pub request: Option>, + /// Current status of the collator + pub status: CollatorStatus, +} + +impl< + Balance: Copy + + Zero + + PartialOrd + + sp_std::ops::AddAssign + + sp_std::ops::SubAssign + + sp_std::ops::Sub + + sp_std::fmt::Debug + + Saturating, + > CandidateMetadata +{ + pub fn new(bond: Balance) -> Self { + CandidateMetadata { + bond, + delegation_count: 0u32, + total_counted: bond, + lowest_top_delegation_amount: Zero::zero(), + highest_bottom_delegation_amount: Zero::zero(), + lowest_bottom_delegation_amount: Zero::zero(), + top_capacity: CapacityStatus::Empty, + bottom_capacity: CapacityStatus::Empty, + request: None, + status: CollatorStatus::Active, + } + } + pub fn is_active(&self) -> bool { + matches!(self.status, CollatorStatus::Active) + } + pub fn is_leaving(&self) -> bool { + matches!(self.status, CollatorStatus::Leaving(_)) + } + pub fn schedule_leave(&mut self) -> Result<(RoundIndex, RoundIndex), DispatchError> { + ensure!(!self.is_leaving(), Error::::CandidateAlreadyLeaving); + let now = >::get().current; + let when = now + T::LeaveCandidatesDelay::get(); + self.status = CollatorStatus::Leaving(when); + Ok((now, when)) + } + pub fn can_leave(&self) -> DispatchResult { + if let CollatorStatus::Leaving(when) = self.status { + ensure!( + >::get().current >= when, + Error::::CandidateCannotLeaveYet + ); + Ok(()) + } else { + Err(Error::::CandidateNotLeaving.into()) + } + } + pub fn go_offline(&mut self) { + self.status = CollatorStatus::Idle; + } + pub fn go_online(&mut self) { + self.status = CollatorStatus::Active; + } + pub fn bond_more(&mut self, who: T::AccountId, more: Balance) -> DispatchResult + where + BalanceOf: From, + { + T::Currency::reserve(&who, more.into())?; + let new_total = >::get().saturating_add(more.into()); + >::put(new_total); + self.bond = self.bond.saturating_add(more); + self.total_counted = self.total_counted.saturating_add(more); + >::deposit_event(Event::CandidateBondedMore { + candidate: who.clone(), + amount: more.into(), + new_total_bond: self.bond.into(), + }); + Ok(()) + } + /// Schedule executable decrease of collator candidate self bond + /// Returns the round at which the collator can execute the pending request + pub fn schedule_bond_less( + &mut self, + less: Balance, + ) -> Result + where + BalanceOf: Into, + { + // ensure no pending request + ensure!( + self.request.is_none(), + Error::::PendingCandidateRequestAlreadyExists + ); + // ensure bond above min after decrease + ensure!(self.bond > less, Error::::CandidateBondBelowMin); + ensure!( + self.bond - less >= T::MinCandidateStk::get().into(), + Error::::CandidateBondBelowMin + ); + let when_executable = >::get().current + T::CandidateBondLessDelay::get(); + self.request = Some(CandidateBondLessRequest { + amount: less, + when_executable, + }); + Ok(when_executable) + } + /// Execute pending request to decrease the collator self bond + /// Returns the event to be emitted + pub fn execute_bond_less(&mut self, who: T::AccountId) -> DispatchResult + where + BalanceOf: From, + { + let request = self + .request + .ok_or(Error::::PendingCandidateRequestsDNE)?; + ensure!( + request.when_executable <= >::get().current, + Error::::PendingCandidateRequestNotDueYet + ); + T::Currency::unreserve(&who, request.amount.into()); + let new_total_staked = >::get().saturating_sub(request.amount.into()); + >::put(new_total_staked); + // Arithmetic assumptions are self.bond > less && self.bond - less > CollatorMinBond + // (assumptions enforced by `schedule_bond_less`; if storage corrupts, must re-verify) + self.bond = self.bond.saturating_sub(request.amount); + self.total_counted = self.total_counted.saturating_sub(request.amount); + let event = Event::CandidateBondedLess { + candidate: who.clone().into(), + amount: request.amount.into(), + new_bond: self.bond.into(), + }; + // reset s.t. no pending request + self.request = None; + // update candidate pool value because it must change if self bond changes + if self.is_active() { + Pallet::::update_active(who.into(), self.total_counted.into()); + } + Pallet::::deposit_event(event); + Ok(()) + } + /// Cancel candidate bond less request + pub fn cancel_bond_less(&mut self, who: T::AccountId) -> DispatchResult + where + BalanceOf: From, + { + let request = self + .request + .ok_or(Error::::PendingCandidateRequestsDNE)?; + let event = Event::CancelledCandidateBondLess { + candidate: who.clone().into(), + amount: request.amount.into(), + execute_round: request.when_executable, + }; + self.request = None; + Pallet::::deposit_event(event); + Ok(()) + } + /// Reset top delegations metadata + pub fn reset_top_data( + &mut self, + candidate: T::AccountId, + top_delegations: &Delegations>, + ) where + BalanceOf: Into + From, + { + self.lowest_top_delegation_amount = top_delegations.lowest_delegation_amount().into(); + self.top_capacity = top_delegations.top_capacity::(); + let old_total_counted = self.total_counted; + self.total_counted = self.bond.saturating_add(top_delegations.total.into()); + // CandidatePool value for candidate always changes if top delegations total changes + // so we moved the update into this function to deduplicate code and patch a bug that + // forgot to apply the update when increasing top delegation + if old_total_counted != self.total_counted && self.is_active() { + Pallet::::update_active(candidate, self.total_counted.into()); + } + } + /// Reset bottom delegations metadata + pub fn reset_bottom_data( + &mut self, + bottom_delegations: &Delegations>, + ) where + BalanceOf: Into, + { + self.lowest_bottom_delegation_amount = bottom_delegations.lowest_delegation_amount().into(); + self.highest_bottom_delegation_amount = + bottom_delegations.highest_delegation_amount().into(); + self.bottom_capacity = bottom_delegations.bottom_capacity::(); + } + /// Add delegation + /// Returns whether delegator was added and an optional negative total counted remainder + /// for if a bottom delegation was kicked + /// MUST ensure no delegation exists for this candidate in the `DelegatorState` before call + pub fn add_delegation( + &mut self, + candidate: &T::AccountId, + delegation: Bond>, + ) -> Result<(DelegatorAdded, Option), DispatchError> + where + BalanceOf: Into + From, + { + let mut less_total_staked = None; + let delegator_added = match self.top_capacity { + CapacityStatus::Full => { + // top is full, insert into top iff the lowest_top < amount + if self.lowest_top_delegation_amount < delegation.amount.into() { + // bumps lowest top to the bottom inside this function call + less_total_staked = self.add_top_delegation::(candidate, delegation); + DelegatorAdded::AddedToTop { + new_total: self.total_counted, + } + } else { + // if bottom is full, only insert if greater than lowest bottom (which will + // be bumped out) + if matches!(self.bottom_capacity, CapacityStatus::Full) { + ensure!( + delegation.amount.into() > self.lowest_bottom_delegation_amount, + Error::::CannotDelegateLessThanOrEqualToLowestBottomWhenFull + ); + // need to subtract from total staked + less_total_staked = Some(self.lowest_bottom_delegation_amount); + } + // insert into bottom + self.add_bottom_delegation::(false, candidate, delegation); + DelegatorAdded::AddedToBottom + } + } + // top is either empty or partially full + _ => { + self.add_top_delegation::(candidate, delegation); + DelegatorAdded::AddedToTop { + new_total: self.total_counted, + } + } + }; + Ok((delegator_added, less_total_staked)) + } + /// Add delegation to top delegation + /// Returns Option + /// Only call if lowest top delegation is less than delegation.amount || !top_full + pub fn add_top_delegation( + &mut self, + candidate: &T::AccountId, + delegation: Bond>, + ) -> Option + where + BalanceOf: Into + From, + { + let mut less_total_staked = None; + let mut top_delegations = >::get(candidate) + .expect("CandidateInfo existence => TopDelegations existence"); + let max_top_delegations_per_candidate = T::MaxTopDelegationsPerCandidate::get(); + if top_delegations.delegations.len() as u32 == max_top_delegations_per_candidate { + // pop lowest top delegation + let new_bottom_delegation = top_delegations.delegations.pop().expect(""); + top_delegations.total = top_delegations + .total + .saturating_sub(new_bottom_delegation.amount); + if matches!(self.bottom_capacity, CapacityStatus::Full) { + less_total_staked = Some(self.lowest_bottom_delegation_amount); + } + self.add_bottom_delegation::(true, candidate, new_bottom_delegation); + } + // insert into top + top_delegations.insert_sorted_greatest_to_least(delegation); + // update candidate info + self.reset_top_data::(candidate.clone(), &top_delegations); + if less_total_staked.is_none() { + // only increment delegation count if we are not kicking a bottom delegation + self.delegation_count = self.delegation_count.saturating_add(1u32); + } + >::insert(&candidate, top_delegations); + less_total_staked + } + /// Add delegation to bottom delegations + /// Check before call that if capacity is full, inserted delegation is higher than lowest + /// bottom delegation (and if so, need to adjust the total storage item) + /// CALLER MUST ensure(lowest_bottom_to_be_kicked.amount < delegation.amount) + pub fn add_bottom_delegation( + &mut self, + bumped_from_top: bool, + candidate: &T::AccountId, + delegation: Bond>, + ) where + BalanceOf: Into + From, + { + let mut bottom_delegations = >::get(candidate) + .expect("CandidateInfo existence => BottomDelegations existence"); + // if bottom is full, kick the lowest bottom (which is expected to be lower than input + // as per check) + let increase_delegation_count = if bottom_delegations.delegations.len() as u32 + == T::MaxBottomDelegationsPerCandidate::get() + { + let lowest_bottom_to_be_kicked = bottom_delegations + .delegations + .pop() + .expect("if at full capacity (>0), then >0 bottom delegations exist; qed"); + // EXPECT lowest_bottom_to_be_kicked.amount < delegation.amount enforced by caller + // if lowest_bottom_to_be_kicked.amount == delegation.amount, we will still kick + // the lowest bottom to enforce first come first served + bottom_delegations.total = bottom_delegations + .total + .saturating_sub(lowest_bottom_to_be_kicked.amount); + // update delegator state + // unreserve kicked bottom + T::Currency::unreserve( + &lowest_bottom_to_be_kicked.owner, + lowest_bottom_to_be_kicked.amount, + ); + // total staked is updated via propagation of lowest bottom delegation amount prior + // to call + let mut delegator_state = >::get(&lowest_bottom_to_be_kicked.owner) + .expect("Delegation existence => DelegatorState existence"); + let leaving = delegator_state.delegations.0.len() == 1usize; + delegator_state.rm_delegation(candidate); + >::delegation_remove_request_with_state( + &candidate, + &lowest_bottom_to_be_kicked.owner, + &mut delegator_state, + ); + + Pallet::::deposit_event(Event::DelegationKicked { + delegator: lowest_bottom_to_be_kicked.owner.clone(), + candidate: candidate.clone(), + unstaked_amount: lowest_bottom_to_be_kicked.amount, + }); + if leaving { + >::remove(&lowest_bottom_to_be_kicked.owner); + Pallet::::deposit_event(Event::DelegatorLeft { + delegator: lowest_bottom_to_be_kicked.owner, + unstaked_amount: lowest_bottom_to_be_kicked.amount, + }); + } else { + >::insert(&lowest_bottom_to_be_kicked.owner, delegator_state); + } + false + } else { + !bumped_from_top + }; + // only increase delegation count if new bottom delegation (1) doesn't come from top && + // (2) doesn't pop the lowest delegation from the bottom + if increase_delegation_count { + self.delegation_count = self.delegation_count.saturating_add(1u32); + } + bottom_delegations.insert_sorted_greatest_to_least(delegation); + self.reset_bottom_data::(&bottom_delegations); + >::insert(candidate, bottom_delegations); + } + /// Remove delegation + /// Removes from top if amount is above lowest top or top is not full + /// Return Ok(if_total_counted_changed) + pub fn rm_delegation_if_exists( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + amount: Balance, + ) -> Result + where + BalanceOf: Into + From, + { + let amount_geq_lowest_top = amount >= self.lowest_top_delegation_amount; + let top_is_not_full = !matches!(self.top_capacity, CapacityStatus::Full); + let lowest_top_eq_highest_bottom = + self.lowest_top_delegation_amount == self.highest_bottom_delegation_amount; + let delegation_dne_err: DispatchError = Error::::DelegationDNE.into(); + if top_is_not_full || (amount_geq_lowest_top && !lowest_top_eq_highest_bottom) { + self.rm_top_delegation::(candidate, delegator) + } else if amount_geq_lowest_top && lowest_top_eq_highest_bottom { + let result = self.rm_top_delegation::(candidate, delegator.clone()); + if result == Err(delegation_dne_err) { + // worst case removal + self.rm_bottom_delegation::(candidate, delegator) + } else { + result + } + } else { + self.rm_bottom_delegation::(candidate, delegator) + } + } + /// Remove top delegation, bumps top bottom delegation if exists + pub fn rm_top_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + ) -> Result + where + BalanceOf: Into + From, + { + let old_total_counted = self.total_counted; + // remove top delegation + let mut top_delegations = >::get(candidate) + .expect("CandidateInfo exists => TopDelegations exists"); + let mut actual_amount_option: Option> = None; + top_delegations.delegations = top_delegations + .delegations + .clone() + .into_iter() + .filter(|d| { + if d.owner != delegator { + true + } else { + actual_amount_option = Some(d.amount); + false + } + }) + .collect(); + let actual_amount = actual_amount_option.ok_or(Error::::DelegationDNE)?; + top_delegations.total = top_delegations.total.saturating_sub(actual_amount); + // if bottom nonempty => bump top bottom to top + if !matches!(self.bottom_capacity, CapacityStatus::Empty) { + let mut bottom_delegations = + >::get(candidate).expect("bottom is nonempty as just checked"); + // expect already stored greatest to least by bond amount + let highest_bottom_delegation = bottom_delegations.delegations.remove(0); + bottom_delegations.total = bottom_delegations + .total + .saturating_sub(highest_bottom_delegation.amount); + self.reset_bottom_data::(&bottom_delegations); + >::insert(candidate, bottom_delegations); + // insert highest bottom into top delegations + top_delegations.insert_sorted_greatest_to_least(highest_bottom_delegation); + } + // update candidate info + self.reset_top_data::(candidate.clone(), &top_delegations); + self.delegation_count = self.delegation_count.saturating_sub(1u32); + >::insert(candidate, top_delegations); + // return whether total counted changed + Ok(old_total_counted == self.total_counted) + } + /// Remove bottom delegation + /// Returns if_total_counted_changed: bool + pub fn rm_bottom_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + ) -> Result + where + BalanceOf: Into, + { + // remove bottom delegation + let mut bottom_delegations = >::get(candidate) + .expect("CandidateInfo exists => BottomDelegations exists"); + let mut actual_amount_option: Option> = None; + bottom_delegations.delegations = bottom_delegations + .delegations + .clone() + .into_iter() + .filter(|d| { + if d.owner != delegator { + true + } else { + actual_amount_option = Some(d.amount); + false + } + }) + .collect(); + let actual_amount = actual_amount_option.ok_or(Error::::DelegationDNE)?; + bottom_delegations.total = bottom_delegations.total.saturating_sub(actual_amount); + // update candidate info + self.reset_bottom_data::(&bottom_delegations); + self.delegation_count = self.delegation_count.saturating_sub(1u32); + >::insert(candidate, bottom_delegations); + Ok(false) + } + /// Increase delegation amount + pub fn increase_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + bond: BalanceOf, + more: BalanceOf, + ) -> Result + where + BalanceOf: Into + From, + { + let lowest_top_eq_highest_bottom = + self.lowest_top_delegation_amount == self.highest_bottom_delegation_amount; + let bond_geq_lowest_top = bond.into() >= self.lowest_top_delegation_amount; + let delegation_dne_err: DispatchError = Error::::DelegationDNE.into(); + if bond_geq_lowest_top && !lowest_top_eq_highest_bottom { + // definitely in top + self.increase_top_delegation::(candidate, delegator.clone(), more) + } else if bond_geq_lowest_top && lowest_top_eq_highest_bottom { + // update top but if error then update bottom (because could be in bottom because + // lowest_top_eq_highest_bottom) + let result = self.increase_top_delegation::(candidate, delegator.clone(), more); + if result == Err(delegation_dne_err) { + self.increase_bottom_delegation::(candidate, delegator, bond, more) + } else { + result + } + } else { + self.increase_bottom_delegation::(candidate, delegator, bond, more) + } + } + /// Increase top delegation + pub fn increase_top_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + more: BalanceOf, + ) -> Result + where + BalanceOf: Into + From, + { + let mut top_delegations = >::get(candidate) + .expect("CandidateInfo exists => TopDelegations exists"); + let mut in_top = false; + top_delegations.delegations = top_delegations + .delegations + .clone() + .into_iter() + .map(|d| { + if d.owner != delegator { + d + } else { + in_top = true; + let new_amount = d.amount.saturating_add(more); + Bond { + owner: d.owner, + amount: new_amount, + } + } + }) + .collect(); + ensure!(in_top, Error::::DelegationDNE); + top_delegations.total = top_delegations.total.saturating_add(more); + top_delegations.sort_greatest_to_least(); + self.reset_top_data::(candidate.clone(), &top_delegations); + >::insert(candidate, top_delegations); + Ok(true) + } + /// Increase bottom delegation + pub fn increase_bottom_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + bond: BalanceOf, + more: BalanceOf, + ) -> Result + where + BalanceOf: Into + From, + { + let mut bottom_delegations = + >::get(candidate).ok_or(Error::::CandidateDNE)?; + let mut delegation_option: Option>> = None; + let in_top_after = if (bond.saturating_add(more)).into() > self.lowest_top_delegation_amount + { + // bump it from bottom + bottom_delegations.delegations = bottom_delegations + .delegations + .clone() + .into_iter() + .filter(|d| { + if d.owner != delegator { + true + } else { + delegation_option = Some(Bond { + owner: d.owner.clone(), + amount: d.amount.saturating_add(more), + }); + false + } + }) + .collect(); + let delegation = delegation_option.ok_or(Error::::DelegationDNE)?; + bottom_delegations.total = bottom_delegations.total.saturating_sub(bond); + // add it to top + let mut top_delegations = >::get(candidate) + .expect("CandidateInfo existence => TopDelegations existence"); + // if top is full, pop lowest top + if matches!(top_delegations.top_capacity::(), CapacityStatus::Full) { + // pop lowest top delegation + let new_bottom_delegation = top_delegations + .delegations + .pop() + .expect("Top capacity full => Exists at least 1 top delegation"); + top_delegations.total = top_delegations + .total + .saturating_sub(new_bottom_delegation.amount); + bottom_delegations.insert_sorted_greatest_to_least(new_bottom_delegation); + } + // insert into top + top_delegations.insert_sorted_greatest_to_least(delegation); + self.reset_top_data::(candidate.clone(), &top_delegations); + >::insert(candidate, top_delegations); + true + } else { + let mut in_bottom = false; + // just increase the delegation + bottom_delegations.delegations = bottom_delegations + .delegations + .clone() + .into_iter() + .map(|d| { + if d.owner != delegator { + d + } else { + in_bottom = true; + Bond { + owner: d.owner, + amount: d.amount.saturating_add(more), + } + } + }) + .collect(); + ensure!(in_bottom, Error::::DelegationDNE); + bottom_delegations.total = bottom_delegations.total.saturating_add(more); + bottom_delegations.sort_greatest_to_least(); + false + }; + self.reset_bottom_data::(&bottom_delegations); + >::insert(candidate, bottom_delegations); + Ok(in_top_after) + } + /// Decrease delegation + pub fn decrease_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + bond: Balance, + less: BalanceOf, + ) -> Result + where + BalanceOf: Into + From, + { + let lowest_top_eq_highest_bottom = + self.lowest_top_delegation_amount == self.highest_bottom_delegation_amount; + let bond_geq_lowest_top = bond >= self.lowest_top_delegation_amount; + let delegation_dne_err: DispatchError = Error::::DelegationDNE.into(); + if bond_geq_lowest_top && !lowest_top_eq_highest_bottom { + // definitely in top + self.decrease_top_delegation::(candidate, delegator.clone(), bond.into(), less) + } else if bond_geq_lowest_top && lowest_top_eq_highest_bottom { + // update top but if error then update bottom (because could be in bottom because + // lowest_top_eq_highest_bottom) + let result = + self.decrease_top_delegation::(candidate, delegator.clone(), bond.into(), less); + if result == Err(delegation_dne_err) { + self.decrease_bottom_delegation::(candidate, delegator, less) + } else { + result + } + } else { + self.decrease_bottom_delegation::(candidate, delegator, less) + } + } + /// Decrease top delegation + pub fn decrease_top_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + bond: BalanceOf, + less: BalanceOf, + ) -> Result + where + BalanceOf: Into + From, + { + // The delegation after the `decrease-delegation` will be strictly less than the + // highest bottom delegation + let bond_after_less_than_highest_bottom = + bond.saturating_sub(less).into() < self.highest_bottom_delegation_amount; + // The top delegations is full and the bottom delegations has at least one delegation + let full_top_and_nonempty_bottom = matches!(self.top_capacity, CapacityStatus::Full) + && !matches!(self.bottom_capacity, CapacityStatus::Empty); + let mut top_delegations = + >::get(candidate).ok_or(Error::::CandidateDNE)?; + let in_top_after = if bond_after_less_than_highest_bottom && full_top_and_nonempty_bottom { + let mut delegation_option: Option>> = None; + // take delegation from top + top_delegations.delegations = top_delegations + .delegations + .clone() + .into_iter() + .filter(|d| { + if d.owner != delegator { + true + } else { + top_delegations.total = top_delegations.total.saturating_sub(d.amount); + delegation_option = Some(Bond { + owner: d.owner.clone(), + amount: d.amount.saturating_sub(less), + }); + false + } + }) + .collect(); + let delegation = delegation_option.ok_or(Error::::DelegationDNE)?; + // pop highest bottom by reverse and popping + let mut bottom_delegations = >::get(candidate) + .expect("CandidateInfo existence => BottomDelegations existence"); + let highest_bottom_delegation = bottom_delegations.delegations.remove(0); + bottom_delegations.total = bottom_delegations + .total + .saturating_sub(highest_bottom_delegation.amount); + // insert highest bottom into top + top_delegations.insert_sorted_greatest_to_least(highest_bottom_delegation); + // insert previous top into bottom + bottom_delegations.insert_sorted_greatest_to_least(delegation); + self.reset_bottom_data::(&bottom_delegations); + >::insert(candidate, bottom_delegations); + false + } else { + // keep it in the top + let mut is_in_top = false; + top_delegations.delegations = top_delegations + .delegations + .clone() + .into_iter() + .map(|d| { + if d.owner != delegator { + d + } else { + is_in_top = true; + Bond { + owner: d.owner, + amount: d.amount.saturating_sub(less), + } + } + }) + .collect(); + ensure!(is_in_top, Error::::DelegationDNE); + top_delegations.total = top_delegations.total.saturating_sub(less); + top_delegations.sort_greatest_to_least(); + true + }; + self.reset_top_data::(candidate.clone(), &top_delegations); + >::insert(candidate, top_delegations); + Ok(in_top_after) + } + /// Decrease bottom delegation + pub fn decrease_bottom_delegation( + &mut self, + candidate: &T::AccountId, + delegator: T::AccountId, + less: BalanceOf, + ) -> Result + where + BalanceOf: Into, + { + let mut bottom_delegations = >::get(candidate) + .expect("CandidateInfo exists => BottomDelegations exists"); + let mut in_bottom = false; + bottom_delegations.delegations = bottom_delegations + .delegations + .clone() + .into_iter() + .map(|d| { + if d.owner != delegator { + d + } else { + in_bottom = true; + Bond { + owner: d.owner, + amount: d.amount.saturating_sub(less), + } + } + }) + .collect(); + ensure!(in_bottom, Error::::DelegationDNE); + bottom_delegations.sort_greatest_to_least(); + self.reset_bottom_data::(&bottom_delegations); + >::insert(candidate, bottom_delegations); + Ok(false) + } +} + +// Temporary manual implementation for migration testing purposes +impl PartialEq for CollatorCandidate { + fn eq(&self, other: &Self) -> bool { + let must_be_true = self.id == other.id + && self.bond == other.bond + && self.total_counted == other.total_counted + && self.total_backing == other.total_backing + && self.request == other.request + && self.state == other.state; + if !must_be_true { + return false; + } + for (x, y) in self.delegators.0.iter().zip(other.delegators.0.iter()) { + if x != y { + return false; + } + } + for ( + Bond { + owner: o1, + amount: a1, + }, + Bond { + owner: o2, + amount: a2, + }, + ) in self + .top_delegations + .iter() + .zip(other.top_delegations.iter()) + { + if o1 != o2 || a1 != a2 { + return false; + } + } + for ( + Bond { + owner: o1, + amount: a1, + }, + Bond { + owner: o2, + amount: a2, + }, + ) in self + .bottom_delegations + .iter() + .zip(other.bottom_delegations.iter()) + { + if o1 != o2 || a1 != a2 { + return false; + } + } + true + } +} + +/// Convey relevant information describing if a delegator was added to the top or bottom +/// Delegations added to the top yield a new total +#[derive(Clone, Copy, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +pub enum DelegatorAdded { + AddedToTop { new_total: B }, + AddedToBottom, +} + +impl< + A: Ord + Clone + sp_std::fmt::Debug, + B: AtLeast32BitUnsigned + + Ord + + Copy + + sp_std::ops::AddAssign + + sp_std::ops::SubAssign + + sp_std::fmt::Debug, + > CollatorCandidate +{ + pub fn is_active(&self) -> bool { + self.state == CollatorStatus::Active + } +} + +impl From> for CollatorSnapshot { + fn from(other: CollatorCandidate) -> CollatorSnapshot { + CollatorSnapshot { + bond: other.bond, + delegations: other.top_delegations, + total: other.total_counted, + } + } +} + +#[derive(Clone, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +pub enum DelegatorStatus { + /// Active with no scheduled exit + Active, +} + +#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Delegator state +pub struct Delegator { + /// Delegator account + pub id: AccountId, + /// All current delegations + pub delegations: OrderedSet>, + /// Total balance locked for this delegator + pub total: Balance, + /// Sum of pending revocation amounts + bond less amounts + pub less_total: Balance, + /// Status for this delegator + pub status: DelegatorStatus, +} + +// Temporary manual implementation for migration testing purposes +impl PartialEq for Delegator { + fn eq(&self, other: &Self) -> bool { + let must_be_true = self.id == other.id + && self.total == other.total + && self.less_total == other.less_total + && self.status == other.status; + if !must_be_true { + return false; + } + for ( + Bond { + owner: o1, + amount: a1, + }, + Bond { + owner: o2, + amount: a2, + }, + ) in self.delegations.0.iter().zip(other.delegations.0.iter()) + { + if o1 != o2 || a1 != a2 { + return false; + } + } + true + } +} + +impl< + AccountId: Ord + Clone, + Balance: Copy + + sp_std::ops::AddAssign + + sp_std::ops::Add + + sp_std::ops::SubAssign + + sp_std::ops::Sub + + Ord + + Zero + + Default + + Saturating, + > Delegator +{ + pub fn new(id: AccountId, collator: AccountId, amount: Balance) -> Self { + Delegator { + id, + delegations: OrderedSet::from(vec![Bond { + owner: collator, + amount, + }]), + total: amount, + less_total: Balance::zero(), + status: DelegatorStatus::Active, + } + } + + pub fn is_active(&self) -> bool { + matches!(self.status, DelegatorStatus::Active) + } + + pub fn add_delegation(&mut self, bond: Bond) -> bool { + let amt = bond.amount; + if self.delegations.insert(bond) { + self.total = self.total.saturating_add(amt); + true + } else { + false + } + } + // Return Some(remaining balance), must be more than MinDelegatorStk + // Return None if delegation not found + pub fn rm_delegation(&mut self, collator: &AccountId) -> Option { + let mut amt: Option = None; + let delegations = self + .delegations + .0 + .iter() + .filter_map(|x| { + if &x.owner == collator { + amt = Some(x.amount); + None + } else { + Some(x.clone()) + } + }) + .collect(); + if let Some(balance) = amt { + self.delegations = OrderedSet::from(delegations); + self.total = self.total.saturating_sub(balance); + Some(self.total) + } else { + None + } + } + pub fn increase_delegation( + &mut self, + candidate: AccountId, + amount: Balance, + ) -> DispatchResult + where + BalanceOf: From, + T::AccountId: From, + Delegator>: From>, + { + let delegator_id: T::AccountId = self.id.clone().into(); + let candidate_id: T::AccountId = candidate.clone().into(); + let balance_amt: BalanceOf = amount.into(); + // increase delegation + for x in &mut self.delegations.0 { + if x.owner == candidate { + let before_amount: BalanceOf = x.amount.into(); + x.amount = x.amount.saturating_add(amount); + self.total = self.total.saturating_add(amount); + // update collator state delegation + let mut collator_state = + >::get(&candidate_id).ok_or(Error::::CandidateDNE)?; + T::Currency::reserve(&self.id.clone().into(), balance_amt)?; + let before = collator_state.total_counted; + let in_top = collator_state.increase_delegation::( + &candidate_id, + delegator_id.clone(), + before_amount, + balance_amt, + )?; + let after = collator_state.total_counted; + if collator_state.is_active() && (before != after) { + Pallet::::update_active(candidate_id.clone(), after); + } + >::insert(&candidate_id, collator_state); + let new_total_staked = >::get().saturating_add(balance_amt); + >::put(new_total_staked); + let nom_st: Delegator> = self.clone().into(); + >::insert(&delegator_id, nom_st); + Pallet::::deposit_event(Event::DelegationIncreased { + delegator: delegator_id, + candidate: candidate_id, + amount: balance_amt, + in_top: in_top, + }); + return Ok(()); + } + } + Err(Error::::DelegationDNE.into()) + } + + /// Retrieves the bond amount that a delegator has provided towards a collator. + /// Returns `None` if missing. + pub fn get_bond_amount(&self, collator: &AccountId) -> Option { + self.delegations + .0 + .iter() + .find(|b| &b.owner == collator) + .map(|b| b.amount) + } +} + +pub mod deprecated { + #![allow(deprecated)] + + use super::*; + + #[deprecated(note = "use DelegationAction")] + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Changes requested by the delegator + /// - limit of 1 ongoing change per delegation + pub enum DelegationChange { + Revoke, + Decrease, + } + + #[deprecated(note = "use ScheduledRequest")] + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + pub struct DelegationRequest { + pub collator: AccountId, + pub amount: Balance, + pub when_executable: RoundIndex, + pub action: DelegationChange, + } + + #[deprecated(note = "use DelegationScheduledRequests storage item")] + #[derive(Clone, Encode, PartialEq, Decode, RuntimeDebug, TypeInfo)] + /// Pending requests to mutate delegations for each delegator + pub struct PendingDelegationRequests { + /// Number of pending revocations (necessary for determining whether revoke is exit) + pub revocations_count: u32, + /// Map from collator -> Request (enforces at most 1 pending request per delegation) + pub requests: BTreeMap>, + /// Sum of pending revocation amounts + bond less amounts + pub less_total: Balance, + } + + impl Default for PendingDelegationRequests { + fn default() -> PendingDelegationRequests { + PendingDelegationRequests { + revocations_count: 0u32, + requests: BTreeMap::new(), + less_total: B::zero(), + } + } + } + + impl< + A: Ord + Clone, + B: Zero + + Ord + + Copy + + Clone + + sp_std::ops::AddAssign + + sp_std::ops::Add + + sp_std::ops::SubAssign + + sp_std::ops::Sub + + Saturating, + > PendingDelegationRequests + { + /// New default (empty) pending requests + pub fn new() -> Self { + Self::default() + } + } + + #[deprecated(note = "use new crate::types::Delegator struct")] + #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] + /// Delegator state + pub struct Delegator { + /// Delegator account + pub id: AccountId, + /// All current delegations + pub delegations: OrderedSet>, + /// Total balance locked for this delegator + pub total: Balance, + /// Requests to change delegations, relevant iff active + pub requests: PendingDelegationRequests, + /// Status for this delegator + pub status: DelegatorStatus, + } +} + +#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +/// DEPRECATED in favor of Delegator +/// Nominator state +pub struct Nominator2 { + /// All current delegations + pub delegations: OrderedSet>, + /// Delegations scheduled to be revoked + pub revocations: OrderedSet, + /// Total balance locked for this nominator + pub total: Balance, + /// Total number of revocations scheduled to be executed + pub scheduled_revocations_count: u32, + /// Total amount to be unbonded once revocations are executed + pub scheduled_revocations_total: Balance, + /// Status for this nominator + pub status: DelegatorStatus, +} + +// /// Temporary function to migrate state +// pub(crate) fn migrate_nominator_to_delegator_state( +// id: T::AccountId, +// nominator: Nominator2>, +// ) -> Delegator> { +// Delegator { +// id, +// delegations: nominator.delegations, +// total: nominator.total, +// requests: PendingDelegationRequests::new(), +// status: nominator.status, +// } +// } + +#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +/// The current round index and transition information +pub struct RoundInfo { + /// Current round index + pub current: RoundIndex, + /// The first block of the current round + pub first: BlockNumber, + /// The length of the current round in number of blocks + pub length: u32, +} +impl< + B: Copy + sp_std::ops::Add + sp_std::ops::Sub + From + PartialOrd, + > RoundInfo +{ + pub fn new(current: RoundIndex, first: B, length: u32) -> RoundInfo { + RoundInfo { + current, + first, + length, + } + } + /// Check if the round should be updated + pub fn should_update(&self, now: B) -> bool { + now - self.first >= self.length.into() + } + /// New round + pub fn update(&mut self, now: B) { + self.current = self.current.saturating_add(1u32); + self.first = now; + } +} +impl< + B: Copy + sp_std::ops::Add + sp_std::ops::Sub + From + PartialOrd, + > Default for RoundInfo +{ + fn default() -> RoundInfo { + RoundInfo::new(1u32, 1u32.into(), 20u32) + } +} + +#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +/// Reserve information { account, percent_of_inflation } +pub struct ParachainBondConfig { + /// Account which receives funds intended for parachain bond + pub account: AccountId, + /// Percent of inflation set aside for parachain bond account + pub percent: Percent, +} +impl Default for ParachainBondConfig { + fn default() -> ParachainBondConfig { + ParachainBondConfig { + account: A::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"), + percent: Percent::zero(), + } + } +} diff --git a/pallets/parachain-staking/src/weights.rs b/pallets/parachain-staking/src/weights.rs new file mode 100644 index 0000000000..39dec52300 --- /dev/null +++ b/pallets/parachain-staking/src/weights.rs @@ -0,0 +1,642 @@ +// This file is part of Mangata. + +// Copyright (C) 2020-2022 Mangata Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for parachain_staking +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-24, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// /home/ubuntu/mangata-node/scripts/..//target/release/mangata-node +// benchmark +// --chain +// dev +// --execution +// wasm +// --wasm-execution +// compiled +// --pallet +// parachain_staking +// --extrinsic +// * +// --steps +// 20 +// --repeat +// 10 +// --output +// ./benchmarks/parachain_staking_weights.rs +// --template +// ./templates/module-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for parachain_staking. +pub trait WeightInfo { + fn set_total_selected() -> Weight; + fn set_collator_commission() -> Weight; + fn join_candidates(x: u32, y: u32, ) -> Weight; + fn schedule_leave_candidates(x: u32, ) -> Weight; + fn execute_leave_candidates(x: u32, ) -> Weight; + fn cancel_leave_candidates(x: u32, ) -> Weight; + fn go_offline() -> Weight; + fn go_online() -> Weight; + fn schedule_candidate_bond_more() -> Weight; + fn schedule_candidate_bond_less() -> Weight; + fn execute_candidate_bond_more() -> Weight; + fn execute_candidate_bond_less() -> Weight; + fn cancel_candidate_bond_more() -> Weight; + fn cancel_candidate_bond_less() -> Weight; + fn delegate(x: u32, y: u32, ) -> Weight; + fn schedule_leave_delegators() -> Weight; + fn execute_leave_delegators(x: u32, ) -> Weight; + fn cancel_leave_delegators() -> Weight; + fn schedule_revoke_delegation() -> Weight; + fn schedule_delegator_bond_more() -> Weight; + fn schedule_delegator_bond_less() -> Weight; + fn execute_revoke_delegation() -> Weight; + fn execute_delegator_bond_more() -> Weight; + fn execute_delegator_bond_less() -> Weight; + fn cancel_revoke_delegation() -> Weight; + fn cancel_delegator_bond_more() -> Weight; + fn cancel_delegator_bond_less() -> Weight; + fn add_staking_liquidity_token(x: u32, ) -> Weight; + fn remove_staking_liquidity_token(x: u32, ) -> Weight; + fn passive_session_change() -> Weight; + fn active_session_change(x: u32, y: u32, z: u32) -> Weight; + fn payout_collator_rewards() -> Weight; + fn payout_delegator_reward() -> Weight; + fn update_candidate_aggregator() -> Weight; + fn aggregator_update_metadata() -> Weight; +} + +/// Weights for parachain_staking using the Mangata node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + // Storage: ParachainStaking TotalSelected (r:1 w:1) + fn set_total_selected() -> Weight { + Weight::from_parts(14_867_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CollatorCommission (r:1 w:1) + fn set_collator_commission() -> Weight { + Weight::from_parts(14_948_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking DelegatorState (r:1 w:0) + // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:0) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn join_candidates(x: u32, y: u32, ) -> Weight { + Weight::from_parts(57_975_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(452_000, 0)).saturating_mul(x as u64)) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(95_000, 0)).saturating_mul(y as u64)) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + fn schedule_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(34_598_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(428_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: Tokens Accounts (r:2 w:2) + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn execute_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(19_556_000, 0) + // Standard Error: 19_000 + .saturating_add((Weight::from_parts(19_556_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(x as u64))) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + fn cancel_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(31_884_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(421_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn go_offline() -> Weight { + Weight::from_parts(34_946_000, 0) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn go_online() -> Weight { + Weight::from_parts(33_628_000, 0) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:0) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_candidate_bond_more() -> Weight { + Weight::from_parts(36_194_000, 0) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_candidate_bond_less() -> Weight { + Weight::from_parts(29_009_000, 0) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + fn execute_candidate_bond_more() -> Weight { + Weight::from_parts(61_070_000, 0) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + fn execute_candidate_bond_less() -> Weight { + Weight::from_parts(57_922_000, 0) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + fn cancel_candidate_bond_more() -> Weight { + Weight::from_parts(26_206_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + fn cancel_candidate_bond_less() -> Weight { + Weight::from_parts(25_974_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn delegate(x: u32, y: u32, ) -> Weight { + Weight::from_parts(62_286_000, 0) + // Standard Error: 9_000 + .saturating_add((Weight::from_parts(689_000, 0)).saturating_mul(x as u64)) + // Standard Error: 30_000 + .saturating_add((Weight::from_parts(639_000, 0)).saturating_mul(y as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_leave_delegators() -> Weight { + Weight::from_parts(30_002_000, 0) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn execute_leave_delegators(x: u32, ) -> Weight { + Weight::from_parts(0, 0) + // Standard Error: 110_000 + .saturating_add((Weight::from_parts(29_927_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(x as u64))) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + fn cancel_leave_delegators() -> Weight { + Weight::from_parts(25_498_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_revoke_delegation() -> Weight { + Weight::from_parts(30_598_000, 0) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:0) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_delegator_bond_more() -> Weight { + Weight::from_parts(38_554_000, 0) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + fn schedule_delegator_bond_less() -> Weight { + Weight::from_parts(30_322_000, 0) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn execute_revoke_delegation() -> Weight { + Weight::from_parts(76_394_000, 0) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn execute_delegator_bond_more() -> Weight { + Weight::from_parts(70_382_000, 0) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking Round (r:1 w:0) + // Storage: ParachainStaking CandidateState (r:1 w:1) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + fn execute_delegator_bond_less() -> Weight { + Weight::from_parts(66_780_000, 0) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + fn cancel_revoke_delegation() -> Weight { + Weight::from_parts(27_076_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + fn cancel_delegator_bond_more() -> Weight { + Weight::from_parts(32_355_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:1) + fn cancel_delegator_bond_less() -> Weight { + Weight::from_parts(31_925_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) + fn add_staking_liquidity_token(x: u32, ) -> Weight { + Weight::from_parts(7_373_000, 0) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(92_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) + fn remove_staking_liquidity_token(x: u32, ) -> Weight { + Weight::from_parts(7_078_000, 0) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(95_000, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ParachainStaking Round (r:1 w:0) + fn passive_session_change() -> Weight { + Weight::from_parts(5_166_000, 0) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + } + // Storage: ParachainStaking Round (r:1 w:1) + // Storage: Session CurrentIndex (r:1 w:1) + // Storage: Session QueuedChanged (r:1 w:1) + // Storage: Session QueuedKeys (r:1 w:1) + // Storage: Session DisabledValidators (r:1 w:0) + // Storage: ParachainStaking Points (r:1 w:1) + // Storage: ParachainStaking Staked (r:1 w:2) + // Storage: ParachainStaking InflationConfig (r:1 w:0) + // Storage: Tokens TotalIssuance (r:4 w:1) + // Storage: ParachainStaking ParachainBondInfo (r:1 w:0) + // Storage: Tokens Accounts (r:289 w:289) + // Storage: System Account (r:287 w:287) + // Storage: ParachainStaking CollatorCommission (r:1 w:0) + // Storage: ParachainStaking AwardedPts (r:25 w:24) + // Storage: ParachainStaking AtStake (r:24 w:48) + // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) + // Storage: Xyk LiquidityPools (r:3 w:0) + // Storage: Xyk Pools (r:3 w:0) + // Storage: ParachainStaking CandidatePool (r:1 w:0) + // Storage: ParachainStaking TotalSelected (r:1 w:0) + // Storage: ParachainStaking CandidateState (r:24 w:0) + // Storage: Session NextKeys (r:24 w:0) + // Storage: Aura Authorities (r:1 w:0) + // Storage: ParachainStaking SelectedCandidates (r:0 w:1) + // Storage: Session Validators (r:0 w:1) + fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { + (Weight::from_parts(819_648_670, 0)) + // Standard Error: 16_309 + .saturating_add((Weight::from_parts(15_337_752, 0)).saturating_mul(x as u64)) + // Standard Error: 70_621 + .saturating_add((Weight::from_parts(6_320_523, 0)).saturating_mul(y as u64)) + // Standard Error: 166_526 + .saturating_add((Weight::from_parts(32_822_119, 0)).saturating_mul(z as u64)) + .saturating_add(RocksDbWeight::get().reads(124 as u64)) + .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(119 as u64)) + } + + fn payout_collator_rewards() -> Weight{ + Weight::from_parts(0, 0) + .saturating_add(RocksDbWeight::get().reads((20 as u64))) + .saturating_add(RocksDbWeight::get().writes((20 as u64))) + } + + fn payout_delegator_reward() -> Weight{ + Weight::from_parts(0, 0) + .saturating_add(RocksDbWeight::get().reads((20 as u64))) + .saturating_add(RocksDbWeight::get().writes((20 as u64))) + } + // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking DelegatorState (r:1 w:0) + // Storage: ParachainStaking AggregatorMetadata (r:1 w:1) + // Storage: ParachainStaking CandidateAggregator (r:1 w:1) + fn aggregator_update_metadata() -> Weight { + (Weight::from_parts(599_580_000, 0)) + .saturating_add(RocksDbWeight::get().reads(52 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:0) + // Storage: ParachainStaking CandidateAggregator (r:1 w:1) + // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) + fn update_candidate_aggregator() -> Weight { + (Weight::from_parts(98_020_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + } + // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn set_total_selected() -> Weight { + Weight::from_parts(14_867_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn set_collator_commission() -> Weight { + Weight::from_parts(14_948_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn join_candidates(x: u32, y: u32, ) -> Weight { + Weight::from_parts(57_975_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(452_000, 0)).saturating_mul(x as u64)) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(95_000, 0)).saturating_mul(y as u64)) + .saturating_add(RocksDbWeight::get().reads(6 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + fn schedule_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(34_598_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(428_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + fn execute_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(34_089_000, 0) + // Standard Error: 19_000 + .saturating_add((Weight::from_parts(19_556_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(x as u64))) + } + fn cancel_leave_candidates(x: u32, ) -> Weight { + Weight::from_parts(31_884_000, 0) + // Standard Error: 3_000 + .saturating_add((Weight::from_parts(421_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + fn go_offline() -> Weight { + Weight::from_parts(34_946_000, 0) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + fn go_online() -> Weight { + Weight::from_parts(33_628_000, 0) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + fn schedule_candidate_bond_more() -> Weight { + Weight::from_parts(36_194_000, 0) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_candidate_bond_less() -> Weight { + Weight::from_parts(29_009_000, 0) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn execute_candidate_bond_more() -> Weight { + Weight::from_parts(61_070_000, 0) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + fn execute_candidate_bond_less() -> Weight { + Weight::from_parts(57_922_000, 0) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + fn cancel_candidate_bond_more() -> Weight { + Weight::from_parts(26_206_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn cancel_candidate_bond_less() -> Weight { + Weight::from_parts(25_974_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn delegate(x: u32, y: u32, ) -> Weight { + Weight::from_parts(62_286_000, 0) + // Standard Error: 9_000 + .saturating_add((Weight::from_parts(689_000, 0)).saturating_mul(x as u64)) + // Standard Error: 30_000 + .saturating_add((Weight::from_parts(639_000, 0)).saturating_mul(y as u64)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) + } + fn schedule_leave_delegators() -> Weight { + Weight::from_parts(30_002_000, 0) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn execute_leave_delegators(x: u32, ) -> Weight { + Weight::from_parts(0, 0) + // Standard Error: 110_000 + .saturating_add((Weight::from_parts(29_927_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(x as u64))) + } + fn cancel_leave_delegators() -> Weight { + Weight::from_parts(25_498_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_revoke_delegation() -> Weight { + Weight::from_parts(30_598_000, 0) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_delegator_bond_more() -> Weight { + Weight::from_parts(38_554_000, 0) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn schedule_delegator_bond_less() -> Weight { + Weight::from_parts(30_322_000, 0) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn execute_revoke_delegation() -> Weight { + Weight::from_parts(76_394_000, 0) + .saturating_add(RocksDbWeight::get().reads(6 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) + } + fn execute_delegator_bond_more() -> Weight { + Weight::from_parts(70_382_000, 0) + .saturating_add(RocksDbWeight::get().reads(6 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) + } + fn execute_delegator_bond_less() -> Weight { + Weight::from_parts(66_780_000, 0) + .saturating_add(RocksDbWeight::get().reads(6 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) + } + fn cancel_revoke_delegation() -> Weight { + Weight::from_parts(27_076_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn cancel_delegator_bond_more() -> Weight { + Weight::from_parts(32_355_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn cancel_delegator_bond_less() -> Weight { + Weight::from_parts(31_925_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn add_staking_liquidity_token(x: u32, ) -> Weight { + Weight::from_parts(7_373_000, 0) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(92_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn remove_staking_liquidity_token(x: u32, ) -> Weight { + Weight::from_parts(7_078_000, 0) + // Standard Error: 1_000 + .saturating_add((Weight::from_parts(95_000, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) + } + fn passive_session_change() -> Weight { + Weight::from_parts(5_166_000, 0) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + } + fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { + (Weight::from_parts(819_648_670, 0)) + // Standard Error: 16_309 + .saturating_add((Weight::from_parts(15_337_752, 0)).saturating_mul(x as u64)) + // Standard Error: 70_621 + .saturating_add((Weight::from_parts(6_320_523, 0)).saturating_mul(y as u64)) + // Standard Error: 166_526 + .saturating_add((Weight::from_parts(32_822_119, 0)).saturating_mul(z as u64)) + .saturating_add(RocksDbWeight::get().reads(124 as u64)) + .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(119 as u64)) + } + + fn payout_collator_rewards() -> Weight{ + Weight::from_parts(0, 0) + .saturating_add(RocksDbWeight::get().reads((20 as u64))) + .saturating_add(RocksDbWeight::get().writes((20 as u64))) + } + + fn payout_delegator_reward() -> Weight{ + Weight::from_parts(0, 0) + .saturating_add(RocksDbWeight::get().reads((20 as u64))) + .saturating_add(RocksDbWeight::get().writes((20 as u64))) + } + // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking DelegatorState (r:1 w:0) + // Storage: ParachainStaking AggregatorMetadata (r:1 w:1) + // Storage: ParachainStaking CandidateAggregator (r:1 w:1) + fn aggregator_update_metadata() -> Weight { + (Weight::from_parts(599_580_000, 0)) + .saturating_add(RocksDbWeight::get().reads(52 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: ParachainStaking CandidateState (r:1 w:0) + // Storage: ParachainStaking CandidateAggregator (r:1 w:1) + // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) + fn update_candidate_aggregator() -> Weight { + (Weight::from_parts(98_020_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + } + // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) +} diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index 68feb0a224..4ae41ef719 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -1,75 +1,78 @@ [package] -authors = ['Mangata team'] -edition = '2018' -name = 'pallet-proof-of-stake' -version = '0.1.0' +authors = ["Mangata team"] +edition = "2018" +name = "pallet-proof-of-stake" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex = { package = "rustc-hex", version = "2.1.0", default-features = false } hex-literal = { version = "0.3.3", default-features = false } +log = { version = "0.4.14", default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = "5.0.0", default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-issuance = { default-features = false, path = "../issuance" } pallet-bootstrap = { default-features = false, path = "../bootstrap" } -sp-arithmetic = { default-features = false, version = '6.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -libm = { default-features = false, git = "https://github.com/rust-lang/libm", rev="2f3fc968f43d345f9b449938d050a9ea46a04c83"} -orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +pallet-issuance = { default-features = false, path = "../issuance" } + +libm = { git = "https://github.com/rust-lang/libm", rev = "2f3fc968f43d345f9b449938d050a9ea46a04c83", default-features = false } + +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -similar-asserts = "1.1.0" -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" env_logger = "0.9.0" +lazy_static = "1.1.1" serial_test = { version = "0.6.0", default-features = false } +similar-asserts = "1.1.0" test-case = "2.0.2" +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + [features] -default = ['std'] +default = ["std"] std = [ - 'hex/std', - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - 'frame-support/std', - 'frame-system/std', - "frame-benchmarking/std", - 'orml-tokens/std', + "codec/std", + "hex/std", "frame-benchmarking/std", - 'pallet-vesting-mangata/std', - "mangata-support/std", + "frame-support/std", + "frame-system/std", + "mangata-support/std", + "orml-tokens/std", + "pallet-vesting-mangata/std", "scale-info/std", + "serde", + "sp-std/std", + "sp-core/std", ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "orml-tokens/try-runtime", "pallet-bootstrap/try-runtime", "pallet-issuance/try-runtime", "pallet-vesting-mangata/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 4066363d90..4d84cb89f2 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -54,38 +54,39 @@ benchmarks! { init!(); let caller: ::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + let initial_amount: BalanceOf = 1000000000000000000000_u128.try_into().ok().expect("should fit"); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); - let liquidity_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); - PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); + let amount: BalanceOf = ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).try_into().ok().expect("should fit"); + let liquidity_asset_id = ::Currency::create(&caller, amount).unwrap(); + PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); assert_eq!( - ::Currency::total_issuance(liquidity_asset_id.into()), - ::Currency::free_balance(liquidity_asset_id.into(), &caller), + ::Currency::total_issuance(liquidity_asset_id), + ::Currency::free_balance(liquidity_asset_id, &caller), ); - let total_minted_liquidity = ::Currency::total_issuance(liquidity_asset_id.into()); - let half_of_minted_liquidity = total_minted_liquidity.into() / 2_u128; - let quater_of_minted_liquidity = total_minted_liquidity.into() / 4_u128; + let total_minted_liquidity = ::Currency::total_issuance(liquidity_asset_id); + let half_of_minted_liquidity = total_minted_liquidity / 2_u32.into(); + let quater_of_minted_liquidity = total_minted_liquidity / 4_u32.into(); forward_to_next_session!(); - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id, quater_of_minted_liquidity, None).unwrap(); forward_to_next_session!(); forward_to_next_session!(); - assert!(PoS::::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap() > 0); + assert!(PoS::::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap() > 0_u32.into()); }: claim_rewards_all(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id) verify { assert_eq!( - 0, + BalanceOf::::zero(), PoS::::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap() ); @@ -94,8 +95,8 @@ benchmarks! { update_pool_promotion { let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000; - let token_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + let initial_amount: BalanceOf = 1000000000000_u128.try_into().ok().expect("should fit"); + let token_id = ::Currency::create(&caller, initial_amount).unwrap(); }: update_pool_promotion(RawOrigin::Root, token_id, 1u8) @@ -115,25 +116,26 @@ benchmarks! { init!(); let caller: ::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + let initial_amount: BalanceOf = 1000000000000000000000_u128.try_into().ok().expect("should fit"); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); - let liquidity_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); - PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); + let amount: BalanceOf = ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).try_into().ok().expect("should fit"); + let liquidity_asset_id = ::Currency::create(&caller, amount).unwrap(); + PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); assert_eq!( - ::Currency::total_issuance(liquidity_asset_id.into()), - ::Currency::free_balance(liquidity_asset_id.into(), &caller), + ::Currency::total_issuance(liquidity_asset_id), + ::Currency::free_balance(liquidity_asset_id, &caller), ); - let total_minted_liquidity: u128 = ::Currency::total_issuance(liquidity_asset_id.into()).into(); - let half_of_minted_liquidity = total_minted_liquidity / 2_u128; - let quater_of_minted_liquidity = total_minted_liquidity / 4_u128; + let total_minted_liquidity = ::Currency::total_issuance(liquidity_asset_id); + let half_of_minted_liquidity = total_minted_liquidity / 2_u32.into(); + let quater_of_minted_liquidity = total_minted_liquidity / 4_u32.into(); - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id, quater_of_minted_liquidity, None).unwrap(); assert_eq!( PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, @@ -142,11 +144,11 @@ benchmarks! { forward_to_next_session!(); - }: activate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity, None) + }: activate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, quater_of_minted_liquidity, None) verify { assert_eq!( - PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, + PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, half_of_minted_liquidity ) } @@ -160,36 +162,37 @@ benchmarks! { init!(); let caller: ::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let liquidity_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); + let initial_amount: BalanceOf = 1000000000000000000000_u128.try_into().ok().expect("should fit"); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + let amount: BalanceOf = ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).try_into().ok().expect("should fit"); + let liquidity_asset_id = ::Currency::create(&caller, amount).unwrap(); PoS::::enable(liquidity_asset_id, 1u8); assert_eq!( - ::Currency::total_issuance(liquidity_asset_id.into()), - ::Currency::free_balance(liquidity_asset_id.into(), &caller), + ::Currency::total_issuance(liquidity_asset_id), + ::Currency::free_balance(liquidity_asset_id, &caller), ); - let total_minted_liquidity = ::Currency::total_issuance(liquidity_asset_id.into()); - let half_of_minted_liquidity = total_minted_liquidity.into() / 2_u128; - let quater_of_minted_liquidity = total_minted_liquidity.into() / 4_u128; + let total_minted_liquidity = ::Currency::total_issuance(liquidity_asset_id); + let half_of_minted_liquidity = total_minted_liquidity / 2_u32.into(); + let quater_of_minted_liquidity = total_minted_liquidity / 4_u32.into(); - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone().into()).into(), liquidity_asset_id.into(), half_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity(RawOrigin::Signed(caller.clone().into()).into(), liquidity_asset_id, half_of_minted_liquidity, None).unwrap(); assert_eq!( - PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, + PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, half_of_minted_liquidity ); forward_to_next_session!(); - }: deactivate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity.into()) + }: deactivate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, quater_of_minted_liquidity) verify { assert_eq!( - PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, + PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, quater_of_minted_liquidity ); } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 426009495e..448c770232 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1,10 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_benchmarking::Zero; -use frame_support::{ - dispatch::{DispatchError, DispatchResult}, - ensure, -}; +use frame_support::{dispatch::DispatchResult, ensure}; use frame_system::ensure_signed; use sp_core::U256; @@ -17,11 +13,14 @@ use frame_system::pallet_prelude::*; use mangata_support::traits::{ ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, }; -use mangata_types::{multipurpose_liquidity::ActivateKind, Balance, TokenId}; +use mangata_types::multipurpose_liquidity::ActivateKind; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; use sp_std::collections::btree_map::BTreeMap; -use sp_runtime::{traits::SaturatedConversion, Perbill}; +use sp_runtime::{ + traits::{CheckedAdd, CheckedSub, SaturatedConversion, Zero}, + DispatchError, Perbill, +}; use sp_std::{convert::TryInto, prelude::*}; mod reward_info; @@ -54,6 +53,14 @@ pub use weights::WeightInfo; type AccountIdOf = ::AccountId; +type BalanceOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::Balance; + +type CurrencyIdOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -63,7 +70,7 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks> for Pallet {} #[cfg(feature = "runtime-benchmarks")] pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} @@ -80,9 +87,11 @@ pub mod pallet { pub trait Config: frame_system::Config + PoSBenchmarkingConfig { type RuntimeEvent: From> + IsType<::RuntimeEvent>; type ActivationReservesProvider: ActivationReservesProviderTrait< - AccountId = Self::AccountId, + Self::AccountId, + BalanceOf, + CurrencyIdOf, >; - type NativeCurrencyId: Get; + type NativeCurrencyId: Get>; type Currency: MultiTokenCurrencyExtended + MultiTokenReservableCurrency; #[pallet::constant] @@ -117,10 +126,10 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - PoolPromotionUpdated(TokenId, Option), - LiquidityActivated(T::AccountId, TokenId, Balance), - LiquidityDeactivated(T::AccountId, TokenId, Balance), - RewardsClaimed(T::AccountId, TokenId, Balance), + PoolPromotionUpdated(CurrencyIdOf, Option), + LiquidityActivated(T::AccountId, CurrencyIdOf, BalanceOf), + LiquidityDeactivated(T::AccountId, CurrencyIdOf, BalanceOf), + RewardsClaimed(T::AccountId, CurrencyIdOf, BalanceOf), } #[pallet::storage] @@ -130,8 +139,8 @@ pub mod pallet { Twox64Concat, AccountIdOf, Twox64Concat, - TokenId, - RewardInfo, + CurrencyIdOf, + RewardInfo>, ValueQuery, >; @@ -141,7 +150,7 @@ pub mod pallet { /// token. Here is tracked the number of rewards per liquidity token relationship. /// Expect larger values when the number of liquidity tokens are smaller. pub type PromotedPoolRewards = - StorageValue<_, BTreeMap, ValueQuery>; + StorageValue<_, BTreeMap, PromotedPools>, ValueQuery>; #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] /// Information about single token rewards @@ -157,7 +166,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn total_activated_amount)] pub type TotalActivatedLiquidity = - StorageMap<_, Twox64Concat, TokenId, u128, ValueQuery>; + StorageMap<_, Twox64Concat, CurrencyIdOf, BalanceOf, ValueQuery>; #[pallet::call] impl Pallet { @@ -167,11 +176,11 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::claim_rewards_all())] pub fn claim_rewards_all( origin: OriginFor, - liquidity_token_id: TokenId, + liquidity_token_id: CurrencyIdOf, ) -> DispatchResult { let sender = ensure_signed(origin)?; - >::claim_rewards_all( + , CurrencyIdOf>>::claim_rewards_all( sender, liquidity_token_id, )?; @@ -184,18 +193,18 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::update_pool_promotion())] pub fn update_pool_promotion( origin: OriginFor, - liquidity_token_id: TokenId, + liquidity_token_id: CurrencyIdOf, liquidity_mining_issuance_weight: u8, ) -> DispatchResult { ensure_root(origin)?; if liquidity_mining_issuance_weight > 0 { - >::enable( + , CurrencyIdOf>>::enable( liquidity_token_id, liquidity_mining_issuance_weight, ); } else { - >::disable(liquidity_token_id); + , CurrencyIdOf>>::disable(liquidity_token_id); } Ok(()) } @@ -211,13 +220,13 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::activate_liquidity())] pub fn activate_liquidity( origin: OriginFor, - liquidity_token_id: TokenId, - amount: Balance, + liquidity_token_id: CurrencyIdOf, + amount: BalanceOf, use_balance_from: Option, ) -> DispatchResult { let sender = ensure_signed(origin)?; - >::activate_liquidity( + , CurrencyIdOf>>::activate_liquidity( sender, liquidity_token_id, amount, @@ -231,12 +240,12 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::deactivate_liquidity())] pub fn deactivate_liquidity( origin: OriginFor, - liquidity_token_id: TokenId, - amount: Balance, + liquidity_token_id: CurrencyIdOf, + amount: BalanceOf, ) -> DispatchResult { let sender = ensure_signed(origin)?; - >::deactivate_liquidity( + , CurrencyIdOf>>::deactivate_liquidity( sender, liquidity_token_id, amount, @@ -250,18 +259,18 @@ impl Pallet { ::RewardsDistributionPeriod::get() } - fn native_token_id() -> TokenId { + fn native_token_id() -> CurrencyIdOf { ::NativeCurrencyId::get() } - fn get_pool_rewards(liquidity_asset_id: TokenId) -> Result { + fn get_pool_rewards(liquidity_asset_id: CurrencyIdOf) -> Result { Ok(PromotedPoolRewards::::get() .get(&liquidity_asset_id) .map(|v| v.rewards) .ok_or(Error::::NotAPromotedPool)?) } - fn get_current_rewards_time() -> Result { + fn get_current_rewards_time() -> Result { >::block_number() .saturated_into::() .checked_add(1) @@ -269,7 +278,7 @@ impl Pallet { .ok_or(DispatchError::from(Error::::CalculateRewardsMathError)) } - fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { + fn ensure_is_promoted_pool(liquidity_asset_id: CurrencyIdOf) -> Result<(), DispatchError> { if Self::get_pool_rewards(liquidity_asset_id).is_ok() { Ok(()) } else { @@ -279,17 +288,17 @@ impl Pallet { fn set_liquidity_minting_checkpoint( user: AccountIdOf, - liquidity_asset_id: TokenId, - liquidity_assets_added: Balance, + liquidity_asset_id: CurrencyIdOf, + liquidity_assets_added: BalanceOf, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let current_time: u32 = Self::get_current_rewards_time()?; let pool_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?; let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) .unwrap_or(RewardInfo { - activated_amount: 0_u128, - rewards_not_yet_claimed: 0_u128, - rewards_already_claimed: 0_u128, + activated_amount: BalanceOf::::zero(), + rewards_not_yet_claimed: BalanceOf::::zero(), + rewards_already_claimed: BalanceOf::::zero(), last_checkpoint: current_time, pool_ratio_at_last_checkpoint: pool_ratio_current, missing_at_last_checkpoint: U256::from(0u128), @@ -304,7 +313,7 @@ impl Pallet { //TODO: refactor storage name TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { - if let Some(val) = active_amount.checked_add(liquidity_assets_added) { + if let Some(val) = active_amount.checked_add(&liquidity_assets_added) { *active_amount = val; Ok(()) } else { @@ -318,8 +327,8 @@ impl Pallet { fn set_liquidity_burning_checkpoint( user: AccountIdOf, - liquidity_asset_id: TokenId, - liquidity_assets_burned: Balance, + liquidity_asset_id: CurrencyIdOf, + liquidity_assets_burned: BalanceOf, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let current_time: u32 = Self::get_current_rewards_time()?; @@ -340,7 +349,7 @@ impl Pallet { RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { - if let Some(val) = active_amount.checked_sub(liquidity_assets_burned) { + if let Some(val) = active_amount.checked_sub(&liquidity_assets_burned) { *active_amount = val; Ok(()) } else { @@ -359,12 +368,8 @@ impl Pallet { } } -impl ProofOfStakeRewardsApi for Pallet { - type Balance = Balance; - - type CurrencyId = TokenId; - - fn enable(liquidity_token_id: TokenId, weight: u8) { +impl ProofOfStakeRewardsApi, CurrencyIdOf> for Pallet { + fn enable(liquidity_token_id: CurrencyIdOf, weight: u8) { PromotedPoolRewards::::mutate(|promoted_pools| { promoted_pools .entry(liquidity_token_id) @@ -374,7 +379,7 @@ impl ProofOfStakeRewardsApi for Pallet { Pallet::::deposit_event(Event::PoolPromotionUpdated(liquidity_token_id, Some(weight))); } - fn disable(liquidity_token_id: TokenId) { + fn disable(liquidity_token_id: CurrencyIdOf) { PromotedPoolRewards::::mutate(|promoted_pools| { if let Some(info) = promoted_pools.get_mut(&liquidity_token_id) { info.weight = 0; @@ -383,14 +388,14 @@ impl ProofOfStakeRewardsApi for Pallet { Pallet::::deposit_event(Event::PoolPromotionUpdated(liquidity_token_id, None)); } - fn is_enabled(liquidity_token_id: TokenId) -> bool { + fn is_enabled(liquidity_token_id: CurrencyIdOf) -> bool { PromotedPoolRewards::::get().contains_key(&liquidity_token_id) } fn claim_rewards_all( user: T::AccountId, - liquidity_asset_id: Self::CurrencyId, - ) -> Result { + liquidity_asset_id: CurrencyIdOf, + ) -> Result, DispatchError> { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) @@ -402,18 +407,18 @@ impl ProofOfStakeRewardsApi for Pallet { .ok_or(Error::::CalculateRewardsMathError)?; let total_available_rewards = current_rewards - .checked_add(rewards_info.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(rewards_info.rewards_already_claimed)) + .checked_add(&rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(&rewards_info.rewards_already_claimed)) .ok_or(Error::::CalculateRewardsAllMathError)?; - rewards_info.rewards_not_yet_claimed = 0_u128; + rewards_info.rewards_not_yet_claimed = BalanceOf::::zero(); rewards_info.rewards_already_claimed = current_rewards; ::Currency::transfer( Self::native_token_id().into(), &::LiquidityMiningIssuanceVault::get(), &user, - total_available_rewards.into(), + total_available_rewards, ExistenceRequirement::KeepAlive, )?; @@ -430,8 +435,8 @@ impl ProofOfStakeRewardsApi for Pallet { fn activate_liquidity( user: T::AccountId, - liquidity_asset_id: Self::CurrencyId, - amount: Self::Balance, + liquidity_asset_id: CurrencyIdOf, + amount: BalanceOf, use_balance_from: Option, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; @@ -461,10 +466,10 @@ impl ProofOfStakeRewardsApi for Pallet { fn deactivate_liquidity( user: T::AccountId, - liquidity_asset_id: Self::CurrencyId, - amount: Self::Balance, + liquidity_asset_id: CurrencyIdOf, + amount: BalanceOf, ) -> DispatchResult { - if amount > 0 { + if amount > BalanceOf::::zero() { Self::set_liquidity_burning_checkpoint(user.clone(), liquidity_asset_id, amount)?; Pallet::::deposit_event(Event::LiquidityDeactivated( user, @@ -478,31 +483,31 @@ impl ProofOfStakeRewardsApi for Pallet { fn calculate_rewards_amount( user: AccountIdOf, - liquidity_asset_id: TokenId, - ) -> Result { + liquidity_asset_id: CurrencyIdOf, + ) -> Result, DispatchError> { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; let current_rewards = match rewards_info.activated_amount { - 0 => 0u128, - _ => rewards_info + amount if amount > BalanceOf::::zero() => rewards_info .calculate_rewards( Self::get_current_rewards_time()?, Self::get_pool_rewards(liquidity_asset_id)?, ) .ok_or(Error::::CalculateRewardsMathError)?, + _ => BalanceOf::::zero(), }; Ok(current_rewards - .checked_add(rewards_info.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(rewards_info.rewards_already_claimed)) + .checked_add(&rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(&rewards_info.rewards_already_claimed)) .ok_or(Error::::CalculateRewardsMathError)?) } } -impl LiquidityMiningApi for Pallet { +impl LiquidityMiningApi> for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight - fn distribute_rewards(liquidity_mining_rewards: Balance) { + fn distribute_rewards(liquidity_mining_rewards: BalanceOf) { let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { // benchmark with max of X prom pools let activated_pools: Vec<_> = promoted_pools @@ -510,7 +515,7 @@ impl LiquidityMiningApi for Pallet { .into_iter() .filter_map(|(token_id, info)| { let activated_amount = Self::total_activated_amount(token_id); - if activated_amount > 0 && info.weight > 0 { + if activated_amount > BalanceOf::::zero() && info.weight > 0 { Some((token_id, info.weight, info.rewards, activated_amount)) } else { None @@ -530,14 +535,15 @@ impl LiquidityMiningApi for Pallet { Some(total_weight) if !total_weight.is_zero() => Perbill::from_rational(weight.into(), total_weight) .mul_floor(liquidity_mining_rewards), - _ => Balance::zero(), + _ => BalanceOf::::zero(), }; - let rewards_for_liquidity: U256 = U256::from(liquidity_mining_issuance_for_pool) - .checked_mul(U256::from(u128::MAX)) - .and_then(|x| x.checked_div(activated_amount.into())) - .and_then(|x| x.checked_add(rewards)) - .ok_or(Error::::MathError)?; + let rewards_for_liquidity: U256 = + U256::from(liquidity_mining_issuance_for_pool.into()) + .checked_mul(U256::from(u128::MAX)) + .and_then(|x| x.checked_div(activated_amount.into().into())) + .and_then(|x| x.checked_add(rewards)) + .ok_or(Error::::MathError)?; promoted_pools .entry(token_id.clone()) diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index fa95825027..ce83787666 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -2,78 +2,67 @@ use super::*; -use sp_core::H256; - -use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, -}; - use crate as pos; +use core::convert::TryFrom; use frame_support::{ construct_runtime, parameter_types, - traits::{tokens::currency::MultiTokenCurrency, ConstU32, Contains, Everything}, + traits::{ + tokens::currency::MultiTokenCurrency, ConstU32, Contains, Everything, WithdrawReasons, + }, PalletId, }; - use frame_system as system; pub use mangata_support::traits::ProofOfStakeRewardsApi; -use mangata_types::{assets::CustomMetadata, Amount, Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyAdapter, MultiTokenCurrencyExtended}; -use orml_traits::{asset_registry::AssetMetadata, parameter_type_with_key}; -use sp_runtime::{Perbill, Percent}; -use std::{collections::HashMap, sync::Mutex}; +use orml_traits::parameter_type_with_key; +use sp_runtime::{traits::AccountIdConversion, BuildStorage, Perbill, Percent}; pub const NATIVE_CURRENCY_ID: u32 = 0; -pub(crate) type AccountId = u128; +pub(crate) type AccountId = u64; +pub(crate) type Amount = i128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; -use core::convert::TryFrom; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - ProofOfStake: pos::{Pallet, Call, Storage, Event}, - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, - Issuance: pallet_issuance::{Pallet, Event, Storage}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + ProofOfStake: pos, + Vesting: pallet_vesting_mangata, + Issuance: pallet_issuance, } ); parameter_types! { pub const BlockHashCount: u64 = 250; } -impl system::Config for Test { +impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); type DbWeight = (); type Version = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type PalletInfo = PalletInfo; - type BlockWeights = (); - type BlockLength = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } parameter_type_with_key! { @@ -139,6 +128,8 @@ parameter_types! { parameter_types! { pub const MinVestedTransfer: Balance = 0; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting_mangata::Config for Test { @@ -147,6 +138,7 @@ impl pallet_vesting_mangata::Config for Test { type BlockNumberToBalance = sp_runtime::traits::ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting_mangata::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 28; @@ -184,24 +176,6 @@ impl Contains<(TokenId, TokenId)> for DummyBlacklistedPool { } } -pub struct MockAssetRegister; - -lazy_static::lazy_static! { - static ref ASSET_REGISTER: Mutex>> = { - let m = HashMap::new(); - Mutex::new(m) - }; -} - -pub struct MockMaintenanceStatusProvider; - -lazy_static::lazy_static! { - static ref MAINTENANCE_STATUS: Mutex = { - let m: bool = false; - Mutex::new(m) - }; -} - impl pos::Config for Test { type RuntimeEvent = RuntimeEvent; type ActivationReservesProvider = TokensActivationPassthrough; @@ -214,78 +188,72 @@ impl pos::Config for Test { pub struct TokensActivationPassthrough(PhantomData); -impl ActivationReservesProviderTrait for TokensActivationPassthrough +impl ActivationReservesProviderTrait + for TokensActivationPassthrough where - AccountId: From<::AccountId>, + T::Currency: MultiTokenReservableCurrency, { - type AccountId = T::AccountId; - - fn get_max_instant_unreserve_amount( - token_id: TokenId, - account_id: &Self::AccountId, - ) -> Balance { - let account_id: u128 = (account_id.clone()).into(); - let token_id: u32 = token_id; + fn get_max_instant_unreserve_amount(token_id: TokenId, account_id: &AccountId) -> Balance { ProofOfStake::get_rewards_info(account_id, token_id).activated_amount } fn can_activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> bool { - ::Currency::can_reserve(token_id.into(), account_id, amount.into()) + ::Currency::can_reserve(token_id, account_id, amount) } fn activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> DispatchResult { - ::Currency::reserve(token_id.into(), account_id, amount.into()) + ::Currency::reserve(token_id, account_id, amount) } - fn deactivate(token_id: TokenId, account_id: &Self::AccountId, amount: Balance) -> Balance { - ::Currency::unreserve(token_id.into(), account_id, amount.into()) - .into() + fn deactivate(token_id: TokenId, account_id: &AccountId, amount: Balance) -> Balance { + ::Currency::unreserve(token_id, account_id, amount) } } -impl Pallet { - pub fn balance(id: TokenId, who: T::AccountId) -> Balance { - ::Currency::free_balance(id.into(), &who).into() +impl Pallet +where + T::Currency: MultiTokenReservableCurrency + + MultiTokenCurrencyExtended, +{ + pub fn balance(id: TokenId, who: AccountId) -> Balance { + ::Currency::free_balance(id, &who) } - pub fn reserved(id: TokenId, who: T::AccountId) -> Balance { - ::Currency::reserved_balance(id.into(), &who).into() + pub fn reserved(id: TokenId, who: AccountId) -> Balance { + ::Currency::reserved_balance(id, &who) } pub fn total_supply(id: TokenId) -> Balance { - ::Currency::total_issuance(id.into()).into() + ::Currency::total_issuance(id) } pub fn transfer( currency_id: TokenId, - source: T::AccountId, - dest: T::AccountId, + source: AccountId, + dest: AccountId, value: Balance, ) -> DispatchResult { ::Currency::transfer( - currency_id.into(), + currency_id, &source, &dest, - value.into(), + value, ExistenceRequirement::KeepAlive, ) } - pub fn create_new_token(who: &T::AccountId, amount: Balance) -> TokenId { - ::Currency::create(who, amount.into()) - .expect("Token creation failed") - .into() + pub fn create_new_token(who: &AccountId, amount: Balance) -> TokenId { + ::Currency::create(who, amount).expect("Token creation failed") } - pub fn mint_token(token_id: TokenId, who: &T::AccountId, amount: Balance) { - ::Currency::mint(token_id.into(), who, amount.into()) - .expect("Token minting failed") + pub fn mint_token(token_id: TokenId, who: &AccountId, amount: Balance) { + ::Currency::mint(token_id, who, amount).expect("Token minting failed") } } @@ -293,7 +261,7 @@ impl Pallet { // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = - system::GenesisConfig::default().build_storage::().unwrap().into(); + system::GenesisConfig::::default().build_storage().unwrap().into(); ext.execute_with(|| { System::set_block_number(1); }); diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 6909f83a7b..888319e759 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -2,9 +2,11 @@ use frame_support::dispatch::DispatchResult; use crate::{Config, Error}; use frame_support::pallet_prelude::*; -use mangata_types::Balance; use sp_core::U256; -use sp_std::{convert::TryInto, prelude::*}; +use sp_std::{ + convert::{TryFrom, TryInto}, + prelude::*, +}; // Quocient ratio in which liquidity minting curve is rising const Q: f64 = 1.03; @@ -18,13 +20,13 @@ fn calculate_q_pow(q: f64, pow: u32) -> u128 { /// Stores all the information required for non iterative rewards calculation between /// last_checkpoint and particular subsequent block ('now' in most cases) #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -pub struct RewardInfo { +pub struct RewardInfo { // amount of activated token - pub activated_amount: u128, + pub activated_amount: Balance, // when doing checkpoint we need to store rewards up to this point - pub rewards_not_yet_claimed: u128, + pub rewards_not_yet_claimed: Balance, // there is no checkpoint during for claim_rewards - pub rewards_already_claimed: u128, + pub rewards_already_claimed: Balance, // block number of last checkpoint pub last_checkpoint: u32, // ration betwen rewards : liquidity (as in table) @@ -33,7 +35,10 @@ pub struct RewardInfo { pub missing_at_last_checkpoint: U256, } -impl RewardInfo { +impl RewardInfo +where + Balance: frame_support::traits::tokens::Balance + Into + TryFrom, +{ pub fn calculate_missing_at_checkpoint(&self, current_time: u32) -> Option { let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); let q_pow = calculate_q_pow(Q, time_passed); @@ -48,12 +53,12 @@ impl RewardInfo { ) -> DispatchResult { let activated_amount = self .activated_amount - .checked_add(liquidity_assets_added) + .checked_add(&liquidity_assets_added) .ok_or(Error::::LiquidityCheckpointMathError)?; let missing_at_last_checkpoint = self .calculate_missing_at_checkpoint(current_time) - .and_then(|v| v.checked_add(U256::from(liquidity_assets_added))) + .and_then(|v| v.checked_add(U256::from(liquidity_assets_added.into()))) .ok_or(Error::::LiquidityCheckpointMathError)?; let user_current_rewards = self @@ -61,13 +66,13 @@ impl RewardInfo { .ok_or(Error::::CalculateRewardsMathError)?; let rewards_not_yet_claimed = user_current_rewards - .checked_add(self.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(self.rewards_already_claimed)) + .checked_add(&self.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(&self.rewards_already_claimed)) .ok_or(Error::::LiquidityCheckpointMathError)?; self.activated_amount = activated_amount; self.pool_ratio_at_last_checkpoint = pool_ratio_current; - self.rewards_already_claimed = 0_u128; + self.rewards_already_claimed = Balance::zero(); self.missing_at_last_checkpoint = missing_at_last_checkpoint; self.rewards_not_yet_claimed = rewards_not_yet_claimed; self.last_checkpoint = current_time; @@ -82,7 +87,7 @@ impl RewardInfo { ) -> DispatchResult { let activated_amount = self .activated_amount - .checked_sub(liquidity_assets_removed) + .checked_sub(&liquidity_assets_removed) .ok_or(Error::::LiquidityCheckpointMathError)?; let missing_at_checkpoint_new = self @@ -91,24 +96,24 @@ impl RewardInfo { let activated_amount_new = self .activated_amount - .checked_sub(liquidity_assets_removed) + .checked_sub(&liquidity_assets_removed) .ok_or(Error::::LiquidityCheckpointMathError)?; - let missing_at_checkpoint_after_burn = U256::from(activated_amount_new) + let missing_at_checkpoint_after_burn = U256::from(activated_amount_new.into()) .checked_mul(missing_at_checkpoint_new) - .and_then(|v| v.checked_div(self.activated_amount.into())) + .and_then(|v| v.checked_div(self.activated_amount.into().into())) .ok_or(Error::::LiquidityCheckpointMathError)?; let user_current_rewards = self .calculate_rewards(current_time, pool_ratio_current) .ok_or(Error::::CalculateRewardsMathError)?; let total_available_rewards = user_current_rewards - .checked_add(self.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(self.rewards_already_claimed)) + .checked_add(&self.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(&self.rewards_already_claimed)) .ok_or(Error::::LiquidityCheckpointMathError)?; self.activated_amount = activated_amount; self.pool_ratio_at_last_checkpoint = pool_ratio_current; - self.rewards_already_claimed = 0_u128; + self.rewards_already_claimed = 0_u32.into(); self.missing_at_last_checkpoint = missing_at_checkpoint_after_burn; self.rewards_not_yet_claimed = total_available_rewards; self.last_checkpoint = current_time; @@ -123,18 +128,20 @@ impl RewardInfo { let pool_rewards_ratio_new = pool_rewards_ratio_current.checked_sub(self.pool_ratio_at_last_checkpoint)?; - let user_rewards_base: U256 = U256::from(self.activated_amount) + let user_rewards_base: U256 = U256::from(self.activated_amount.into()) .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 let (cumulative_work, cummulative_work_max_possible) = self.calculate_cumulative_work_max_ratio(current_time)?; - user_rewards_base + let reward: u128 = user_rewards_base .checked_mul(cumulative_work)? .checked_div(cummulative_work_max_possible)? .try_into() - .ok() + .ok()?; + + reward.try_into().ok() } fn calculate_cumulative_work_max_ratio(&self, current_time: u32) -> Option<(U256, U256)> { @@ -143,8 +150,8 @@ impl RewardInfo { let mut cummulative_work = U256::from(0); let mut cummulative_work_max_possible_for_ratio = U256::from(1); - if time_passed != 0 && self.activated_amount != 0 { - let liquidity_assets_amount_u256: U256 = self.activated_amount.into(); + if time_passed != 0 && self.activated_amount != Balance::zero() { + let liquidity_assets_amount_u256: U256 = self.activated_amount.into().into(); // whole formula: missing_at_last_checkpoint*106/6 - missing_at_last_checkpoint*106*precision/6/q_pow // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index ea311c85d2..d95fc8d817 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -17,7 +17,7 @@ fn mint_and_activate_tokens(who: AccountId, token_id: TokenId, amount: Balance) fn initialize_liquidity_rewards() { System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = std::u128::MAX; PromotedPoolRewards::::get(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -53,7 +53,7 @@ fn liquidity_rewards_single_user_mint_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -118,7 +118,7 @@ fn liquidity_rewards_three_users_burn_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -161,7 +161,7 @@ fn liquidity_rewards_claim_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -199,7 +199,7 @@ fn liquidity_rewards_promote_pool_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -216,7 +216,7 @@ fn liquidity_rewards_promote_pool_already_promoted_NW() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -235,7 +235,7 @@ fn liquidity_rewards_work_after_burn_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -279,7 +279,7 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -314,7 +314,7 @@ fn liquidity_rewards_deactivate_more_NW() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -344,7 +344,7 @@ fn liquidity_rewards_activate_more_NW() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -373,7 +373,7 @@ fn liquidity_rewards_calculate_rewards_pool_not_promoted() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -391,7 +391,7 @@ fn liquidity_rewards_claim_pool_not_promoted() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -423,7 +423,7 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -473,7 +473,7 @@ fn extreme_case_pool_ratio() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -503,7 +503,7 @@ fn rewards_rounding_during_often_mint() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -593,7 +593,7 @@ fn rewards_storage_right_amounts_start1() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -729,7 +729,7 @@ fn rewards_storage_right_amounts_start2() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -853,7 +853,7 @@ fn rewards_storage_right_amounts_start3() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -925,7 +925,7 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); @@ -975,7 +975,7 @@ pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option() / BlocksPerRound::get(); - session_issuance = ::get_all_issuance(session_number) + session_issuance = >::get_all_issuance(session_number) .expect("session issuance is always populated in advance"); block_issuance = (session_issuance.0 + session_issuance.1) / (BlocksPerRound::get().saturated_into::()); @@ -995,7 +995,7 @@ pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option::create(&99999, 2000_000_000).unwrap(); @@ -1056,7 +1056,7 @@ fn claim_rewards_from_pool_that_has_been_disabled() { new_test_ext().execute_with(|| { let max = std::u128::MAX; System::set_block_number(1); - let acc_id: u128 = 2; + let acc_id: AccountId = 2; let amount: u128 = max; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); diff --git a/pallets/sudo-origin/Cargo.toml b/pallets/sudo-origin/Cargo.toml index 355ee82c70..5aa6b21d14 100644 --- a/pallets/sudo-origin/Cargo.toml +++ b/pallets/sudo-origin/Cargo.toml @@ -13,35 +13,36 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +log = { version = "0.4.14", default-features = false } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } -sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } + +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } [dev-dependencies] -sp-core = { version = "7.0.0", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } [features] default = ["std"] std = [ "codec/std", + "frame-support/std", + "frame-system/std", "scale-info/std", "sp-std/std", "sp-io/std", "sp-runtime/std", - "frame-support/std", - "frame-system/std", ] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", - "sp-runtime/try-runtime" + "frame-try-runtime", + "sp-runtime/try-runtime", ] diff --git a/pallets/sudo-origin/src/mock.rs b/pallets/sudo-origin/src/mock.rs index 556f1d8b42..d6eedf7467 100644 --- a/pallets/sudo-origin/src/mock.rs +++ b/pallets/sudo-origin/src/mock.rs @@ -19,14 +19,14 @@ use super::*; use crate as sudo_origin; -use frame_support::{parameter_types, traits::Contains, weights::Weight}; +use frame_support::{ + parameter_types, + traits::{Contains, Everything}, + weights::Weight, +}; use frame_system::{limits, EnsureRoot}; -use sp_core::H256; use sp_io; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::BuildStorage; use sp_std::convert::TryFrom; // Logger module to track execution. @@ -93,18 +93,13 @@ pub mod logger { pub(super) type I32Log = StorageValue<_, Vec, ValueQuery>; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - SudoOrigin: sudo_origin::{Pallet, Call, Event}, - Logger: logger::{Pallet, Call, Storage, Event}, + pub enum Test { + System: frame_system, + SudoOrigin: sudo_origin, + Logger: logger, } ); @@ -121,21 +116,20 @@ impl Contains for BlockEverything { } impl frame_system::Config for Test { - type BaseCallFilter = BlockEverything; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); + type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -165,6 +159,6 @@ pub type LoggerCall = logger::Call; // Build test environment by setting the root `key` for the Genesis. pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); t.into() } diff --git a/pallets/sudo-origin/src/tests.rs b/pallets/sudo-origin/src/tests.rs index 0a32a7b6c0..8e91acfb7c 100644 --- a/pallets/sudo-origin/src/tests.rs +++ b/pallets/sudo-origin/src/tests.rs @@ -18,12 +18,13 @@ //! Tests for the module. use super::*; -use frame_support::{assert_noop, assert_ok, dispatch::DispatchError, weights::Weight}; +use frame_support::{assert_noop, assert_ok, weights::Weight}; use frame_system::RawOrigin; use mock::{ new_test_ext, Logger, LoggerCall, RuntimeCall, RuntimeEvent as TestEvent, RuntimeOrigin, SudoOrigin, SudoOriginCall, System, }; +use sp_runtime::DispatchError; #[test] fn test_setup_works() { diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 687239d14a..55f341dc68 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,77 +1,82 @@ [package] -authors = ['Mangata team'] -edition = '2018' -name = 'pallet-xyk' -version = '0.1.0' +authors = ["Mangata team"] +edition = "2018" +name = "pallet-xyk" +version = "0.1.0" [package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] +targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex = { package = "rustc-hex", version = "2.1.0", default-features = false } hex-literal = { version = "0.3.3", default-features = false } +log = { version = "0.4.14", default-features = false } serde = { version = "1.0.126", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-benchmarking = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true , branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = "5.0.0", default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-issuance = { default-features = false, path = "../issuance" } -pallet-bootstrap = { default-features = false, path = "../bootstrap" } -pallet-proof-of-stake = { default-features = false, path = "../proof-of-stake" } -sp-arithmetic = { default-features = false, version = '6.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -libm = { default-features = false, git = "https://github.com/rust-lang/libm", rev="2f3fc968f43d345f9b449938d050a9ea46a04c83"} -orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +libm = { git = "https://github.com/rust-lang/libm", rev = "2f3fc968f43d345f9b449938d050a9ea46a04c83", default-features = false } + +pallet-issuance = { path = "../issuance", default-features = false } +pallet-bootstrap = { path = "../bootstrap", default-features = false } +pallet-proof-of-stake = { path = "../proof-of-stake", default-features = false } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } [dev-dependencies] -similar-asserts = "1.1.0" -pallet-proof-of-stake = {path = "../proof-of-stake"} -orml-traits = { default-features = false, version="0.4.1-dev" , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -sp-io = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -lazy_static = "1.1.1" env_logger = "0.9.0" +lazy_static = "1.1.1" serial_test = { version = "0.6.0", default-features = false } +similar-asserts = "1.1.0" test-case = "2.0.2" +pallet-proof-of-stake = { path = "../proof-of-stake" } + +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } + +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } + [features] -default = ['std'] +default = ["std"] std = [ - 'hex/std', - 'serde', - 'codec/std', - 'sp-std/std', - 'sp-core/std', - 'frame-support/std', - 'frame-system/std', - "frame-benchmarking/std", - 'orml-tokens/std', + "codec/std", "frame-benchmarking/std", - 'pallet-vesting-mangata/std', - "mangata-support/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "mangata-support/std", + "orml-tokens/std", + "pallet-vesting-mangata/std", "scale-info/std", + "serde", + "sp-std/std", + "sp-core/std", ] runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", + "frame-try-runtime", "orml-tokens/try-runtime", "pallet-bootstrap/try-runtime", "pallet-issuance/try-runtime", "pallet-vesting-mangata/try-runtime", - "sp-runtime/try-runtime" + "sp-runtime/try-runtime", ] diff --git a/pallets/xyk/rpc/Cargo.toml b/pallets/xyk/rpc/Cargo.toml index 814f19149d..c6ee5e78a9 100644 --- a/pallets/xyk/rpc/Cargo.toml +++ b/pallets/xyk/rpc/Cargo.toml @@ -1,5 +1,5 @@ [package] -authors = ['Mangata team'] +authors = ["Mangata team"] name = "xyk-rpc" version = "2.0.0" edition = "2018" @@ -13,12 +13,12 @@ serde = { version = "1.0.126", features = ["derive"], optional = true } # Substrate packages -sp-api = { version = '4.0.0-dev', default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-blockchain = { version = '4.0.0-dev', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-rpc = { version = '6.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { version = '5.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-blockchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-rpc = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # local packages @@ -27,10 +27,10 @@ xyk-runtime-api = { version = "2.0.0", path = "../runtime-api", default-features [features] default = ["std"] std = [ - "serde", - "sp-api/std", - "sp-core/std", - "sp-std/std", - "sp-runtime/std", - "xyk-runtime-api/std" + "serde", + "sp-api/std", + "sp-core/std", + "sp-std/std", + "sp-runtime/std", + "xyk-runtime-api/std", ] diff --git a/pallets/xyk/rpc/src/lib.rs b/pallets/xyk/rpc/src/lib.rs index 5f96d56cb6..25897c1dc1 100644 --- a/pallets/xyk/rpc/src/lib.rs +++ b/pallets/xyk/rpc/src/lib.rs @@ -10,10 +10,7 @@ use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::U256; use sp_rpc::number::NumberOrHex; -use sp_runtime::{ - generic::BlockId, - traits::{Block as BlockT, MaybeDisplay, MaybeFromStr}, -}; +use sp_runtime::traits::{Block as BlockT, MaybeDisplay, MaybeFromStr}; use sp_std::convert::{TryFrom, TryInto}; use std::sync::Arc; use xyk_runtime_api::RpcAssetMetadata; @@ -169,7 +166,7 @@ where input_reserve: NumberOrHex, output_reserve: NumberOrHex, sell_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -195,7 +192,7 @@ where input_reserve: NumberOrHex, output_reserve: NumberOrHex, buy_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -221,7 +218,7 @@ where sold_token_id: TokenId, bought_token_id: TokenId, sell_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -247,7 +244,7 @@ where sold_token_id: TokenId, bought_token_id: TokenId, buy_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -273,7 +270,7 @@ where first_asset_id: TokenId, second_asset_id: TokenId, liquidity_asset_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult<(NumberOrHex, NumberOrHex)> { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -298,7 +295,7 @@ where &self, user: AccountId, liquidity_asset_id: TokenId, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -318,7 +315,7 @@ where &self, user: AccountId, liquidity_asset_id: TokenId, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -338,7 +335,7 @@ where &self, user: AccountId, liquidity_asset_id: TokenId, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -358,7 +355,7 @@ where &self, total_amount: NumberOrHex, reserve_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -380,7 +377,7 @@ where fn get_liq_tokens_for_trading( &self, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult> { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -398,7 +395,7 @@ where &self, path: sp_std::vec::Vec, input_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult> { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -417,7 +414,7 @@ where &self, path: sp_std::vec::Vec, input_amount: NumberOrHex, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult> { let api = self.client.runtime_api(); let at = self.client.info().best_hash; @@ -434,7 +431,7 @@ where fn get_tradeable_tokens( &self, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult>> { let api = self.client.runtime_api(); let at = self.client.info().best_hash; diff --git a/pallets/xyk/runtime-api/Cargo.toml b/pallets/xyk/runtime-api/Cargo.toml index 3d4b594cf7..931b580f43 100644 --- a/pallets/xyk/runtime-api/Cargo.toml +++ b/pallets/xyk/runtime-api/Cargo.toml @@ -1,19 +1,21 @@ [package] -authors = ['Mangata team'] +authors = ["Mangata team"] name = "xyk-runtime-api" version = "2.0.0" edition = "2018" license = "GPL-3.0-or-later" [dependencies] -serde = { version = "1.0.126", optional = true, features = ["derive"] } -sp-api = { version = '4.0.0-dev', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-std = { default-features = false, version = '5.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.126", optional = true, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } + +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } [dev-dependencies] serde_json = "1.0.68" @@ -21,10 +23,10 @@ serde_json = "1.0.68" [features] default = ["std"] std = [ - "serde", - "sp-api/std", - "codec/std", - "sp-runtime/std", - "frame-support/std", - 'frame-system/std' + "codec/std", + "frame-support/std", + "frame-system/std", + "serde", + "sp-api/std", + "sp-runtime/std", ] diff --git a/pallets/xyk/runtime-api/src/lib.rs b/pallets/xyk/runtime-api/src/lib.rs index 2f42b4e2c5..b00b908c10 100644 --- a/pallets/xyk/runtime-api/src/lib.rs +++ b/pallets/xyk/runtime-api/src/lib.rs @@ -3,12 +3,13 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::unnecessary_mut_passed)] use codec::{Codec, Decode, Encode}; +use frame_support::pallet_prelude::TypeInfo; #[cfg(feature = "std")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use sp_runtime::traits::{MaybeDisplay, MaybeFromStr}; use sp_std::vec::Vec; -#[derive(Eq, PartialEq, Encode, Decode, Default)] +#[derive(Eq, PartialEq, Encode, Decode, Default, TypeInfo)] #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] pub struct RpcAssetMetadata { diff --git a/pallets/xyk/src/benchmarking.rs b/pallets/xyk/src/benchmarking.rs index 3a4c67ca63..9e3178fad2 100644 --- a/pallets/xyk/src/benchmarking.rs +++ b/pallets/xyk/src/benchmarking.rs @@ -31,6 +31,16 @@ use crate::Pallet as Xyk; const MILION: u128 = 1_000__000_000__000_000; +trait ToBalance { + fn to_balance(self) -> BalanceOf; +} + +impl ToBalance for u128 { + fn to_balance(self) -> BalanceOf { + self.try_into().ok().expect("u128 should fit into Balance type") + } +} + #[macro_export] macro_rules! init { () => { @@ -68,22 +78,22 @@ benchmarks! { create_pool { init!(); let caller: T::AccountId = whitelisted_caller(); - let first_asset_amount = MILION; - let second_asset_amount = MILION; - let first_asset_id = ::Currency::create(&caller, first_asset_amount.into()).unwrap(); - let second_asset_id = ::Currency::create(&caller, second_asset_amount.into()).unwrap(); - let liquidity_asset_id = second_asset_id.into() + 1; + let first_asset_amount = MILION.to_balance::(); + let second_asset_amount = MILION.to_balance::(); + let first_asset_id = ::Currency::create(&caller, first_asset_amount).unwrap(); + let second_asset_id = ::Currency::create(&caller, second_asset_amount).unwrap(); + let liquidity_asset_id = second_asset_id + 1_u32.into(); - }: create_pool(RawOrigin::Signed(caller.clone().into()), first_asset_id.into(), first_asset_amount.into(), second_asset_id.into(), second_asset_amount.into()) + }: create_pool(RawOrigin::Signed(caller.clone().into()), first_asset_id, first_asset_amount, second_asset_id, second_asset_amount) verify { assert_eq!( - Xyk::::asset_pool((first_asset_id.into(), second_asset_id.into())), + Xyk::::asset_pool((first_asset_id, second_asset_id)), (first_asset_amount, second_asset_amount) ); assert!( - Xyk::::liquidity_asset((first_asset_id.into(), second_asset_id.into())).is_some() + Xyk::::liquidity_asset((first_asset_id, second_asset_id)).is_some() ); } @@ -93,21 +103,22 @@ benchmarks! { init!(); let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000; - let expected_amount = 0; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id.into(), 100000000000000, non_native_asset_id1.into(), 100000000000000).unwrap(); - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1.into(), 100000000000000, non_native_asset_id2.into(), 100000000000000).unwrap(); - - }: sell_asset(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1.into(), non_native_asset_id2.into(), 50000000000000, 0) + let initial_amount: BalanceOf = 1000000000000000.to_balance::(); + let expected_amount = BalanceOf::::zero(); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + + let pool_amount: BalanceOf = 100_000_000_000_000.to_balance::(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id, pool_amount, non_native_asset_id1, pool_amount).unwrap(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1, pool_amount, non_native_asset_id2, pool_amount).unwrap(); + + }: sell_asset(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1, non_native_asset_id2, pool_amount / 2_u32.into(), 0_u32.into()) verify { // verify only trading result as rest of the assertion is in unit test - assert_eq!(::Currency::free_balance(non_native_asset_id1.into(), &caller).into(), 750000000000000); - assert_eq!(::Currency::free_balance(non_native_asset_id2.into(), &caller).into(), 933266599933266); + assert_eq!(::Currency::free_balance(non_native_asset_id1, &caller).into(), 750000000000000_u128); + assert_eq!(::Currency::free_balance(non_native_asset_id2, &caller).into(), 933266599933266_u128); } @@ -116,52 +127,53 @@ benchmarks! { // NOTE: All atomic swaps in the chain involve sold tokens that are pooled with the native token for bnb, which is the worst case // liquidity tokens - let x in 3..100; + let x in 3_u32..100; init!(); let caller: T::AccountId = whitelisted_caller(); - let mint_amount: mangata_types::Balance = 1000000000000000000; - let pool_creation_amount: mangata_types::Balance = 10000000000000000; - let trade_amount: mangata_types::Balance = 1000000000000; + let mint_amount: BalanceOf = 1000000000000000000.to_balance::(); + let pool_creation_amount: BalanceOf = 10000000000000000.to_balance::(); + let trade_amount: BalanceOf = 1000000000000.to_balance::(); - let mut initial_asset_id: mangata_types::TokenId = ::Currency::get_next_currency_id().into(); - let native_asset_id : mangata_types::TokenId = ::NativeCurrencyId::get().into(); + let mut initial_asset_id = ::Currency::get_next_currency_id(); + let native_asset_id = ::NativeCurrencyId::get(); if initial_asset_id == native_asset_id { - assert_eq!(::Currency::create(&caller, (mint_amount * x as u128).into()).unwrap().into(), native_asset_id); - initial_asset_id = initial_asset_id + 1; + assert_eq!(::Currency::create(&caller, mint_amount * x.into()).unwrap(), native_asset_id); + initial_asset_id = initial_asset_id + 1_u32.into(); } else { - assert_ok!(::Currency::mint(native_asset_id.into(), &caller, (mint_amount * x as u128).into())); + assert_ok!(::Currency::mint(native_asset_id, &caller, mint_amount * x.into())); } // Create all the non-native tokens we will need - for i in 0..x{ - assert_eq!(::Currency::create(&caller, (mint_amount).into()).unwrap().into(), initial_asset_id + i); + for i in 0_u32..x{ + assert_eq!(::Currency::create(&caller, mint_amount).unwrap(), initial_asset_id + i.into()); } // Create all pool with the subsequent non-native tokens - for i in 0.. (x - 1){ - assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), {initial_asset_id + i}.into(), pool_creation_amount, {initial_asset_id + i+1}.into(), pool_creation_amount)); + for i in 0_u32.. (x - 1){ + assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), initial_asset_id + i.into(), pool_creation_amount, initial_asset_id + (i+1).into(), pool_creation_amount)); } // Create all pool with the subsequent non-native tokens - for i in 0..x{ - assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id.into(), pool_creation_amount, {initial_asset_id + i}.into(), pool_creation_amount)); + for i in 0_u32..x{ + assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id, pool_creation_amount, initial_asset_id + i.into(), pool_creation_amount)); } - let mut swap_token_list: Vec = vec![]; + let mut swap_token_list: Vec> = vec![]; - for i in 0..x{ - swap_token_list.push({initial_asset_id + i}.into()); + for i in 0_u32..x{ + swap_token_list.push(initial_asset_id + i.into()); } - assert_eq!(::Currency::free_balance({initial_asset_id + x - 1}.into(), &caller).into(), mint_amount - 2 * pool_creation_amount); + let expected: BalanceOf = mint_amount - pool_creation_amount - pool_creation_amount; + assert_eq!(::Currency::free_balance(initial_asset_id + (x - 1).into(), &caller), expected); - }: multiswap_sell_asset(RawOrigin::Signed(caller.clone().into()), swap_token_list.into(), trade_amount, 0) + }: multiswap_sell_asset(RawOrigin::Signed(caller.clone().into()), swap_token_list.into(), trade_amount, 0_u32.into()) verify { // verify only trading result as rest of the assertion is in unit test - assert!(::Currency::free_balance({initial_asset_id + x - 1}.into(), &caller).into() > mint_amount - 2 * pool_creation_amount); + assert!(::Currency::free_balance(initial_asset_id + (x - 1).into(), &caller) > expected); } @@ -170,21 +182,22 @@ benchmarks! { init!(); let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000; - let expected_amount = 0; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id.into(), 100000000000000, non_native_asset_id1.into(), 100000000000000).unwrap(); - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1.into(), 100000000000000, non_native_asset_id2.into(), 100000000000000).unwrap(); - - }: buy_asset(RawOrigin::Signed(caller.clone().into()), non_native_asset_id2.into(), non_native_asset_id1.into(), 33266599933266, 50000000000001) + let initial_amount: BalanceOf = 1000000000000000.to_balance::(); + let expected_amount = BalanceOf::::zero(); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + + let amount = 100000000000000.to_balance::(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id, amount, non_native_asset_id1, amount).unwrap(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1, amount, non_native_asset_id2, amount).unwrap(); + + }: buy_asset(RawOrigin::Signed(caller.clone().into()), non_native_asset_id2.into(), non_native_asset_id1.into(), 33266599933266.to_balance::(), 50000000000001.to_balance::()) verify { // verify only trading result as rest of the assertion is in unit test - assert_eq!(::Currency::free_balance(non_native_asset_id1.into(), &caller).into(), 833266599933266); - assert_eq!(::Currency::free_balance(non_native_asset_id2.into(), &caller).into(), 850000000000001); + assert_eq!(::Currency::free_balance(non_native_asset_id1, &caller).into(), 833266599933266); + assert_eq!(::Currency::free_balance(non_native_asset_id2, &caller).into(), 850000000000001); } multiswap_buy_asset { @@ -192,52 +205,53 @@ benchmarks! { // NOTE: All atomic swaps in the chain involve sold tokens that are pooled with the native token for bnb, which is the worst case // liquidity tokens - let x in 3..100; + let x in 3_u32..100; init!(); let caller: T::AccountId = whitelisted_caller(); - let mint_amount: mangata_types::Balance = 1000000000000000000; - let pool_creation_amount: mangata_types::Balance = 10000000000000000; - let trade_amount: mangata_types::Balance = 1000000000000; + let mint_amount: BalanceOf = 1000000000000000000.to_balance::(); + let pool_creation_amount: BalanceOf = 10000000000000000.to_balance::(); + let trade_amount: BalanceOf = 1000000000000.to_balance::(); - let mut initial_asset_id: mangata_types::TokenId = ::Currency::get_next_currency_id().into(); - let native_asset_id : mangata_types::TokenId = ::NativeCurrencyId::get().into(); + let mut initial_asset_id = ::Currency::get_next_currency_id(); + let native_asset_id = ::NativeCurrencyId::get(); if initial_asset_id == native_asset_id { - assert_eq!(::Currency::create(&caller, (mint_amount * x as u128).into()).unwrap().into(), native_asset_id); - initial_asset_id = initial_asset_id + 1; + assert_eq!(::Currency::create(&caller, mint_amount * x.into()).unwrap(), native_asset_id); + initial_asset_id = initial_asset_id + 1_u32.into(); } else { - assert_ok!(::Currency::mint(native_asset_id.into(), &caller, (mint_amount * x as u128).into())); + assert_ok!(::Currency::mint(native_asset_id, &caller, mint_amount * x.into())); } // Create all the non-native tokens we will need for i in 0..x{ - assert_eq!(::Currency::create(&caller, (mint_amount).into()).unwrap().into(), initial_asset_id + i); + assert_eq!(::Currency::create(&caller, mint_amount).unwrap(), initial_asset_id + i.into()); } // Create all pool with the subsequent non-native tokens for i in 0.. (x - 1){ - assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), {initial_asset_id + i}.into(), pool_creation_amount, {initial_asset_id + i+1}.into(), pool_creation_amount)); + assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), initial_asset_id + i.into(), pool_creation_amount, initial_asset_id + (i+1).into(), pool_creation_amount)); } // Create all pool with the subsequent non-native tokens for i in 0..x{ - assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id.into(), pool_creation_amount, {initial_asset_id + i}.into(), pool_creation_amount)); + assert_ok!(Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), native_asset_id, pool_creation_amount, initial_asset_id + i.into(), pool_creation_amount)); } - let mut swap_token_list: Vec = vec![]; + let mut swap_token_list: Vec> = vec![]; for i in 0..x{ - swap_token_list.push({initial_asset_id + i}.into()); + swap_token_list.push(initial_asset_id + i.into()); } - assert_eq!(::Currency::free_balance({initial_asset_id + x - 1}.into(), &caller).into(), mint_amount - 2 * pool_creation_amount); + let expected: BalanceOf = mint_amount - pool_creation_amount - pool_creation_amount; + assert_eq!(::Currency::free_balance(initial_asset_id + (x - 1).into(), &caller), expected); - }: multiswap_buy_asset(RawOrigin::Signed(caller.clone().into()), swap_token_list.into(), trade_amount, trade_amount*10) + }: multiswap_buy_asset(RawOrigin::Signed(caller.clone().into()), swap_token_list, trade_amount, trade_amount*10_u32.into()) verify { // verify only trading result as rest of the assertion is in unit test - assert!(::Currency::free_balance({initial_asset_id + x - 1}.into(), &caller).into() > mint_amount - 2 * pool_creation_amount); + assert!(::Currency::free_balance(initial_asset_id + (x - 1).into(), &caller) > expected); } mint_liquidity { @@ -249,25 +263,26 @@ benchmarks! { init!(); let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let liquidity_asset_id = non_native_asset_id2 + 1; - let pool_create_first_token_amount = 40000000000000000000_u128; - let pool_create_second_token_amount = 60000000000000000000_u128; - let pool_mint_first_token_amount = 20000000000000000000_u128; - let pool_mint_second_token_amount = 30000000000000000001_u128; - - - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), - non_native_asset_id1.into(), + let initial_amount:BalanceOf = 1000000000000000000000.to_balance::(); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + let liquidity_asset_id = non_native_asset_id2 + 1_u32.into(); + let pool_create_first_token_amount = 40000000000000000000_u128.to_balance::(); + let pool_create_second_token_amount = 60000000000000000000_u128.to_balance::(); + let pool_mint_first_token_amount = 20000000000000000000_u128.to_balance::(); + let pool_mint_second_token_amount = 30000000000000000001_u128.to_balance::(); + + + Xyk::::create_pool( + RawOrigin::Signed(caller.clone().into()).into(), + non_native_asset_id1, pool_create_first_token_amount, - non_native_asset_id2.into(), + non_native_asset_id2, pool_create_second_token_amount ).unwrap(); - let initial_liquidity_amount = ::Currency::total_issuance(liquidity_asset_id.into()); + let initial_liquidity_amount = ::Currency::total_issuance(liquidity_asset_id); // as ProofOfStakeRewardsApi>::update_pool_promotion( liquidity_asset_id, Some(1u8)).unwrap(); @@ -275,21 +290,21 @@ benchmarks! { Xyk::::mint_liquidity( RawOrigin::Signed(caller.clone().into()).into(), - non_native_asset_id1.into(), - non_native_asset_id2.into(), + non_native_asset_id1, + non_native_asset_id2, pool_mint_first_token_amount, pool_mint_second_token_amount, ).unwrap(); - let liquidity_amount_after_first_mint = ::Currency::total_issuance(liquidity_asset_id.into()); + let liquidity_amount_after_first_mint = ::Currency::total_issuance(liquidity_asset_id); assert!( liquidity_amount_after_first_mint > initial_liquidity_amount); forward_to_next_session!(); - }: mint_liquidity(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1.into(), non_native_asset_id2.into(), 20000000000000000000, 30000000000000000001) + }: mint_liquidity(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1, non_native_asset_id2, 20000000000000000000.to_balance::(), 30000000000000000001.to_balance::()) verify { - let liquidity_amount_after_second_mint = ::Currency::total_issuance(liquidity_asset_id.into()); + let liquidity_amount_after_second_mint = ::Currency::total_issuance(liquidity_asset_id); assert!( liquidity_amount_after_second_mint > liquidity_amount_after_first_mint @@ -301,31 +316,31 @@ benchmarks! { init!(); let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId = ::NativeCurrencyId::get(); - while ::Currency::create(&caller, initial_amount.into()).unwrap().into() < native_asset_id { + let initial_amount:BalanceOf = 1000000000000000000000.to_balance::(); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::NativeCurrencyId::get(); + while ::Currency::create(&caller, initial_amount).unwrap() < native_asset_id { } - ::Currency::mint(native_asset_id.into(), &caller, MILION.into()).expect("Token creation failed"); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let liquidity_asset_id = non_native_asset_id2 + 1; - let pool_creation_asset_1_amount = 40000000000000000000_u128; - let pool_creation_asset_2_amount = 60000000000000000000_u128; - let initial_liquidity_amount = pool_creation_asset_1_amount / 2_u128 + pool_creation_asset_2_amount / 2_u128; - let lock = 1_000_000_u128; + ::Currency::mint(native_asset_id, &caller, MILION.to_balance::()).expect("Token creation failed"); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + let liquidity_asset_id = non_native_asset_id2 + 1_u32.into(); + let pool_creation_asset_1_amount = 40000000000000000000_u128.to_balance::(); + let pool_creation_asset_2_amount = 60000000000000000000_u128.to_balance::(); + let initial_liquidity_amount = pool_creation_asset_1_amount / 2_u32.into() + pool_creation_asset_2_amount / 2_u32.into(); + let lock = 1_000_000_u32; ::Currency::mint( - ::NativeCurrencyId::get().into(), + ::NativeCurrencyId::get(), &caller, - initial_amount.into() + initial_amount ).expect("Token creation failed"); Xyk::::create_pool( RawOrigin::Signed(caller.clone().into()).into(), - native_asset_id.into(), + native_asset_id, pool_creation_asset_1_amount, - non_native_asset_id2.into(), + non_native_asset_id2, pool_creation_asset_2_amount ).unwrap(); // as ProofOfStakeRewardsApi>::update_pool_promotion( liquidity_asset_id, Some(1u8)).unwrap(); @@ -333,26 +348,28 @@ benchmarks! { assert_eq!( - ::Currency::total_issuance(liquidity_asset_id.into()), - initial_liquidity_amount.into() + ::Currency::total_issuance(liquidity_asset_id), + initial_liquidity_amount ); forward_to_next_session!(); - ::VestingProvider::lock_tokens(&caller, native_asset_id.into(), (initial_amount - pool_creation_asset_1_amount).into(), None, lock.into()).unwrap(); + ::VestingProvider::lock_tokens(&caller, native_asset_id, initial_amount - pool_creation_asset_1_amount, None, lock.into()).unwrap(); forward_to_next_session!(); - Xyk::::mint_liquidity_using_vesting_native_tokens(RawOrigin::Signed(caller.clone().into()).into(), 10000000000000000000, non_native_asset_id2.into(), 20000000000000000000).unwrap(); + Xyk::::mint_liquidity_using_vesting_native_tokens( + RawOrigin::Signed(caller.clone().into()).into(), 10000000000000000000.to_balance::(), non_native_asset_id2, 20000000000000000000.to_balance::() + ).unwrap(); forward_to_next_session!(); - let pre_minting_liq_token_amount = ::Currency::total_issuance(liquidity_asset_id.into()); + let pre_minting_liq_token_amount = ::Currency::total_issuance(liquidity_asset_id); - }: mint_liquidity_using_vesting_native_tokens(RawOrigin::Signed(caller.clone().into()), 10000000000000000000, non_native_asset_id2.into(), 20000000000000000000) + }: mint_liquidity_using_vesting_native_tokens(RawOrigin::Signed(caller.clone().into()), 10000000000000000000.to_balance::(), non_native_asset_id2, 20000000000000000000.to_balance::()) verify { assert!( - ::Currency::total_issuance(liquidity_asset_id.into()) > pre_minting_liq_token_amount + ::Currency::total_issuance(liquidity_asset_id) > pre_minting_liq_token_amount ); } @@ -365,87 +382,87 @@ benchmarks! { init!(); let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let liquidity_asset_id = non_native_asset_id2 + 1; - let pool_create_first_token_amount = 40000000000000000000_u128; - let pool_create_second_token_amount = 60000000000000000000_u128; - let pool_mint_first_token_amount = 20000000000000000000_u128; - let pool_mint_second_token_amount = 30000000000000000001_u128; - - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1.into(), pool_create_first_token_amount, non_native_asset_id2.into(), pool_create_second_token_amount).unwrap(); + let initial_amount:BalanceOf = 1000000000000000000000.to_balance::(); + let expected_native_asset_id = ::NativeCurrencyId::get(); + let native_asset_id = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id1 = ::Currency::create(&caller, initial_amount).unwrap(); + let non_native_asset_id2 = ::Currency::create(&caller, initial_amount).unwrap(); + let liquidity_asset_id = non_native_asset_id2 + 1_u32.into(); + let pool_create_first_token_amount = 40000000000000000000_u128.to_balance::(); + let pool_create_second_token_amount = 60000000000000000000_u128.to_balance::(); + let pool_mint_first_token_amount = 20000000000000000000_u128.to_balance::(); + let pool_mint_second_token_amount = 30000000000000000001_u128.to_balance::(); + + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1, pool_create_first_token_amount, non_native_asset_id2, pool_create_second_token_amount).unwrap(); // as ProofOfStakeRewardsApi>::update_pool_promotion( liquidity_asset_id, Some(1u8)).unwrap(); T::LiquidityMiningRewards::enable(liquidity_asset_id, 1u8); assert!(Xyk::::liquidity_pool(liquidity_asset_id).is_some()); - Xyk::::mint_liquidity(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1.into(), non_native_asset_id2.into(), pool_mint_first_token_amount, pool_mint_second_token_amount).unwrap(); + Xyk::::mint_liquidity(RawOrigin::Signed(caller.clone().into()).into(), non_native_asset_id1, non_native_asset_id2, pool_mint_first_token_amount, pool_mint_second_token_amount).unwrap(); forward_to_next_session!(); - let total_liquidity_after_minting = ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_after_minting = ::Currency::total_issuance(liquidity_asset_id); - }: burn_liquidity(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1.into(), non_native_asset_id2.into(), total_liquidity_after_minting) + }: burn_liquidity(RawOrigin::Signed(caller.clone().into()), non_native_asset_id1, non_native_asset_id2, total_liquidity_after_minting) verify { - assert_eq!(Xyk::::liquidity_pool(liquidity_asset_id), Some((non_native_asset_id1.into(), non_native_asset_id2.into()))); - assert_eq!(::Currency::total_issuance(liquidity_asset_id.into()).into(), 0); + assert_eq!(Xyk::::liquidity_pool(liquidity_asset_id), Some((non_native_asset_id1, non_native_asset_id2))); + assert_eq!(::Currency::total_issuance(liquidity_asset_id), BalanceOf::::zero()); } provide_liquidity_with_conversion { let caller: T::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1_000_000_000; - let asset_id_1 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let asset_id_2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let liquidity_asset_id = asset_id_2 + 1; + let initial_amount:BalanceOf = 1_000_000_000.to_balance::(); + let asset_id_1 = ::Currency::create(&caller, initial_amount).unwrap(); + let asset_id_2 = ::Currency::create(&caller, initial_amount).unwrap(); + let liquidity_asset_id = asset_id_2 + 1_u32.into(); - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), asset_id_1.into(), 500_000_000, asset_id_2.into(), 500_000_000).unwrap(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), asset_id_1, 500_000_000.to_balance::(), asset_id_2, 500_000_000.to_balance::()).unwrap(); - }: provide_liquidity_with_conversion(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), asset_id_1, 100_000_u128) + }: provide_liquidity_with_conversion(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, asset_id_1, 100_000_u128.to_balance::()) verify { - let post_asset_amount_1 = ::Currency::free_balance(asset_id_1.into(), &caller).into(); - let post_asset_amount_2 = ::Currency::free_balance(asset_id_2.into(), &caller).into(); - assert_eq!(post_asset_amount_1, 499_900_002,); - assert_eq!(post_asset_amount_2, 500_000_000); + let post_asset_amount_1 = ::Currency::free_balance(asset_id_1, &caller); + let post_asset_amount_2 = ::Currency::free_balance(asset_id_2, &caller); + assert_eq!(post_asset_amount_1, 499_900_002.to_balance::()); + assert_eq!(post_asset_amount_2, 500_000_000.to_balance::()); let post_pool_balance = Xyk::::asset_pool((asset_id_1, asset_id_2)); - assert_eq!(post_pool_balance.0, 500_099_946); - assert_eq!(post_pool_balance.1, 500_000_000); + assert_eq!(post_pool_balance.0, 500_099_946.to_balance::()); + assert_eq!(post_pool_balance.1, 500_000_000.to_balance::()); } compound_rewards { let other: T::AccountId = account("caller1", 0, 0); let caller: T::AccountId = whitelisted_caller(); - let reward_ratio = 1_000_000; - let initial_amount:mangata_types::Balance = 1_000_000_000; - let pool_amount:mangata_types::Balance = initial_amount / 2; - - let next_asset_id: TokenId = ::Currency::get_next_currency_id().into(); - let asset_id_1: TokenId; - let asset_id_2: TokenId; - if next_asset_id == 0 { + let reward_ratio = 1_000_000.to_balance::(); + let initial_amount:BalanceOf = 1_000_000_000.to_balance::(); + let pool_amount:BalanceOf = initial_amount / 2_u32.into(); + + let next_asset_id = ::Currency::get_next_currency_id(); + let asset_id_1; + let asset_id_2; + if next_asset_id == 0_u32.into() { // in test there is no other currencies created - asset_id_1 = ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - ::Currency::mint(asset_id_1.into(), &other, (initial_amount * reward_ratio).into()).unwrap(); - asset_id_2 = ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - ::Currency::mint(asset_id_2.into(), &other, (initial_amount * reward_ratio).into()).unwrap(); + asset_id_1 = ::Currency::create(&caller, initial_amount).unwrap(); + ::Currency::mint(asset_id_1, &other, initial_amount * reward_ratio).unwrap(); + asset_id_2 = ::Currency::create(&caller, initial_amount).unwrap(); + ::Currency::mint(asset_id_2, &other, initial_amount * reward_ratio).unwrap(); } else { // in bench the genesis sets up the assets - asset_id_1 = ::NativeCurrencyId::get().into(); - ::Currency::mint(asset_id_1.into(), &caller, initial_amount.into()).unwrap(); - ::Currency::mint(asset_id_1.into(), &other, (initial_amount * reward_ratio).into()).unwrap(); - asset_id_2 = ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - ::Currency::mint(asset_id_2.into(), &other, (initial_amount * reward_ratio).into()).unwrap(); + asset_id_1 = ::NativeCurrencyId::get(); + ::Currency::mint(asset_id_1, &caller, initial_amount).unwrap(); + ::Currency::mint(asset_id_1, &other, initial_amount * reward_ratio).unwrap(); + asset_id_2 = ::Currency::create(&caller, initial_amount).unwrap(); + ::Currency::mint(asset_id_2, &other, initial_amount * reward_ratio).unwrap(); } - let liquidity_asset_id = asset_id_2 + 1; + let liquidity_asset_id = asset_id_2 + 1_u32.into(); as ComputeIssuance>::initialize(); - Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), asset_id_1.into(), pool_amount, asset_id_2.into(), pool_amount).unwrap(); + Xyk::::create_pool(RawOrigin::Signed(caller.clone().into()).into(), asset_id_1, pool_amount, asset_id_2, pool_amount).unwrap(); T::LiquidityMiningRewards::enable(liquidity_asset_id, 1u8); T::LiquidityMiningRewards::activate_liquidity(caller.clone(), liquidity_asset_id, pool_amount, None).unwrap(); @@ -455,7 +472,7 @@ benchmarks! { asset_id_1, asset_id_2, pool_amount * reward_ratio, - pool_amount * reward_ratio + 1, + pool_amount * reward_ratio + 1_u32.into(), ).unwrap(); frame_system::Pallet::::set_block_number(50_000u32.into()); @@ -464,20 +481,20 @@ benchmarks! { let mut pre_pool_balance = Xyk::::asset_pool((asset_id_1, asset_id_2)); let rewards_to_claim = T::LiquidityMiningRewards::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap(); let swap_amount = Xyk::::calculate_balanced_sell_amount(rewards_to_claim, pre_pool_balance.0).unwrap(); - let balance_native_before = ::Currency::free_balance(::NativeCurrencyId::get().into(), &caller).into(); - let balance_asset_before = ::Currency::free_balance(liquidity_asset_id.into(), &caller).into(); + let balance_native_before = ::Currency::free_balance(::NativeCurrencyId::get(), &caller); + let balance_asset_before = ::Currency::free_balance(liquidity_asset_id, &caller); pre_pool_balance = Xyk::::asset_pool((asset_id_1, asset_id_2)); - }: compound_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), Permill::one()) + }: compound_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, Permill::one()) verify { assert_eq!( T::LiquidityMiningRewards::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap(), - (0_u128) + 0_u32.into(), ); - let balance_native_after = ::Currency::free_balance(::NativeCurrencyId::get().into(), &caller).into(); - let balance_asset_after = ::Currency::free_balance(liquidity_asset_id.into(), &caller).into(); + let balance_native_after = ::Currency::free_balance(::NativeCurrencyId::get(), &caller); + let balance_asset_after = ::Currency::free_balance(liquidity_asset_id, &caller); // surplus asset amount assert!(balance_native_before < balance_native_after); assert_eq!(balance_asset_before, balance_asset_after); diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 79db4e5682..0586f85d63 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -291,7 +291,7 @@ use frame_support::{ assert_ok, - dispatch::{DispatchError, DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo}, + dispatch::{DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo}, ensure, traits::Contains, PalletId, @@ -301,7 +301,10 @@ use sp_core::U256; use frame_support::{ pallet_prelude::*, - traits::{tokens::currency::MultiTokenCurrency, ExistenceRequirement, Get, WithdrawReasons}, + traits::{ + tokens::currency::{MultiTokenCurrency, MultiTokenVestingLocks}, + ExistenceRequirement, Get, WithdrawReasons, + }, transactional, }; use frame_system::pallet_prelude::*; @@ -309,20 +312,21 @@ use mangata_support::traits::{ ActivationReservesProviderTrait, GetMaintenanceStatusTrait, PoolCreateApi, PreValidateSwaps, ProofOfStakeRewardsApi, Valuate, XykFunctionsTrait, }; -use mangata_types::{multipurpose_liquidity::ActivateKind, Balance, TokenId}; +use mangata_types::multipurpose_liquidity::ActivateKind; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; -use pallet_vesting_mangata::MultiTokenVestingLocks; use sp_arithmetic::{helpers_128bit::multiply_by_rational_with_rounding, per_things::Rounding}; use sp_runtime::{ - traits::{AccountIdConversion, Zero}, - ModuleError, Permill, + traits::{ + AccountIdConversion, Bounded, CheckedAdd, CheckedDiv, CheckedSub, One, Saturating, Zero, + }, + DispatchError, ModuleError, Permill, SaturatedConversion, }; use sp_std::{ collections::btree_set::BTreeSet, convert::{TryFrom, TryInto}, ops::Div, prelude::*, - vec::Vec, + vec, }; #[cfg(test)] @@ -331,16 +335,6 @@ mod mock; #[cfg(test)] mod tests; -#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -pub struct RewardInfo { - pub activated_amount: u128, - pub rewards_not_yet_claimed: u128, - pub rewards_already_claimed: u128, - pub last_checkpoint: u32, - pub pool_ratio_at_last_checkpoint: U256, - pub missing_at_last_checkpoint: U256, -} - pub(crate) const LOG_TARGET: &str = "xyk"; // syntactic sugar for logging. @@ -370,6 +364,15 @@ pub mod weights; pub use weights::WeightInfo; type AccountIdOf = ::AccountId; + +pub type BalanceOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::Balance; + +pub type CurrencyIdOf = <::Currency as MultiTokenCurrency< + ::AccountId, +>>::CurrencyId; + // type LiquidityMiningRewardsOf = ::AccountId; #[derive(Eq, PartialEq, Encode, Decode)] pub enum SwapKind { @@ -386,7 +389,7 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks> for Pallet {} #[cfg(feature = "runtime-benchmarks")] pub trait XykBenchmarkingConfig: @@ -398,19 +401,19 @@ pub mod pallet { pub trait XykBenchmarkingConfig {} // #[cfg(feature = "runtime-benchmarks")] - // pub trait XykRewardsApi: ProofOfStakeRewardsApi + LiquidityMiningApi{} + // pub trait XykRewardsApi: ProofOfStakeRewardsApi> + LiquidityMiningApi{} // #[cfg(feature = "runtime-benchmarks")] // impl XykRewardsApi for K where - // K: ProofOfStakeRewardsApi, + // K: ProofOfStakeRewardsApi>, // K: LiquidityMiningApi, // { // } // // #[cfg(not(feature = "runtime-benchmarks"))] - // pub trait XykRewardsApi: ProofOfStakeRewardsApi{} + // pub trait XykRewardsApi: ProofOfStakeRewardsApi>{} // #[cfg(not(feature = "runtime-benchmarks"))] // impl XykRewardsApi for K where - // K: ProofOfStakeRewardsApi, + // K: ProofOfStakeRewardsApi>, // { // } @@ -419,17 +422,19 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; type MaintenanceStatusProvider: GetMaintenanceStatusTrait; type ActivationReservesProvider: ActivationReservesProviderTrait< - AccountId = Self::AccountId, + Self::AccountId, + BalanceOf, + CurrencyIdOf, >; type Currency: MultiTokenCurrencyExtended + MultiTokenReservableCurrency; - type NativeCurrencyId: Get; + type NativeCurrencyId: Get>; type TreasuryPalletId: Get; type BnbTreasurySubAccDerive: Get<[u8; 4]>; type LiquidityMiningRewards: ProofOfStakeRewardsApi< Self::AccountId, - Balance = Balance, - CurrencyId = TokenId, + BalanceOf, + CurrencyIdOf, >; #[pallet::constant] type PoolFeePercentage: Get; @@ -437,10 +442,14 @@ pub mod pallet { type TreasuryFeePercentage: Get; #[pallet::constant] type BuyAndBurnFeePercentage: Get; - type DisallowedPools: Contains<(TokenId, TokenId)>; - type DisabledTokens: Contains; - type VestingProvider: MultiTokenVestingLocks; - type AssetMetadataMutation: AssetMetadataMutationTrait; + type DisallowedPools: Contains<(CurrencyIdOf, CurrencyIdOf)>; + type DisabledTokens: Contains>; + type VestingProvider: MultiTokenVestingLocks< + Self::AccountId, + Currency = ::Currency, + Moment = BlockNumberFor, + >; + type AssetMetadataMutation: AssetMetadataMutationTrait>; type WeightInfo: WeightInfo; } @@ -511,41 +520,96 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - PoolCreated(T::AccountId, TokenId, Balance, TokenId, Balance), - AssetsSwapped(T::AccountId, Vec, Balance, Balance), - SellAssetFailedDueToSlippage(T::AccountId, TokenId, Balance, TokenId, Balance, Balance), - BuyAssetFailedDueToSlippage(T::AccountId, TokenId, Balance, TokenId, Balance, Balance), - LiquidityMinted(T::AccountId, TokenId, Balance, TokenId, Balance, TokenId, Balance), - LiquidityBurned(T::AccountId, TokenId, Balance, TokenId, Balance, TokenId, Balance), - PoolPromotionUpdated(TokenId, Option), - LiquidityActivated(T::AccountId, TokenId, Balance), - LiquidityDeactivated(T::AccountId, TokenId, Balance), - RewardsClaimed(T::AccountId, TokenId, Balance), - MultiSwapAssetFailedOnAtomicSwap(T::AccountId, Vec, Balance, ModuleError), + PoolCreated(T::AccountId, CurrencyIdOf, BalanceOf, CurrencyIdOf, BalanceOf), + AssetsSwapped(T::AccountId, Vec>, BalanceOf, BalanceOf), + SellAssetFailedDueToSlippage( + T::AccountId, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + BalanceOf, + ), + BuyAssetFailedDueToSlippage( + T::AccountId, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + BalanceOf, + ), + LiquidityMinted( + T::AccountId, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + ), + LiquidityBurned( + T::AccountId, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + ), + PoolPromotionUpdated(CurrencyIdOf, Option), + LiquidityActivated(T::AccountId, CurrencyIdOf, BalanceOf), + LiquidityDeactivated(T::AccountId, CurrencyIdOf, BalanceOf), + RewardsClaimed(T::AccountId, CurrencyIdOf, BalanceOf), + MultiSwapAssetFailedOnAtomicSwap( + T::AccountId, + Vec>, + BalanceOf, + ModuleError, + ), } #[pallet::storage] #[pallet::getter(fn asset_pool)] - pub type Pools = - StorageMap<_, Blake2_256, (TokenId, TokenId), (Balance, Balance), ValueQuery>; + pub type Pools = StorageMap< + _, + Blake2_256, + (CurrencyIdOf, CurrencyIdOf), + (BalanceOf, BalanceOf), + ValueQuery, + >; #[pallet::storage] #[pallet::getter(fn liquidity_asset)] - pub type LiquidityAssets = - StorageMap<_, Blake2_256, (TokenId, TokenId), Option, ValueQuery>; + pub type LiquidityAssets = StorageMap< + _, + Blake2_256, + (CurrencyIdOf, CurrencyIdOf), + Option>, + ValueQuery, + >; #[pallet::storage] #[pallet::getter(fn liquidity_pool)] - pub type LiquidityPools = - StorageMap<_, Blake2_256, TokenId, Option<(TokenId, TokenId)>, ValueQuery>; + pub type LiquidityPools = StorageMap< + _, + Blake2_256, + CurrencyIdOf, + Option<(CurrencyIdOf, CurrencyIdOf)>, + ValueQuery, + >; #[pallet::genesis_config] pub struct GenesisConfig { - pub created_pools_for_staking: - Vec<(T::AccountId, TokenId, Balance, TokenId, Balance, TokenId)>, + pub created_pools_for_staking: Vec<( + T::AccountId, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + BalanceOf, + CurrencyIdOf, + )>, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { GenesisConfig { created_pools_for_staking: vec![] } @@ -553,7 +617,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { + impl BuildGenesisConfig for GenesisConfig { fn build(&self) { self.created_pools_for_staking.iter().for_each( |( @@ -566,7 +630,11 @@ pub mod pallet { )| { if ::Currency::exists({ *liquidity_token_id }.into()) { assert!( - as XykFunctionsTrait>::mint_liquidity( + as XykFunctionsTrait< + T::AccountId, + BalanceOf, + CurrencyIdOf, + >>::mint_liquidity( account_id.clone(), *native_token_id, *pooled_token_id, @@ -578,13 +646,17 @@ pub mod pallet { "Pool mint failed" ); } else { - let created_liquidity_token_id: TokenId = + let created_liquidity_token_id: CurrencyIdOf = ::Currency::get_next_currency_id().into(); assert_eq!( created_liquidity_token_id, *liquidity_token_id, "Assets not initialized in the expected sequence", ); - assert_ok!( as XykFunctionsTrait>::create_pool( + assert_ok!( as XykFunctionsTrait< + T::AccountId, + BalanceOf, + CurrencyIdOf, + >>::create_pool( account_id.clone(), *native_token_id, *native_token_amount, @@ -604,10 +676,10 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::create_pool())] pub fn create_pool( origin: OriginFor, - first_asset_id: TokenId, - first_asset_amount: Balance, - second_asset_id: TokenId, - second_asset_amount: Balance, + first_asset_id: CurrencyIdOf, + first_asset_amount: BalanceOf, + second_asset_id: CurrencyIdOf, + second_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -622,7 +694,7 @@ pub mod pallet { Error::::DisallowedPool, ); - >::create_pool( + , CurrencyIdOf>>::create_pool( sender, first_asset_id, first_asset_amount, @@ -652,14 +724,14 @@ pub mod pallet { #[deprecated(note = "multiswap_sell_asset should be used instead")] pub fn sell_asset( origin: OriginFor, - sold_asset_id: TokenId, - bought_asset_id: TokenId, - sold_asset_amount: Balance, - min_amount_out: Balance, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + sold_asset_amount: BalanceOf, + min_amount_out: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - >::sell_asset( + , CurrencyIdOf>>::sell_asset( sender, sold_asset_id, bought_asset_id, @@ -695,16 +767,16 @@ pub mod pallet { #[pallet::weight((<::WeightInfo>::multiswap_sell_asset(swap_token_list.len() as u32), DispatchClass::Operational, Pays::No))] pub fn multiswap_sell_asset( origin: OriginFor, - swap_token_list: Vec, - sold_asset_amount: Balance, - min_amount_out: Balance, + swap_token_list: Vec>, + sold_asset_amount: BalanceOf, + min_amount_out: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; if let (Some(sold_asset_id), Some(bought_asset_id), 2) = (swap_token_list.get(0), swap_token_list.get(1), swap_token_list.len()) { - >::sell_asset( + , CurrencyIdOf>>::sell_asset( sender, *sold_asset_id, *bought_asset_id, @@ -713,7 +785,7 @@ pub mod pallet { false, ) } else { - >::multiswap_sell_asset( + , CurrencyIdOf>>::multiswap_sell_asset( sender, swap_token_list.clone(), sold_asset_amount, @@ -753,14 +825,14 @@ pub mod pallet { #[deprecated(note = "multiswap_buy_asset should be used instead")] pub fn buy_asset( origin: OriginFor, - sold_asset_id: TokenId, - bought_asset_id: TokenId, - bought_asset_amount: Balance, - max_amount_in: Balance, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - >::buy_asset( + , CurrencyIdOf>>::buy_asset( sender, sold_asset_id, bought_asset_id, @@ -799,16 +871,16 @@ pub mod pallet { #[pallet::weight((<::WeightInfo>::multiswap_buy_asset(swap_token_list.len() as u32), DispatchClass::Operational, Pays::No))] pub fn multiswap_buy_asset( origin: OriginFor, - swap_token_list: Vec, - bought_asset_amount: Balance, - max_amount_in: Balance, + swap_token_list: Vec>, + bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; if let (Some(sold_asset_id), Some(bought_asset_id), 2) = (swap_token_list.get(0), swap_token_list.get(1), swap_token_list.len()) { - >::buy_asset( + , CurrencyIdOf>>::buy_asset( sender, *sold_asset_id, *bought_asset_id, @@ -817,7 +889,7 @@ pub mod pallet { false, ) } else { - >::multiswap_buy_asset( + , CurrencyIdOf>>::multiswap_buy_asset( sender, swap_token_list.clone(), bought_asset_amount, @@ -844,9 +916,9 @@ pub mod pallet { pub fn mint_liquidity_using_vesting_native_tokens_by_vesting_index( origin: OriginFor, native_asset_vesting_index: u32, - vesting_native_asset_unlock_some_amount_or_all: Option, - second_asset_id: TokenId, - expected_second_asset_amount: Balance, + vesting_native_asset_unlock_some_amount_or_all: Option>, + second_asset_id: CurrencyIdOf, + expected_second_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -854,40 +926,45 @@ pub mod pallet { Pallet::::get_liquidity_asset(Self::native_token_id(), second_asset_id)?; ensure!( - >::is_enabled( - liquidity_asset_id - ), + , + CurrencyIdOf, + >>::is_enabled(liquidity_asset_id), Error::::NotAPromotedPool ); let (unlocked_amount, vesting_starting_block, vesting_ending_block_as_balance): ( - Balance, - T::BlockNumber, - Balance, + BalanceOf, + BlockNumberFor, + BalanceOf, ) = <::VestingProvider>::unlock_tokens_by_vesting_index( &sender, Self::native_token_id().into(), native_asset_vesting_index, - vesting_native_asset_unlock_some_amount_or_all.map(Into::into), + vesting_native_asset_unlock_some_amount_or_all, ) - .map(|x| (x.0.into(), x.1, x.2.into()))?; + .map(|x| (x.0, x.1, x.2))?; - let (liquidity_token_id, liquidity_assets_minted) = - >::mint_liquidity( - sender.clone(), - Self::native_token_id(), - second_asset_id, - unlocked_amount, - expected_second_asset_amount, - false, - )?; + let (liquidity_token_id, liquidity_assets_minted) = , + CurrencyIdOf, + >>::mint_liquidity( + sender.clone(), + Self::native_token_id(), + second_asset_id, + unlocked_amount, + expected_second_asset_amount, + false, + )?; <::VestingProvider>::lock_tokens( &sender, liquidity_token_id.into(), - liquidity_assets_minted.into(), + liquidity_assets_minted, Some(vesting_starting_block), - vesting_ending_block_as_balance.into(), + vesting_ending_block_as_balance, )?; Ok(().into()) @@ -898,9 +975,9 @@ pub mod pallet { #[transactional] pub fn mint_liquidity_using_vesting_native_tokens( origin: OriginFor, - vesting_native_asset_amount: Balance, - second_asset_id: TokenId, - expected_second_asset_amount: Balance, + vesting_native_asset_amount: BalanceOf, + second_asset_id: CurrencyIdOf, + expected_second_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -908,38 +985,43 @@ pub mod pallet { Pallet::::get_liquidity_asset(Self::native_token_id(), second_asset_id)?; ensure!( - >::is_enabled( - liquidity_asset_id - ), + , + CurrencyIdOf, + >>::is_enabled(liquidity_asset_id), Error::::NotAPromotedPool ); let (vesting_starting_block, vesting_ending_block_as_balance): ( - T::BlockNumber, - Balance, + BlockNumberFor, + BalanceOf, ) = <::VestingProvider>::unlock_tokens( &sender, Self::native_token_id().into(), - vesting_native_asset_amount.into(), + vesting_native_asset_amount, ) - .map(|x| (x.0, x.1.into()))?; + .map(|x| (x.0, x.1))?; - let (liquidity_token_id, liquidity_assets_minted) = - >::mint_liquidity( - sender.clone(), - Self::native_token_id(), - second_asset_id, - vesting_native_asset_amount, - expected_second_asset_amount, - false, - )?; + let (liquidity_token_id, liquidity_assets_minted) = , + CurrencyIdOf, + >>::mint_liquidity( + sender.clone(), + Self::native_token_id(), + second_asset_id, + vesting_native_asset_amount, + expected_second_asset_amount, + false, + )?; <::VestingProvider>::lock_tokens( &sender, liquidity_token_id.into(), - liquidity_assets_minted.into(), + liquidity_assets_minted, Some(vesting_starting_block), - vesting_ending_block_as_balance.into(), + vesting_ending_block_as_balance, )?; Ok(().into()) @@ -949,10 +1031,10 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::mint_liquidity())] pub fn mint_liquidity( origin: OriginFor, - first_asset_id: TokenId, - second_asset_id: TokenId, - first_asset_amount: Balance, - expected_second_asset_amount: Balance, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + first_asset_amount: BalanceOf, + expected_second_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -962,7 +1044,7 @@ pub mod pallet { Error::::FunctionNotAvailableForThisToken ); - >::mint_liquidity( + , CurrencyIdOf>>::mint_liquidity( sender, first_asset_id, second_asset_id, @@ -979,12 +1061,12 @@ pub mod pallet { #[transactional] pub fn compound_rewards( origin: OriginFor, - liquidity_asset_id: TokenId, + liquidity_asset_id: CurrencyIdOf, amount_permille: Permill, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - >::do_compound_rewards( + , CurrencyIdOf>>::do_compound_rewards( sender, liquidity_asset_id, amount_permille, @@ -998,9 +1080,9 @@ pub mod pallet { #[transactional] pub fn provide_liquidity_with_conversion( origin: OriginFor, - liquidity_asset_id: TokenId, - provided_asset_id: TokenId, - provided_asset_amount: Balance, + liquidity_asset_id: CurrencyIdOf, + provided_asset_id: CurrencyIdOf, + provided_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -1013,7 +1095,7 @@ pub mod pallet { Error::::FunctionNotAvailableForThisToken ); - >::provide_liquidity_with_conversion( + , CurrencyIdOf>>::provide_liquidity_with_conversion( sender, first_asset_id, second_asset_id, @@ -1029,13 +1111,13 @@ pub mod pallet { #[pallet::weight(<::WeightInfo>::burn_liquidity())] pub fn burn_liquidity( origin: OriginFor, - first_asset_id: TokenId, - second_asset_id: TokenId, - liquidity_asset_amount: Balance, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + liquidity_asset_amount: BalanceOf, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - >::burn_liquidity( + , CurrencyIdOf>>::burn_liquidity( sender, first_asset_id, second_asset_id, @@ -1056,17 +1138,17 @@ impl Pallet { pub fn get_max_instant_burn_amount( user: &AccountIdOf, - liquidity_asset_id: TokenId, - ) -> Balance { + liquidity_asset_id: CurrencyIdOf, + ) -> BalanceOf { Self::get_max_instant_unreserve_amount(user, liquidity_asset_id).saturating_add( - ::Currency::available_balance(liquidity_asset_id.into(), user).into(), + ::Currency::available_balance(liquidity_asset_id.into(), user), ) } pub fn get_max_instant_unreserve_amount( user: &AccountIdOf, - liquidity_asset_id: TokenId, - ) -> Balance { + liquidity_asset_id: CurrencyIdOf, + ) -> BalanceOf { ::ActivationReservesProvider::get_max_instant_unreserve_amount( liquidity_asset_id, user, @@ -1077,14 +1159,14 @@ impl Pallet { // May fail if liquidity_asset_id does not exsist // Should not fail otherwise as the parameters for the max and min length in pallet_assets_info should be set appropriately pub fn set_liquidity_asset_info( - liquidity_asset_id: TokenId, - first_asset_id: TokenId, - second_asset_id: TokenId, + liquidity_asset_id: CurrencyIdOf, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, ) -> DispatchResult { let mut name: Vec = Vec::::new(); name.extend_from_slice(LIQUIDITY_TOKEN_IDENTIFIER); name.extend_from_slice(HEX_INDICATOR); - for bytes in liquidity_asset_id.to_be_bytes().iter() { + for bytes in liquidity_asset_id.saturated_into::().to_be_bytes().iter() { match (bytes >> 4) as u8 { x @ 0u8..=9u8 => name.push(x.saturating_add(48u8)), x => name.push(x.saturating_add(55u8)), @@ -1098,7 +1180,7 @@ impl Pallet { let mut symbol: Vec = Vec::::new(); symbol.extend_from_slice(TOKEN_SYMBOL); symbol.extend_from_slice(HEX_INDICATOR); - for bytes in first_asset_id.to_be_bytes().iter() { + for bytes in first_asset_id.saturated_into::().to_be_bytes().iter() { match (bytes >> 4) as u8 { x @ 0u8..=9u8 => symbol.push(x.saturating_add(48u8)), x => symbol.push(x.saturating_add(55u8)), @@ -1111,7 +1193,7 @@ impl Pallet { symbol.extend_from_slice(TOKEN_SYMBOL_SEPARATOR); symbol.extend_from_slice(TOKEN_SYMBOL); symbol.extend_from_slice(HEX_INDICATOR); - for bytes in second_asset_id.to_be_bytes().iter() { + for bytes in second_asset_id.saturated_into::().to_be_bytes().iter() { match (bytes >> 4) as u8 { x @ 0u8..=9u8 => symbol.push(x.saturating_add(48u8)), x => symbol.push(x.saturating_add(55u8)), @@ -1133,16 +1215,16 @@ impl Pallet { // Calculate amount of tokens to be bought by sellling sell_amount pub fn calculate_sell_price( - input_reserve: Balance, - output_reserve: Balance, - sell_amount: Balance, - ) -> Result { + input_reserve: BalanceOf, + output_reserve: BalanceOf, + sell_amount: BalanceOf, + ) -> Result, DispatchError> { let after_fee_percentage: u128 = 10000_u128 .checked_sub(Self::total_fee()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; - let input_reserve_saturated: U256 = input_reserve.into(); - let output_reserve_saturated: U256 = output_reserve.into(); - let sell_amount_saturated: U256 = sell_amount.into(); + let input_reserve_saturated: U256 = input_reserve.into().into(); + let output_reserve_saturated: U256 = output_reserve.into().into(); + let sell_amount_saturated: U256 = sell_amount.into().into(); let input_amount_with_fee: U256 = sell_amount_saturated.saturating_mul(after_fee_percentage.into()); @@ -1160,11 +1242,14 @@ impl Pallet { .checked_div(denominator) .ok_or_else(|| DispatchError::from(Error::::DivisionByZero))?; - let result = Balance::try_from(result_u256) + let result_u128 = u128::try_from(result_u256) + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + + let result = BalanceOf::::try_from(result_u128) .map_err(|_| DispatchError::from(Error::::MathOverflow))?; log!( info, - "calculate_sell_price: ({}, {}, {}) -> {}", + "calculate_sell_price: ({:?}, {:?}, {:?}) -> {:?}", input_reserve, output_reserve, sell_amount, @@ -1175,24 +1260,26 @@ impl Pallet { pub fn calculate_sell_price_no_fee( // Callculate amount of tokens to be received by sellling sell_amount, without fee - input_reserve: Balance, - output_reserve: Balance, - sell_amount: Balance, - ) -> Result { - let input_reserve_saturated: U256 = input_reserve.into(); - let output_reserve_saturated: U256 = output_reserve.into(); - let sell_amount_saturated: U256 = sell_amount.into(); + input_reserve: BalanceOf, + output_reserve: BalanceOf, + sell_amount: BalanceOf, + ) -> Result, DispatchError> { + let input_reserve_saturated: U256 = input_reserve.into().into(); + let output_reserve_saturated: U256 = output_reserve.into().into(); + let sell_amount_saturated: U256 = sell_amount.into().into(); let numerator: U256 = sell_amount_saturated.saturating_mul(output_reserve_saturated); let denominator: U256 = input_reserve_saturated.saturating_add(sell_amount_saturated); let result_u256 = numerator .checked_div(denominator) .ok_or_else(|| DispatchError::from(Error::::DivisionByZero))?; - let result = Balance::try_from(result_u256) + let result_u128 = u128::try_from(result_u256) + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + let result = BalanceOf::::try_from(result_u128) .map_err(|_| DispatchError::from(Error::::MathOverflow))?; log!( info, - "calculate_sell_price_no_fee: ({}, {}, {}) -> {}", + "calculate_sell_price_no_fee: ({:?}, {:?}, {:?}) -> {:?}", input_reserve, output_reserve, sell_amount, @@ -1203,16 +1290,16 @@ impl Pallet { // Calculate amount of tokens to be paid, when buying buy_amount pub fn calculate_buy_price( - input_reserve: Balance, - output_reserve: Balance, - buy_amount: Balance, - ) -> Result { + input_reserve: BalanceOf, + output_reserve: BalanceOf, + buy_amount: BalanceOf, + ) -> Result, DispatchError> { let after_fee_percentage: u128 = 10000_u128 .checked_sub(Self::total_fee()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; - let input_reserve_saturated: U256 = input_reserve.into(); - let output_reserve_saturated: U256 = output_reserve.into(); - let buy_amount_saturated: U256 = buy_amount.into(); + let input_reserve_saturated: U256 = input_reserve.into().into(); + let output_reserve_saturated: U256 = output_reserve.into().into(); + let buy_amount_saturated: U256 = buy_amount.into().into(); let numerator: U256 = input_reserve_saturated .saturating_mul(buy_amount_saturated) @@ -1231,11 +1318,14 @@ impl Pallet { .checked_add(1.into()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; - let result = Balance::try_from(result_u256) + let result_u128 = u128::try_from(result_u256) + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + + let result = BalanceOf::::try_from(result_u128) .map_err(|_| DispatchError::from(Error::::MathOverflow))?; log!( info, - "calculate_buy_price: ({}, {}, {}) -> {}", + "calculate_buy_price: ({:?}, {:?}, {:?}) -> {:?}", input_reserve, output_reserve, buy_amount, @@ -1245,9 +1335,9 @@ impl Pallet { } pub fn calculate_balanced_sell_amount( - total_amount: Balance, - reserve_amount: Balance, - ) -> Result { + total_amount: BalanceOf, + reserve_amount: BalanceOf, + ) -> Result, DispatchError> { let multiplier: U256 = 10_000.into(); let multiplier_sq: U256 = multiplier.pow(2.into()); let non_pool_fees: U256 = Self::total_fee() @@ -1255,8 +1345,8 @@ impl Pallet { .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? .into(); // npf let total_fee: U256 = Self::total_fee().into(); // tf - let total_amount_saturated: U256 = total_amount.into(); // z - let reserve_amount_saturated: U256 = reserve_amount.into(); // a + let total_amount_saturated: U256 = total_amount.into().into(); // z + let reserve_amount_saturated: U256 = reserve_amount.into().into(); // a // n: 2*10_000^2*a - 10_000*tf*a - sqrt( (-2*10_000^2*a + 10_000*tf*a)^2 - 4*10_000^2*a*z*(10_000tf - npf*tf + 10_000npf - 10_000^2) ) // d: 2 * (10_000tf - npf*tf + 10_000npf - 10_000^2) @@ -1304,13 +1394,15 @@ impl Pallet { let result_u256 = numerator_negative .checked_div(denominator_negative) .ok_or_else(|| DispatchError::from(Error::::DivisionByZero))?; - let result = Balance::try_from(result_u256) + let result_u128 = u128::try_from(result_u256) + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + let result = BalanceOf::::try_from(result_u128) .map_err(|_| DispatchError::from(Error::::MathOverflow))?; Ok(result) } - pub fn get_liq_tokens_for_trading() -> Result, DispatchError> { + pub fn get_liq_tokens_for_trading() -> Result>, DispatchError> { let result = LiquidityAssets::::iter_values() .filter_map(|v| v) .filter(|v| !::Currency::total_issuance((*v).into()).is_zero()) @@ -1321,9 +1413,9 @@ impl Pallet { // MAX: 2R pub fn get_liquidity_asset( - first_asset_id: TokenId, - second_asset_id: TokenId, - ) -> Result { + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + ) -> Result, DispatchError> { if LiquidityAssets::::contains_key((first_asset_id, second_asset_id)) { LiquidityAssets::::get((first_asset_id, second_asset_id)) .ok_or_else(|| Error::::UnexpectedFailure.into()) @@ -1334,10 +1426,10 @@ impl Pallet { } pub fn calculate_sell_price_id( - sold_token_id: TokenId, - bought_token_id: TokenId, - sell_amount: Balance, - ) -> Result { + sold_token_id: CurrencyIdOf, + bought_token_id: CurrencyIdOf, + sell_amount: BalanceOf, + ) -> Result, DispatchError> { let (input_reserve, output_reserve) = Pallet::::get_reserves(sold_token_id, bought_token_id)?; @@ -1347,10 +1439,10 @@ impl Pallet { } pub fn calculate_buy_price_id( - sold_token_id: TokenId, - bought_token_id: TokenId, - buy_amount: Balance, - ) -> Result { + sold_token_id: CurrencyIdOf, + bought_token_id: CurrencyIdOf, + buy_amount: BalanceOf, + ) -> Result, DispatchError> { let (input_reserve, output_reserve) = Pallet::::get_reserves(sold_token_id, bought_token_id)?; @@ -1360,9 +1452,9 @@ impl Pallet { } pub fn get_reserves( - first_asset_id: TokenId, - second_asset_id: TokenId, - ) -> Result<(Balance, Balance), DispatchError> { + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + ) -> Result<(BalanceOf, BalanceOf), DispatchError> { let mut reserves = Pools::::get((first_asset_id, second_asset_id)); if Pools::::contains_key((first_asset_id, second_asset_id)) { @@ -1378,10 +1470,10 @@ impl Pallet { /// worst case scenario /// MAX: 2R 1W pub fn set_reserves( - first_asset_id: TokenId, - first_asset_amount: Balance, - second_asset_id: TokenId, - second_asset_amount: Balance, + first_asset_id: CurrencyIdOf, + first_asset_amount: BalanceOf, + second_asset_id: CurrencyIdOf, + second_asset_amount: BalanceOf, ) -> DispatchResult { if Pools::::contains_key((first_asset_id, second_asset_id)) { Pools::::insert( @@ -1402,10 +1494,10 @@ impl Pallet { // Calculate first and second token amounts depending on liquidity amount to burn pub fn get_burn_amount( - first_asset_id: TokenId, - second_asset_id: TokenId, - liquidity_asset_amount: Balance, - ) -> Result<(Balance, Balance), DispatchError> { + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + liquidity_asset_amount: BalanceOf, + ) -> Result<(BalanceOf, BalanceOf), DispatchError> { // Get token reserves and liquidity asset id let liquidity_asset_id = Self::get_liquidity_asset(first_asset_id, second_asset_id)?; let (first_asset_reserve, second_asset_reserve) = @@ -1422,7 +1514,7 @@ impl Pallet { log!( info, - "get_burn_amount: ({}, {}, {}) -> ({}, {})", + "get_burn_amount: ({:?}, {:?}, {:?}) -> ({:?}, {:?})", first_asset_id, second_asset_id, liquidity_asset_amount, @@ -1434,43 +1526,45 @@ impl Pallet { } pub fn get_burn_amount_reserves( - first_asset_reserve: Balance, - second_asset_reserve: Balance, - liquidity_asset_id: TokenId, - liquidity_asset_amount: Balance, - ) -> Result<(Balance, Balance), DispatchError> { + first_asset_reserve: BalanceOf, + second_asset_reserve: BalanceOf, + liquidity_asset_id: CurrencyIdOf, + liquidity_asset_amount: BalanceOf, + ) -> Result<(BalanceOf, BalanceOf), DispatchError> { // Get token reserves and liquidity asset id - let total_liquidity_assets: Balance = - ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_assets: BalanceOf = + ::Currency::total_issuance(liquidity_asset_id.into()); // Calculate first and second token amount to be withdrawn ensure!(!total_liquidity_assets.is_zero(), Error::::DivisionByZero); let first_asset_amount = multiply_by_rational_with_rounding( - first_asset_reserve, - liquidity_asset_amount, - total_liquidity_assets, + first_asset_reserve.into(), + liquidity_asset_amount.into(), + total_liquidity_assets.into(), Rounding::Down, ) + .map(SaturatedConversion::saturated_into) .ok_or(Error::::UnexpectedFailure)?; let second_asset_amount = multiply_by_rational_with_rounding( - second_asset_reserve, - liquidity_asset_amount, - total_liquidity_assets, + second_asset_reserve.into(), + liquidity_asset_amount.into(), + total_liquidity_assets.into(), Rounding::Down, ) + .map(SaturatedConversion::saturated_into) .ok_or(Error::::UnexpectedFailure)?; Ok((first_asset_amount, second_asset_amount)) } fn settle_treasury_and_burn( - sold_asset_id: TokenId, - burn_amount: Balance, - treasury_amount: Balance, + sold_asset_id: CurrencyIdOf, + burn_amount: BalanceOf, + treasury_amount: BalanceOf, ) -> DispatchResult { let vault = Self::account_id(); - let mangata_id: TokenId = Self::native_token_id(); + let mangata_id: CurrencyIdOf = Self::native_token_id(); let treasury_account: T::AccountId = Self::treasury_account_id(); let bnb_treasury_account: T::AccountId = Self::bnb_treasury_account_id(); @@ -1483,7 +1577,7 @@ impl Pallet { ::Currency::burn_and_settle( sold_asset_id.into(), &bnb_treasury_account, - burn_amount.into(), + burn_amount, )?; } //If settling token is connected to mangata, token is swapped in corresponding pool to mangata without fee @@ -1501,11 +1595,12 @@ impl Pallet { input_reserve, output_reserve, treasury_amount - .checked_add(burn_amount) + .checked_add(&burn_amount) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?, )?; - let treasury_amount_in_mangata = settle_amount_in_mangata + let treasury_amount_in_mangata: BalanceOf = settle_amount_in_mangata + .into() .checked_mul(T::TreasuryFeePercentage::get()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? .checked_div( @@ -1513,11 +1608,16 @@ impl Pallet { .checked_add(T::BuyAndBurnFeePercentage::get()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?, ) - .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; + .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; - let burn_amount_in_mangata = settle_amount_in_mangata - .checked_sub(treasury_amount_in_mangata) - .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; + let burn_amount_in_mangata: BalanceOf = settle_amount_in_mangata + .into() + .checked_sub(treasury_amount_in_mangata.into()) + .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; // Apply changes in token pools, adding treasury and burn amounts of settling token, removing treasury and burn amounts of mangata @@ -1535,7 +1635,7 @@ impl Pallet { sold_asset_id.into(), &treasury_account, &vault, - treasury_amount.into(), + treasury_amount, ExistenceRequirement::KeepAlive, )?; @@ -1543,7 +1643,7 @@ impl Pallet { mangata_id.into(), &vault, &treasury_account, - treasury_amount_in_mangata.into(), + treasury_amount_in_mangata, ExistenceRequirement::KeepAlive, )?; @@ -1551,7 +1651,7 @@ impl Pallet { sold_asset_id.into(), &bnb_treasury_account, &vault, - burn_amount.into(), + burn_amount, ExistenceRequirement::KeepAlive, )?; @@ -1559,7 +1659,7 @@ impl Pallet { ::Currency::burn_and_settle( mangata_id.into(), &vault, - burn_amount_in_mangata.into(), + burn_amount_in_mangata, )?; } // Settling token has no mangata connection, settling token is added to treasuries @@ -1581,54 +1681,52 @@ impl Pallet { T::TreasuryPalletId::get().into_sub_account_truncating(T::BnbTreasurySubAccDerive::get()) } - fn native_token_id() -> TokenId { + fn native_token_id() -> CurrencyIdOf { ::NativeCurrencyId::get() } fn calculate_initial_liquidity( - first_asset_amount: Balance, - second_asset_amount: Balance, - ) -> Result { - let mut initial_liquidity = first_asset_amount - .checked_div(2) + first_asset_amount: BalanceOf, + second_asset_amount: BalanceOf, + ) -> Result, DispatchError> { + let initial_liquidity = first_asset_amount + .checked_div(&2_u32.into()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? .checked_add( - second_asset_amount - .checked_div(2) + &second_asset_amount + .checked_div(&2_u32.into()) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?, ) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; - return Ok(if initial_liquidity == 0 { 1 } else { initial_liquidity }) + return Ok(if initial_liquidity == BalanceOf::::zero() { + BalanceOf::::one() + } else { + initial_liquidity + }) } fn is_pool_empty( - first_asset_id: TokenId, - second_asset_id: TokenId, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, ) -> Result { let liquidity_asset_id = Pallet::::get_liquidity_asset(first_asset_id, second_asset_id)?; - let total_liquidity_assets: Balance = - ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_assets: BalanceOf = + ::Currency::total_issuance(liquidity_asset_id.into()); return Ok(total_liquidity_assets.is_zero()) } } -impl PreValidateSwaps for Pallet { - type AccountId = T::AccountId; - - type Balance = Balance; - - type CurrencyId = TokenId; - +impl PreValidateSwaps, CurrencyIdOf> for Pallet { fn pre_validate_sell_asset( - sender: &Self::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - sold_asset_amount: Self::Balance, - _min_amount_out: Self::Balance, + sender: &T::AccountId, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + sold_asset_amount: BalanceOf, + _min_amount_out: BalanceOf, ) -> Result< - (Self::Balance, Self::Balance, Self::Balance, Self::Balance, Self::Balance, Self::Balance), + (BalanceOf, BalanceOf, BalanceOf, BalanceOf, BalanceOf, BalanceOf), DispatchError, > { ensure!( @@ -1647,46 +1745,52 @@ impl PreValidateSwaps for Pallet { ensure!(!(Self::is_pool_empty(sold_asset_id, bought_asset_id)?), Error::::PoolIsEmpty); - let buy_and_burn_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let buy_and_burn_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::BuyAndBurnFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let treasury_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let treasury_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::TreasuryFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let pool_fee_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let pool_fee_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::PoolFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let total_fees = buy_and_burn_amount - .checked_add(treasury_amount) - .and_then(|v| v.checked_add(pool_fee_amount)) + let total_fees: BalanceOf = buy_and_burn_amount + .checked_add(&treasury_amount) + .and_then(|v| v.checked_add(&pool_fee_amount)) .ok_or(Error::::MathOverflow)?; // MAX: 2R let (input_reserve, output_reserve) = Pallet::::get_reserves(sold_asset_id, bought_asset_id)?; - ensure!(input_reserve.checked_add(sold_asset_amount).is_some(), Error::::MathOverflow); + ensure!(input_reserve.checked_add(&sold_asset_amount).is_some(), Error::::MathOverflow); // Calculate bought asset amount to be received by paying sold asset amount let bought_asset_amount = @@ -1696,7 +1800,7 @@ impl PreValidateSwaps for Pallet { ::Currency::ensure_can_withdraw( sold_asset_id.into(), sender, - total_fees.into(), + total_fees, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -1715,19 +1819,19 @@ impl PreValidateSwaps for Pallet { /// We only validate the first atomic swap's ability to accept fees fn pre_validate_multiswap_sell_asset( - sender: &Self::AccountId, - swap_token_list: Vec, - sold_asset_amount: Self::Balance, - _min_amount_out: Self::Balance, + sender: &T::AccountId, + swap_token_list: Vec>, + sold_asset_amount: BalanceOf, + _min_amount_out: BalanceOf, ) -> Result< ( - Self::Balance, - Self::Balance, - Self::Balance, - Self::Balance, - Self::Balance, - Self::CurrencyId, - Self::CurrencyId, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + CurrencyIdOf, + CurrencyIdOf, ), DispatchError, > { @@ -1744,7 +1848,7 @@ impl PreValidateSwaps for Pallet { // Ensure not selling zero amount ensure!(!sold_asset_amount.is_zero(), Error::::ZeroAmount,); - let atomic_pairs: Vec<(TokenId, TokenId)> = swap_token_list + let atomic_pairs: Vec<(CurrencyIdOf, CurrencyIdOf)> = swap_token_list .clone() .into_iter() .zip(swap_token_list.clone().into_iter().skip(1)) @@ -1764,39 +1868,45 @@ impl PreValidateSwaps for Pallet { Error::::FunctionNotAvailableForThisToken ); - let buy_and_burn_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let buy_and_burn_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::BuyAndBurnFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let treasury_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let treasury_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::TreasuryFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let pool_fee_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let pool_fee_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::PoolFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; let total_fees = buy_and_burn_amount - .checked_add(treasury_amount) - .and_then(|v| v.checked_add(pool_fee_amount)) + .checked_add(&treasury_amount) + .and_then(|v| v.checked_add(&pool_fee_amount)) .ok_or(Error::::MathOverflow)?; // Get token reserves @@ -1805,13 +1915,13 @@ impl PreValidateSwaps for Pallet { let (input_reserve, output_reserve) = Pallet::::get_reserves(sold_asset_id, bought_asset_id)?; - ensure!(input_reserve.checked_add(pool_fee_amount).is_some(), Error::::MathOverflow); + ensure!(input_reserve.checked_add(&pool_fee_amount).is_some(), Error::::MathOverflow); // Ensure user has enough tokens to sell ::Currency::ensure_can_withdraw( sold_asset_id.into(), sender, - total_fees.into(), + total_fees, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -1830,13 +1940,13 @@ impl PreValidateSwaps for Pallet { } fn pre_validate_buy_asset( - sender: &Self::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - bought_asset_amount: Self::Balance, - _max_amount_in: Self::Balance, + sender: &T::AccountId, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + bought_asset_amount: BalanceOf, + _max_amount_in: BalanceOf, ) -> Result< - (Self::Balance, Self::Balance, Self::Balance, Self::Balance, Self::Balance, Self::Balance), + (BalanceOf, BalanceOf, BalanceOf, BalanceOf, BalanceOf, BalanceOf), DispatchError, > { ensure!( @@ -1866,35 +1976,41 @@ impl PreValidateSwaps for Pallet { let sold_asset_amount = Pallet::::calculate_buy_price(input_reserve, output_reserve, bought_asset_amount)?; - let buy_and_burn_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let buy_and_burn_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::BuyAndBurnFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let treasury_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let treasury_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::TreasuryFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let pool_fee_amount = multiply_by_rational_with_rounding( - sold_asset_amount, + let pool_fee_amount: BalanceOf = multiply_by_rational_with_rounding( + sold_asset_amount.into(), T::PoolFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; // for future implementation of min fee if necessary // let min_fee: u128 = 0; @@ -1904,13 +2020,13 @@ impl PreValidateSwaps for Pallet { // pool_fee_amount = min_fee - buy_and_burn_amount - treasury_amount; // } - ensure!(input_reserve.checked_add(sold_asset_amount).is_some(), Error::::MathOverflow); + ensure!(input_reserve.checked_add(&sold_asset_amount).is_some(), Error::::MathOverflow); // Ensure user has enough tokens to sell ::Currency::ensure_can_withdraw( sold_asset_id.into(), sender, - sold_asset_amount.into(), + sold_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -1929,19 +2045,19 @@ impl PreValidateSwaps for Pallet { /// We only validate the first atomic swap's ability to accept fees fn pre_validate_multiswap_buy_asset( - sender: &Self::AccountId, - swap_token_list: Vec, - final_bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, + sender: &T::AccountId, + swap_token_list: Vec>, + final_bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, ) -> Result< ( - Self::Balance, - Self::Balance, - Self::Balance, - Self::Balance, - Self::Balance, - Self::CurrencyId, - Self::CurrencyId, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + CurrencyIdOf, + CurrencyIdOf, ), DispatchError, > { @@ -1967,7 +2083,7 @@ impl PreValidateSwaps for Pallet { ); // Cannot use multiswap twice on the same pool - let atomic_pairs: Vec<(TokenId, TokenId)> = swap_token_list + let atomic_pairs: Vec<(CurrencyIdOf, CurrencyIdOf)> = swap_token_list .clone() .into_iter() .zip(swap_token_list.clone().into_iter().skip(1)) @@ -1997,48 +2113,54 @@ impl PreValidateSwaps for Pallet { let (input_reserve, output_reserve) = Pallet::::get_reserves(sold_asset_id, bought_asset_id)?; - let buy_and_burn_amount = multiply_by_rational_with_rounding( - max_amount_in, + let buy_and_burn_amount: BalanceOf = multiply_by_rational_with_rounding( + max_amount_in.into(), T::BuyAndBurnFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let treasury_amount = multiply_by_rational_with_rounding( - max_amount_in, + let treasury_amount: BalanceOf = multiply_by_rational_with_rounding( + max_amount_in.into(), T::TreasuryFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; - let pool_fee_amount = multiply_by_rational_with_rounding( - max_amount_in, + let pool_fee_amount: BalanceOf = multiply_by_rational_with_rounding( + max_amount_in.into(), T::PoolFeePercentage::get(), 10000, Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or(Error::::MathOverflow)?; + .ok_or(Error::::MathOverflow)? + .try_into() + .map_err(|_| Error::::MathOverflow)?; let total_fees = buy_and_burn_amount - .checked_add(treasury_amount) - .and_then(|v| v.checked_add(pool_fee_amount)) + .checked_add(&treasury_amount) + .and_then(|v| v.checked_add(&pool_fee_amount)) .ok_or(Error::::MathOverflow)?; - ensure!(input_reserve.checked_add(pool_fee_amount).is_some(), Error::::MathOverflow); + ensure!(input_reserve.checked_add(&pool_fee_amount).is_some(), Error::::MathOverflow); // Ensure user has enough tokens to sell ::Currency::ensure_can_withdraw( sold_asset_id.into(), sender, - total_fees.into(), + total_fees, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -2057,17 +2179,13 @@ impl PreValidateSwaps for Pallet { } } -impl XykFunctionsTrait for Pallet { - type Balance = Balance; - - type CurrencyId = TokenId; - +impl XykFunctionsTrait, CurrencyIdOf> for Pallet { fn create_pool( sender: T::AccountId, - first_asset_id: Self::CurrencyId, - first_asset_amount: Self::Balance, - second_asset_id: Self::CurrencyId, - second_asset_amount: Self::Balance, + first_asset_id: CurrencyIdOf, + first_asset_amount: BalanceOf, + second_asset_id: CurrencyIdOf, + second_asset_amount: BalanceOf, ) -> DispatchResult { let vault: T::AccountId = Pallet::::account_id(); @@ -2094,7 +2212,7 @@ impl XykFunctionsTrait for Pallet { ::Currency::ensure_can_withdraw( first_asset_id.into(), &sender, - first_asset_amount.into(), + first_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -2104,7 +2222,7 @@ impl XykFunctionsTrait for Pallet { ::Currency::ensure_can_withdraw( second_asset_id.into(), &sender, - second_asset_amount.into(), + second_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -2130,7 +2248,7 @@ impl XykFunctionsTrait for Pallet { first_asset_id.into(), &sender, &vault, - first_asset_amount.into(), + first_asset_amount, ExistenceRequirement::AllowDeath, )?; @@ -2138,13 +2256,13 @@ impl XykFunctionsTrait for Pallet { second_asset_id.into(), &sender, &vault, - second_asset_amount.into(), + second_asset_amount, ExistenceRequirement::AllowDeath, )?; // Creating new liquidity token and transfering it to user - let liquidity_asset_id: Self::CurrencyId = - ::Currency::create(&sender, initial_liquidity.into()) + let liquidity_asset_id: CurrencyIdOf = + ::Currency::create(&sender, initial_liquidity) .map_err(|_| Error::::LiquidityTokenCreationFailed)? .into(); @@ -2154,7 +2272,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "create_pool: ({:?}, {}, {}, {}, {}) -> ({}, {})", + "create_pool: ({:?}, {:?}, {:?}, {:?}, {:?}) -> ({:?}, {:?})", sender, first_asset_id, first_asset_amount, @@ -2166,7 +2284,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "pool-state: [({}, {}) -> {}, ({}, {}) -> {}]", + "pool-state: [({:?}, {:?}) -> {:?}, ({:?}, {:?}) -> {:?}]", first_asset_id, second_asset_id, first_asset_amount, @@ -2196,12 +2314,12 @@ impl XykFunctionsTrait for Pallet { // in which case again the user must not be charged the swap fee. fn sell_asset( sender: T::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + sold_asset_amount: BalanceOf, + min_amount_out: BalanceOf, err_upon_bad_slippage: bool, - ) -> Result { + ) -> Result, DispatchError> { let ( buy_and_burn_amount, treasury_amount, @@ -2209,7 +2327,7 @@ impl XykFunctionsTrait for Pallet { input_reserve, output_reserve, bought_asset_amount, - ) = as PreValidateSwaps>::pre_validate_sell_asset( + ) = as PreValidateSwaps, CurrencyIdOf>>::pre_validate_sell_asset( &sender, sold_asset_id, bought_asset_id, @@ -2226,7 +2344,7 @@ impl XykFunctionsTrait for Pallet { sold_asset_id.into(), &sender, &vault, - pool_fee_amount.into(), + pool_fee_amount, ExistenceRequirement::KeepAlive, )?; @@ -2234,7 +2352,7 @@ impl XykFunctionsTrait for Pallet { sold_asset_id.into(), &sender, &treasury_account, - treasury_amount.into(), + treasury_amount, ExistenceRequirement::KeepAlive, )?; @@ -2242,7 +2360,7 @@ impl XykFunctionsTrait for Pallet { sold_asset_id.into(), &sender, &bnb_treasury_account, - buy_and_burn_amount.into(), + buy_and_burn_amount, ExistenceRequirement::KeepAlive, )?; @@ -2262,15 +2380,14 @@ impl XykFunctionsTrait for Pallet { sold_asset_id.into(), &sender, &vault, - (sold_asset_amount + sold_asset_amount .checked_sub( - buy_and_burn_amount - .checked_add(treasury_amount) - .and_then(|v| v.checked_add(pool_fee_amount)) + &buy_and_burn_amount + .checked_add(&treasury_amount) + .and_then(|v| v.checked_add(&pool_fee_amount)) .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?, ) - .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?) - .into(), + .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?, ExistenceRequirement::KeepAlive, )?; @@ -2278,7 +2395,7 @@ impl XykFunctionsTrait for Pallet { bought_asset_id.into(), &vault, &sender, - bought_asset_amount.into(), + bought_asset_amount, ExistenceRequirement::KeepAlive, )?; @@ -2287,8 +2404,8 @@ impl XykFunctionsTrait for Pallet { // Won't overflow due to earlier ensure let input_reserve_updated = input_reserve.saturating_add( sold_asset_amount - .checked_sub(treasury_amount) - .and_then(|v| v.checked_sub(buy_and_burn_amount)) + .checked_sub(&treasury_amount) + .and_then(|v| v.checked_sub(&buy_and_burn_amount)) .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?, ); let output_reserve_updated = output_reserve.saturating_sub(bought_asset_amount); @@ -2303,7 +2420,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "sell_asset: ({:?}, {}, {}, {}, {}) -> {}", + "sell_asset: ({:?}, {:?}, {:?}, {:?}, {:?}) -> {:?}", sender, sold_asset_id, bought_asset_id, @@ -2314,7 +2431,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "pool-state: [({}, {}) -> {}, ({}, {}) -> {}]", + "pool-state: [({:?}, {:?}) -> {:?}, ({:?}, {:?}) -> {:?}]", sold_asset_id, bought_asset_id, input_reserve_updated, @@ -2355,40 +2472,44 @@ impl XykFunctionsTrait for Pallet { fn do_multiswap_sell_asset( sender: T::AccountId, - swap_token_list: Vec, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, - ) -> Result { - frame_support::storage::with_storage_layer(|| -> Result { + swap_token_list: Vec>, + sold_asset_amount: BalanceOf, + min_amount_out: BalanceOf, + ) -> Result, DispatchError> { + frame_support::storage::with_storage_layer(|| -> Result, DispatchError> { // Ensure user has enough tokens to sell ::Currency::ensure_can_withdraw( // Naked unwrap is fine due to pre validation len check { *swap_token_list.get(0).ok_or(Error::::MultiswapShouldBeAtleastTwoHops)? } .into(), &sender, - sold_asset_amount.into(), + sold_asset_amount, WithdrawReasons::all(), Default::default(), ) .or(Err(Error::::NotEnoughAssets))?; // pre_validate has already confirmed that swap_token_list.len()>1 - let atomic_pairs: Vec<(TokenId, TokenId)> = swap_token_list + let atomic_pairs: Vec<(CurrencyIdOf, CurrencyIdOf)> = swap_token_list .clone() .into_iter() .zip(swap_token_list.clone().into_iter().skip(1)) .collect(); let mut atomic_sold_asset_amount = sold_asset_amount; - let mut atomic_bought_asset_amount = Balance::zero(); + let mut atomic_bought_asset_amount = BalanceOf::::zero(); for (atomic_sold_asset, atomic_bought_asset) in atomic_pairs.iter() { - atomic_bought_asset_amount = >::sell_asset( + atomic_bought_asset_amount = , + CurrencyIdOf, + >>::sell_asset( sender.clone(), *atomic_sold_asset, *atomic_bought_asset, atomic_sold_asset_amount, - Balance::zero(), + BalanceOf::::zero(), // We using most possible slippage so this should be irrelevant true, )?; @@ -2408,12 +2529,12 @@ impl XykFunctionsTrait for Pallet { fn multiswap_sell_asset( sender: T::AccountId, - swap_token_list: Vec, - sold_asset_amount: Self::Balance, - min_amount_out: Self::Balance, - err_upon_bad_slippage: bool, - err_upon_non_slippage_fail: bool, - ) -> Result { + swap_token_list: Vec>, + sold_asset_amount: BalanceOf, + min_amount_out: BalanceOf, + _err_upon_bad_slippage: bool, + _err_upon_non_slippage_fail: bool, + ) -> Result, DispatchError> { let ( fee_swap_buy_and_burn_amount, fee_swap_treasury_amount, @@ -2422,7 +2543,7 @@ impl XykFunctionsTrait for Pallet { fee_swap_output_reserve, fee_swap_sold_asset_id, fee_swap_bought_asset_id, - ) = as PreValidateSwaps>::pre_validate_multiswap_sell_asset( + ) = as PreValidateSwaps, CurrencyIdOf>>::pre_validate_multiswap_sell_asset( &sender, swap_token_list.clone(), sold_asset_amount, @@ -2432,7 +2553,7 @@ impl XykFunctionsTrait for Pallet { // First execute all atomic swaps in a storage layer // And then the finally bought amount is compared // The bool in error represents if the fail is due to bad final slippage - match >::do_multiswap_sell_asset( + match , CurrencyIdOf>>::do_multiswap_sell_asset( sender.clone(), swap_token_list.clone(), sold_asset_amount, @@ -2456,26 +2577,26 @@ impl XykFunctionsTrait for Pallet { // Transfer of fees, before tx can fail on min amount out ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &vault, - fee_swap_pool_fee_amount.into(), + fee_swap_pool_fee_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &treasury_account, - fee_swap_treasury_amount.into(), + fee_swap_treasury_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &bnb_treasury_account, - fee_swap_buy_and_burn_amount.into(), + fee_swap_buy_and_burn_amount, ExistenceRequirement::KeepAlive, )?; @@ -2518,12 +2639,12 @@ impl XykFunctionsTrait for Pallet { // in which case again the user must not be charged the swap fee. fn buy_asset( sender: T::AccountId, - sold_asset_id: Self::CurrencyId, - bought_asset_id: Self::CurrencyId, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, + sold_asset_id: CurrencyIdOf, + bought_asset_id: CurrencyIdOf, + bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, err_upon_bad_slippage: bool, - ) -> Result { + ) -> Result, DispatchError> { let ( buy_and_burn_amount, treasury_amount, @@ -2531,7 +2652,7 @@ impl XykFunctionsTrait for Pallet { input_reserve, output_reserve, sold_asset_amount, - ) = as PreValidateSwaps>::pre_validate_buy_asset( + ) = as PreValidateSwaps, CurrencyIdOf>>::pre_validate_buy_asset( &sender, sold_asset_id, bought_asset_id, @@ -2545,26 +2666,26 @@ impl XykFunctionsTrait for Pallet { // Transfer of fees, before tx can fail on min amount out ::Currency::transfer( - sold_asset_id.into(), + sold_asset_id, &sender, &vault, - pool_fee_amount.into(), + pool_fee_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - sold_asset_id.into(), + sold_asset_id, &sender, &treasury_account, - treasury_amount.into(), + treasury_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - sold_asset_id.into(), + sold_asset_id, &sender, &bnb_treasury_account, - buy_and_burn_amount.into(), + buy_and_burn_amount, ExistenceRequirement::KeepAlive, )?; @@ -2585,20 +2706,19 @@ impl XykFunctionsTrait for Pallet { &vault, sold_asset_amount .checked_sub( - buy_and_burn_amount - .checked_add(treasury_amount) - .and_then(|v| v.checked_add(pool_fee_amount)) + &buy_and_burn_amount + .checked_add(&treasury_amount) + .and_then(|v| v.checked_add(&pool_fee_amount)) .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?, ) - .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))? - .into(), + .ok_or_else(|| DispatchError::from(Error::::SoldAmountTooLow))?, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - bought_asset_id.into(), + bought_asset_id, &vault, &sender, - bought_asset_amount.into(), + bought_asset_amount, ExistenceRequirement::KeepAlive, )?; @@ -2607,8 +2727,8 @@ impl XykFunctionsTrait for Pallet { // Won't overflow due to earlier ensure let input_reserve_updated = input_reserve.saturating_add( sold_asset_amount - .checked_sub(treasury_amount) - .and_then(|v| v.checked_sub(buy_and_burn_amount)) + .checked_sub(&treasury_amount) + .and_then(|v| v.checked_sub(&buy_and_burn_amount)) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?, ); @@ -2622,7 +2742,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "buy_asset: ({:?}, {}, {}, {}, {}) -> {}", + "buy_asset: ({:?}, {:?}, {:?}, {:?}, {:?}) -> {:?}", sender, sold_asset_id, bought_asset_id, @@ -2633,7 +2753,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "pool-state: [({}, {}) -> {}, ({}, {}) -> {}]", + "pool-state: [({:?}, {:?}) -> {:?}, ({:?}, {:?}) -> {:?}]", sold_asset_id, bought_asset_id, input_reserve_updated, @@ -2672,22 +2792,22 @@ impl XykFunctionsTrait for Pallet { fn do_multiswap_buy_asset( sender: T::AccountId, - swap_token_list: Vec, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, - ) -> Result { - frame_support::storage::with_storage_layer(|| -> Result { + swap_token_list: Vec>, + bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, + ) -> Result, DispatchError> { + frame_support::storage::with_storage_layer(|| -> Result, DispatchError> { // pre_validate has already confirmed that swap_token_list.len()>1 - let atomic_pairs: Vec<(TokenId, TokenId)> = swap_token_list + let atomic_pairs: Vec<(CurrencyIdOf, CurrencyIdOf)> = swap_token_list .clone() .into_iter() .zip(swap_token_list.clone().into_iter().skip(1)) .collect(); - let mut atomic_sold_asset_amount = Balance::zero(); + let mut atomic_sold_asset_amount = BalanceOf::::zero(); let mut atomic_bought_asset_amount = bought_asset_amount; - let mut atomic_swap_buy_amounts_rev: Vec = Default::default(); + let mut atomic_swap_buy_amounts_rev: Vec> = Default::default(); // Calc // We can do this using calculate_buy_price_id chain due to the check in pre_validation // that ensures that no pool is touched twice. So the reserves in question are consistent @@ -2711,7 +2831,7 @@ impl XykFunctionsTrait for Pallet { { *swap_token_list.get(0).ok_or(Error::::MultiswapShouldBeAtleastTwoHops)? } .into(), &sender, - atomic_sold_asset_amount.into(), + atomic_sold_asset_amount, WithdrawReasons::all(), Default::default(), ) @@ -2721,12 +2841,12 @@ impl XykFunctionsTrait for Pallet { for ((atomic_sold_asset, atomic_bought_asset), atomic_swap_buy_amount) in atomic_pairs.iter().zip(atomic_swap_buy_amounts_rev.iter().rev()) { - let _ = >::buy_asset( + let _ = , CurrencyIdOf>>::buy_asset( sender.clone(), *atomic_sold_asset, *atomic_bought_asset, *atomic_swap_buy_amount, - Balance::max_value(), + BalanceOf::::max_value(), // We using most possible slippage so this should be irrelevant true, )?; @@ -2738,12 +2858,12 @@ impl XykFunctionsTrait for Pallet { fn multiswap_buy_asset( sender: T::AccountId, - swap_token_list: Vec, - bought_asset_amount: Self::Balance, - max_amount_in: Self::Balance, + swap_token_list: Vec>, + bought_asset_amount: BalanceOf, + max_amount_in: BalanceOf, _err_upon_bad_slippage: bool, _err_upon_non_slippage_fail: bool, - ) -> Result { + ) -> Result, DispatchError> { let ( fee_swap_buy_and_burn_amount, fee_swap_treasury_amount, @@ -2752,7 +2872,7 @@ impl XykFunctionsTrait for Pallet { fee_swap_output_reserve, fee_swap_sold_asset_id, fee_swap_bought_asset_id, - ) = as PreValidateSwaps>::pre_validate_multiswap_buy_asset( + ) = as PreValidateSwaps, CurrencyIdOf>>::pre_validate_multiswap_buy_asset( &sender, swap_token_list.clone(), bought_asset_amount, @@ -2762,7 +2882,7 @@ impl XykFunctionsTrait for Pallet { // First execute all atomic swaps in a storage layer // And then the finally sold amount is compared // The bool in error represents if the fail is due to bad final slippage - match >::do_multiswap_buy_asset( + match , CurrencyIdOf>>::do_multiswap_buy_asset( sender.clone(), swap_token_list.clone(), bought_asset_amount, @@ -2784,26 +2904,26 @@ impl XykFunctionsTrait for Pallet { // Transfer of fees, before tx can fail on min amount out ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &vault, - fee_swap_pool_fee_amount.into(), + fee_swap_pool_fee_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &treasury_account, - fee_swap_treasury_amount.into(), + fee_swap_treasury_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - fee_swap_sold_asset_id.into(), + fee_swap_sold_asset_id, &sender, &bnb_treasury_account, - fee_swap_buy_and_burn_amount.into(), + fee_swap_buy_and_burn_amount, ExistenceRequirement::KeepAlive, )?; @@ -2840,12 +2960,12 @@ impl XykFunctionsTrait for Pallet { fn mint_liquidity( sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - first_asset_amount: Self::Balance, - expected_second_asset_amount: Self::Balance, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + first_asset_amount: BalanceOf, + expected_second_asset_amount: BalanceOf, activate_minted_liquidity: bool, - ) -> Result<(Self::CurrencyId, Self::Balance), DispatchError> { + ) -> Result<(CurrencyIdOf, BalanceOf), DispatchError> { let vault = Pallet::::account_id(); // Ensure pool exists @@ -2861,8 +2981,8 @@ impl XykFunctionsTrait for Pallet { // Get token reserves let (first_asset_reserve, second_asset_reserve) = Pallet::::get_reserves(first_asset_id, second_asset_id)?; - let total_liquidity_assets: Self::Balance = - ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_assets: BalanceOf = + ::Currency::total_issuance(liquidity_asset_id.into()); // The pool is empty and we are basically creating a new pool and reusing the existing one let second_asset_amount = if !(first_asset_reserve.is_zero() && @@ -2873,14 +2993,16 @@ impl XykFunctionsTrait for Pallet { ensure!(!first_asset_reserve.is_zero(), Error::::DivisionByZero); multiply_by_rational_with_rounding( - first_asset_amount, - second_asset_reserve, - first_asset_reserve, + first_asset_amount.into(), + second_asset_reserve.into(), + first_asset_reserve.into(), Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))? } else { expected_second_asset_amount }; @@ -2901,12 +3023,14 @@ impl XykFunctionsTrait for Pallet { Pallet::::calculate_initial_liquidity(first_asset_amount, second_asset_amount)? } else { multiply_by_rational_with_rounding( - first_asset_amount, - total_liquidity_assets, - first_asset_reserve, + first_asset_amount.into(), + total_liquidity_assets.into(), + first_asset_reserve.into(), Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))? }; // Ensure user has enough withdrawable tokens to create pool in amounts required @@ -2914,7 +3038,7 @@ impl XykFunctionsTrait for Pallet { ::Currency::ensure_can_withdraw( first_asset_id.into(), &sender, - first_asset_amount.into(), + first_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -2922,9 +3046,9 @@ impl XykFunctionsTrait for Pallet { .or(Err(Error::::NotEnoughAssets))?; ::Currency::ensure_can_withdraw( - second_asset_id.into(), + second_asset_id, &sender, - second_asset_amount.into(), + second_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -2933,33 +3057,36 @@ impl XykFunctionsTrait for Pallet { // Transfer of token amounts from user to vault ::Currency::transfer( - first_asset_id.into(), + first_asset_id, &sender, &vault, - first_asset_amount.into(), + first_asset_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - second_asset_id.into(), + second_asset_id, &sender, &vault, - second_asset_amount.into(), + second_asset_amount, ExistenceRequirement::KeepAlive, )?; // Creating new liquidity tokens to user - ::Currency::mint( - liquidity_asset_id.into(), - &sender, - liquidity_assets_minted.into(), - )?; + ::Currency::mint(liquidity_asset_id, &sender, liquidity_assets_minted)?; - if >::is_enabled( - liquidity_asset_id, - ) && activate_minted_liquidity + if , + CurrencyIdOf, + >>::is_enabled(liquidity_asset_id) && + activate_minted_liquidity { // The reserve from free_balance will not fail the asset were just minted into free_balance - >::activate_liquidity( + , + CurrencyIdOf, + >>::activate_liquidity( sender.clone(), liquidity_asset_id, liquidity_assets_minted, @@ -2980,7 +3107,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "mint_liquidity: ({:?}, {}, {}, {}) -> ({}, {}, {})", + "mint_liquidity: ({:?}, {:?}, {:?}, {:?}) -> ({:?}, {:?}, {:?})", sender, first_asset_id, second_asset_id, @@ -2992,7 +3119,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "pool-state: [({}, {}) -> {}, ({}, {}) -> {}]", + "pool-state: [({:?}, {:?}) -> {:?}, ({:?}, {:?}) -> {:?}]", first_asset_id, second_asset_id, first_asset_reserve_updated, @@ -3016,7 +3143,7 @@ impl XykFunctionsTrait for Pallet { fn do_compound_rewards( sender: T::AccountId, - liquidity_asset_id: TokenId, + liquidity_asset_id: CurrencyIdOf, amount_permille: Permill, ) -> DispatchResult { let (first_asset_id, second_asset_id) = @@ -3028,7 +3155,7 @@ impl XykFunctionsTrait for Pallet { Error::::FunctionNotAvailableForThisToken ); - let rewards_id: TokenId = Self::native_token_id(); + let rewards_id: CurrencyIdOf = Self::native_token_id(); ensure!( first_asset_id == rewards_id || second_asset_id == rewards_id, Error::::FunctionNotAvailableForThisToken @@ -3036,15 +3163,19 @@ impl XykFunctionsTrait for Pallet { let rewards_claimed = , + CurrencyIdOf, >>::claim_rewards_all(sender.clone(), liquidity_asset_id)?; - let rewards_256 = Into::::into(rewards_claimed) + let rewards_256 = U256::from(rewards_claimed.into()) .saturating_mul(amount_permille.deconstruct().into()) .div(Permill::one().deconstruct()); - let rewards = Balance::try_from(rewards_256) + let rewards_128 = u128::try_from(rewards_256) + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + let rewards = BalanceOf::::try_from(rewards_128) .map_err(|_| DispatchError::from(Error::::MathOverflow))?; - >::provide_liquidity_with_conversion( + , CurrencyIdOf>>::provide_liquidity_with_conversion( sender, first_asset_id, second_asset_id, @@ -3058,12 +3189,12 @@ impl XykFunctionsTrait for Pallet { fn provide_liquidity_with_conversion( sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - provided_asset_id: Self::CurrencyId, - provided_asset_amount: Self::Balance, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + provided_asset_id: CurrencyIdOf, + provided_asset_amount: BalanceOf, activate_minted_liquidity: bool, - ) -> Result<(Self::CurrencyId, Self::Balance), DispatchError> { + ) -> Result<(CurrencyIdOf, BalanceOf), DispatchError> { // checks ensure!(!provided_asset_amount.is_zero(), Error::::ZeroAmount,); @@ -3082,9 +3213,9 @@ impl XykFunctionsTrait for Pallet { // Ensure user has enough tokens to sell ::Currency::ensure_can_withdraw( - provided_asset_id.into(), + provided_asset_id, &sender, - provided_asset_amount.into(), + provided_asset_amount, WithdrawReasons::all(), // Does not fail due to earlier ensure Default::default(), @@ -3097,22 +3228,23 @@ impl XykFunctionsTrait for Pallet { let bought_amount = Pallet::::calculate_sell_price(reserve, other_reserve, swap_amount)?; - let _ = >::sell_asset( - sender.clone(), - provided_asset_id, - other_asset_id, - swap_amount, - bought_amount, - true, - )?; + let _ = + , CurrencyIdOf>>::sell_asset( + sender.clone(), + provided_asset_id, + other_asset_id, + swap_amount, + bought_amount, + true, + )?; let mint_amount = provided_asset_amount - .checked_sub(swap_amount) + .checked_sub(&swap_amount) .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; log!( info, - "provide_liquidity_with_conversion: ({:?}, {}, {}, {}, {}) -> ({}, {})", + "provide_liquidity_with_conversion: ({:?}, {:?}, {:?}, {:?}, {:?}) -> ({:?}, {:?})", sender, first_asset_id, second_asset_id, @@ -3125,21 +3257,21 @@ impl XykFunctionsTrait for Pallet { // we swap the order of the pairs to handle rounding // we spend all of the Y // and have some surplus amount of X that equals to the rounded part of Y - >::mint_liquidity( + , CurrencyIdOf>>::mint_liquidity( sender, other_asset_id, provided_asset_id, bought_amount, - Self::Balance::MAX, + BalanceOf::::max_value(), activate_minted_liquidity, ) } fn burn_liquidity( sender: T::AccountId, - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - liquidity_asset_amount: Self::Balance, + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + liquidity_asset_amount: BalanceOf, ) -> DispatchResult { let vault = Pallet::::account_id(); @@ -3164,11 +3296,11 @@ impl XykFunctionsTrait for Pallet { // Ensure user has enought liquidity tokens to burn let liquidity_token_available_balance = - ::Currency::available_balance(liquidity_asset_id.into(), &sender).into(); + ::Currency::available_balance(liquidity_asset_id.into(), &sender); ensure!( liquidity_token_available_balance - .checked_add(max_instant_unreserve_amount) + .checked_add(&max_instant_unreserve_amount) .ok_or(Error::::MathOverflow)? >= liquidity_asset_amount, Error::::NotEnoughAssets, @@ -3183,11 +3315,11 @@ impl XykFunctionsTrait for Pallet { liquidity_asset_amount.saturating_sub(liquidity_token_available_balance); // deactivate liquidity - >::deactivate_liquidity( - sender.clone(), - liquidity_asset_id, - to_be_deactivated, - )?; + , + CurrencyIdOf, + >>::deactivate_liquidity(sender.clone(), liquidity_asset_id, to_be_deactivated)?; // Calculate first and second token amounts depending on liquidity amount to burn let (first_asset_amount, second_asset_amount) = Pallet::::get_burn_amount_reserves( @@ -3197,8 +3329,8 @@ impl XykFunctionsTrait for Pallet { liquidity_asset_amount, )?; - let total_liquidity_assets: Balance = - ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_assets: BalanceOf = + ::Currency::total_issuance(liquidity_asset_id.into()); // If all liquidity assets are being burned then // both asset amounts must be equal to their reserve values @@ -3227,23 +3359,23 @@ impl XykFunctionsTrait for Pallet { // Transfer withdrawn amounts from vault to user ::Currency::transfer( - first_asset_id.into(), + first_asset_id, &vault, &sender, - first_asset_amount.into(), + first_asset_amount, ExistenceRequirement::KeepAlive, )?; ::Currency::transfer( - second_asset_id.into(), + second_asset_id, &vault, &sender, - second_asset_amount.into(), + second_asset_amount, ExistenceRequirement::KeepAlive, )?; log!( info, - "burn_liquidity: ({:?}, {}, {}, {}) -> ({}, {})", + "burn_liquidity: ({:?}, {:?}, {:?}, {:?}) -> ({:?}, {:?})", sender, first_asset_id, second_asset_id, @@ -3256,13 +3388,18 @@ impl XykFunctionsTrait for Pallet { if liquidity_asset_amount == total_liquidity_assets { log!( info, - "pool-state: [({}, {}) -> Removed, ({}, {}) -> Removed]", + "pool-state: [({:?}, {:?}) -> Removed, ({:?}, {:?}) -> Removed]", first_asset_id, second_asset_id, second_asset_id, first_asset_id, ); - Pallet::::set_reserves(first_asset_id, 0, second_asset_id, 0)?; + Pallet::::set_reserves( + first_asset_id, + BalanceOf::::zero(), + second_asset_id, + BalanceOf::::zero(), + )?; } else { // Apply changes in token pools, removing withdrawn amounts // Cannot underflow due to earlier ensure @@ -3280,7 +3417,7 @@ impl XykFunctionsTrait for Pallet { log!( info, - "pool-state: [({}, {}) -> {}, ({}, {}) -> {}]", + "pool-state: [({:?}, {:?}) -> {:?}, ({:?}, {:?}) -> {:?}]", first_asset_id, second_asset_id, first_asset_reserve_updated, @@ -3295,7 +3432,7 @@ impl XykFunctionsTrait for Pallet { ::Currency::burn_and_settle( liquidity_asset_id.into(), &sender, - liquidity_asset_amount.into(), + liquidity_asset_amount, )?; Pallet::::deposit_event(Event::LiquidityBurned( @@ -3313,39 +3450,44 @@ impl XykFunctionsTrait for Pallet { // This function has not been verified fn get_tokens_required_for_minting( - liquidity_asset_id: Self::CurrencyId, - liquidity_token_amount: Self::Balance, - ) -> Result<(Self::CurrencyId, Self::Balance, Self::CurrencyId, Self::Balance), DispatchError> { + liquidity_asset_id: CurrencyIdOf, + liquidity_token_amount: BalanceOf, + ) -> Result<(CurrencyIdOf, BalanceOf, CurrencyIdOf, BalanceOf), DispatchError> { let (first_asset_id, second_asset_id) = LiquidityPools::::get(liquidity_asset_id).ok_or(Error::::NoSuchLiquidityAsset)?; let (first_asset_reserve, second_asset_reserve) = Pallet::::get_reserves(first_asset_id, second_asset_id)?; - let total_liquidity_assets: Balance = - ::Currency::total_issuance(liquidity_asset_id.into()).into(); + let total_liquidity_assets: BalanceOf = + ::Currency::total_issuance(liquidity_asset_id.into()); ensure!(!total_liquidity_assets.is_zero(), Error::::DivisionByZero); - let second_asset_amount = multiply_by_rational_with_rounding( - liquidity_token_amount, - second_asset_reserve, - total_liquidity_assets, + let second_asset_amount: BalanceOf = multiply_by_rational_with_rounding( + liquidity_token_amount.into(), + second_asset_reserve.into(), + total_liquidity_assets.into(), Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; - let first_asset_amount = multiply_by_rational_with_rounding( - liquidity_token_amount, - first_asset_reserve, - total_liquidity_assets, + .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; + + let first_asset_amount: BalanceOf = multiply_by_rational_with_rounding( + liquidity_token_amount.into(), + first_asset_reserve.into(), + total_liquidity_assets.into(), Rounding::Down, ) .ok_or(Error::::UnexpectedFailure)? .checked_add(1) - .ok_or_else(|| DispatchError::from(Error::::MathOverflow))?; + .ok_or_else(|| DispatchError::from(Error::::MathOverflow))? + .try_into() + .map_err(|_| DispatchError::from(Error::::MathOverflow))?; log!( info, - "get_tokens_required_for_minting: ({}, {}) -> ({}, {}, {}, {})", + "get_tokens_required_for_minting: ({:?}, {:?}) -> ({:?}, {:?}, {:?}, {:?})", liquidity_asset_id, liquidity_token_amount, first_asset_id, @@ -3357,35 +3499,31 @@ impl XykFunctionsTrait for Pallet { Ok((first_asset_id, first_asset_amount, second_asset_id, second_asset_amount)) } - fn is_liquidity_token(liquidity_asset_id: TokenId) -> bool { + fn is_liquidity_token(liquidity_asset_id: CurrencyIdOf) -> bool { LiquidityPools::::get(liquidity_asset_id).is_some() } } -pub trait AssetMetadataMutationTrait { +pub trait AssetMetadataMutationTrait { fn set_asset_info( - asset: TokenId, + asset: CurrencyId, name: Vec, symbol: Vec, decimals: u32, ) -> DispatchResult; } -impl Valuate for Pallet { - type Balance = Balance; - - type CurrencyId = TokenId; - +impl Valuate, CurrencyIdOf> for Pallet { fn get_liquidity_asset( - first_asset_id: Self::CurrencyId, - second_asset_id: Self::CurrencyId, - ) -> Result { + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + ) -> Result, DispatchError> { Pallet::::get_liquidity_asset(first_asset_id, second_asset_id) } fn get_liquidity_token_mga_pool( - liquidity_token_id: Self::CurrencyId, - ) -> Result<(Self::CurrencyId, Self::CurrencyId), DispatchError> { + liquidity_token_id: CurrencyIdOf, + ) -> Result<(CurrencyIdOf, CurrencyIdOf), DispatchError> { let (first_token_id, second_token_id) = LiquidityPools::::get(liquidity_token_id).ok_or(Error::::NoSuchLiquidityAsset)?; let native_currency_id = Self::native_token_id(); @@ -3397,9 +3535,9 @@ impl Valuate for Pallet { } fn valuate_liquidity_token( - liquidity_token_id: Self::CurrencyId, - liquidity_token_amount: Self::Balance, - ) -> Self::Balance { + liquidity_token_id: CurrencyIdOf, + liquidity_token_amount: BalanceOf, + ) -> BalanceOf { let (mga_token_id, other_token_id) = match Self::get_liquidity_token_mga_pool(liquidity_token_id) { Ok(pool) => pool, @@ -3411,43 +3549,43 @@ impl Valuate for Pallet { Err(_) => return Default::default(), }; - let liquidity_token_reserve: Balance = - ::Currency::total_issuance(liquidity_token_id.into()).into(); + let liquidity_token_reserve: BalanceOf = + ::Currency::total_issuance(liquidity_token_id.into()); if liquidity_token_reserve.is_zero() { return Default::default() } multiply_by_rational_with_rounding( - mga_token_reserve, - liquidity_token_amount, - liquidity_token_reserve, + mga_token_reserve.into(), + liquidity_token_amount.into(), + liquidity_token_reserve.into(), Rounding::Down, ) - .unwrap_or(Balance::max_value()) + .map(SaturatedConversion::saturated_into) + .unwrap_or(BalanceOf::::max_value()) } fn scale_liquidity_by_mga_valuation( - mga_valuation: Self::Balance, - liquidity_token_amount: Self::Balance, - mga_token_amount: Self::Balance, - ) -> Self::Balance { + mga_valuation: BalanceOf, + liquidity_token_amount: BalanceOf, + mga_token_amount: BalanceOf, + ) -> BalanceOf { if mga_valuation.is_zero() { return Default::default() } multiply_by_rational_with_rounding( - liquidity_token_amount, - mga_token_amount, - mga_valuation, + liquidity_token_amount.into(), + mga_token_amount.into(), + mga_valuation.into(), Rounding::Down, ) - .unwrap_or(Balance::max_value()) + .map(SaturatedConversion::saturated_into) + .unwrap_or(BalanceOf::::max_value()) } - fn get_pool_state( - liquidity_token_id: Self::CurrencyId, - ) -> Option<(Self::Balance, Self::Balance)> { + fn get_pool_state(liquidity_token_id: CurrencyIdOf) -> Option<(BalanceOf, BalanceOf)> { let (mga_token_id, other_token_id) = match Self::get_liquidity_token_mga_pool(liquidity_token_id) { Ok(pool) => pool, @@ -3459,8 +3597,8 @@ impl Valuate for Pallet { Err(_) => return None, }; - let liquidity_token_reserve: Balance = - ::Currency::total_issuance(liquidity_token_id.into()).into(); + let liquidity_token_reserve: BalanceOf = + ::Currency::total_issuance(liquidity_token_id.into()); if liquidity_token_reserve.is_zero() { return None @@ -3470,28 +3608,26 @@ impl Valuate for Pallet { } fn get_reserves( - first_asset_id: TokenId, - second_asset_id: TokenId, - ) -> Result<(Balance, Balance), DispatchError> { + first_asset_id: CurrencyIdOf, + second_asset_id: CurrencyIdOf, + ) -> Result<(BalanceOf, BalanceOf), DispatchError> { Pallet::::get_reserves(first_asset_id, second_asset_id) } } -impl PoolCreateApi for Pallet { - type AccountId = T::AccountId; - - fn pool_exists(first: TokenId, second: TokenId) -> bool { +impl PoolCreateApi, CurrencyIdOf> for Pallet { + fn pool_exists(first: CurrencyIdOf, second: CurrencyIdOf) -> bool { Pools::::contains_key((first, second)) || Pools::::contains_key((second, first)) } fn pool_create( - account: Self::AccountId, - first: TokenId, - first_amount: Balance, - second: TokenId, - second_amount: Balance, - ) -> Option<(TokenId, Balance)> { - match >::create_pool( + account: T::AccountId, + first: CurrencyIdOf, + first_amount: BalanceOf, + second: CurrencyIdOf, + second_amount: BalanceOf, + ) -> Option<(CurrencyIdOf, BalanceOf)> { + match , CurrencyIdOf>>::create_pool( account, first, first_amount, @@ -3499,7 +3635,7 @@ impl PoolCreateApi for Pallet { second_amount, ) { Ok(_) => LiquidityAssets::::get((first, second)).map(|asset_id| { - (asset_id, ::Currency::total_issuance(asset_id.into()).into()) + (asset_id, ::Currency::total_issuance(asset_id.into())) }), Err(e) => { log!(error, "cannot create pool {:?}!", e); diff --git a/pallets/xyk/src/mock.rs b/pallets/xyk/src/mock.rs index cefb152129..1a84e20637 100644 --- a/pallets/xyk/src/mock.rs +++ b/pallets/xyk/src/mock.rs @@ -2,13 +2,6 @@ use super::*; -use sp_core::H256; - -use sp_runtime::{ - testing::Header, - traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, -}; - use crate as xyk; use frame_support::{ construct_runtime, parameter_types, @@ -17,65 +10,61 @@ use frame_support::{ }, PalletId, }; - use frame_system as system; pub use mangata_support::traits::ProofOfStakeRewardsApi; -use mangata_types::{assets::CustomMetadata, Amount, Balance, TokenId}; +use mangata_types::assets::CustomMetadata; use orml_tokens::{MultiTokenCurrencyAdapter, MultiTokenCurrencyExtended}; use orml_traits::{asset_registry::AssetMetadata, parameter_type_with_key}; -use sp_runtime::{Perbill, Percent}; +use sp_runtime::{traits::AccountIdConversion, BuildStorage, Perbill, Percent}; use std::{collections::HashMap, sync::Mutex}; pub const NATIVE_CURRENCY_ID: u32 = 0; pub(crate) type AccountId = u128; +pub(crate) type Amount = i128; +pub(crate) type Balance = u128; +pub(crate) type TokenId = u32; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config}, - XykStorage: xyk::{Pallet, Call, Storage, Event, Config}, - ProofOfStake: pallet_proof_of_stake::{Pallet, Call, Storage, Event}, - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, - Issuance: pallet_issuance::{Pallet, Event, Storage}, + pub enum Test { + System: frame_system, + Tokens: orml_tokens, + XykStorage: xyk, + ProofOfStake: pallet_proof_of_stake, + Vesting: pallet_vesting_mangata, + Issuance: pallet_issuance, } ); parameter_types! { pub const BlockHashCount: u64 = 250; } -impl system::Config for Test { +impl frame_system::Config for Test { type BaseCallFilter = Everything; type RuntimeOrigin = RuntimeOrigin; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Hashing = BlakeTwo256; + type Hash = sp_runtime::testing::H256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; type RuntimeEvent = RuntimeEvent; + type Block = Block; type BlockHashCount = BlockHashCount; + type BlockWeights = (); + type BlockLength = (); type DbWeight = (); type Version = (); + type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type PalletInfo = PalletInfo; - type BlockWeights = (); - type BlockLength = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } parameter_type_with_key! { @@ -120,6 +109,8 @@ parameter_types! { parameter_types! { pub const MinVestedTransfer: Balance = 0; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting_mangata::Config for Test { @@ -128,6 +119,7 @@ impl pallet_vesting_mangata::Config for Test { type BlockNumberToBalance = sp_runtime::traits::ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting_mangata::weights::SubstrateWeight; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 28; @@ -212,7 +204,7 @@ impl Contains<(TokenId, TokenId)> for DummyBlacklistedPool { pub struct MockAssetRegister; lazy_static::lazy_static! { - static ref ASSET_REGISTER: Mutex>> = { + static ref ASSET_REGISTER: Mutex>>> = { let m = HashMap::new(); Mutex::new(m) }; @@ -220,12 +212,13 @@ lazy_static::lazy_static! { #[cfg(test)] impl MockAssetRegister { - pub fn instance() -> &'static Mutex>> { + pub fn instance( + ) -> &'static Mutex>>> { &ASSET_REGISTER } } -impl AssetMetadataMutationTrait for MockAssetRegister { +impl AssetMetadataMutationTrait for MockAssetRegister { fn set_asset_info( asset: TokenId, name: Vec, @@ -233,8 +226,8 @@ impl AssetMetadataMutationTrait for MockAssetRegister { decimals: u32, ) -> DispatchResult { let meta = AssetMetadata { - name, - symbol, + name: BoundedVec::truncate_from(name), + symbol: BoundedVec::truncate_from(symbol), decimals, location: None, additional: Default::default(), @@ -344,50 +337,48 @@ impl pallet_proof_of_stake::Config for Test { pub struct TokensActivationPassthrough(PhantomData); -impl ActivationReservesProviderTrait for TokensActivationPassthrough +impl ActivationReservesProviderTrait + for TokensActivationPassthrough where - AccountId: From<::AccountId>, + ::Currency: + MultiTokenReservableCurrency, { - type AccountId = T::AccountId; - - fn get_max_instant_unreserve_amount( - token_id: TokenId, - account_id: &Self::AccountId, - ) -> Balance { - let account_id: u128 = (account_id.clone()).into(); - let token_id: u32 = token_id; + fn get_max_instant_unreserve_amount(token_id: TokenId, account_id: &AccountId) -> Balance { ProofOfStake::get_rewards_info(account_id, token_id).activated_amount } fn can_activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> bool { - ::Currency::can_reserve(token_id.into(), account_id, amount.into()) + ::Currency::can_reserve(token_id, account_id, amount) } fn activate( token_id: TokenId, - account_id: &Self::AccountId, + account_id: &AccountId, amount: Balance, _use_balance_from: Option, ) -> DispatchResult { - ::Currency::reserve(token_id.into(), account_id, amount.into()) + ::Currency::reserve(token_id, account_id, amount) } - fn deactivate(token_id: TokenId, account_id: &Self::AccountId, amount: Balance) -> Balance { - ::Currency::unreserve(token_id.into(), account_id, amount.into()) - .into() + fn deactivate(token_id: TokenId, account_id: &AccountId, amount: Balance) -> Balance { + ::Currency::unreserve(token_id, account_id, amount) } } -impl Pallet { - pub fn balance(id: TokenId, who: T::AccountId) -> Balance { +impl Pallet +where + ::Currency: MultiTokenReservableCurrency + + MultiTokenCurrencyExtended, +{ + pub fn balance(id: TokenId, who: AccountId) -> Balance { ::Currency::free_balance(id.into(), &who).into() } - pub fn reserved(id: TokenId, who: T::AccountId) -> Balance { + pub fn reserved(id: TokenId, who: AccountId) -> Balance { ::Currency::reserved_balance(id.into(), &who).into() } pub fn total_supply(id: TokenId) -> Balance { @@ -395,27 +386,24 @@ impl Pallet { } pub fn transfer( currency_id: TokenId, - source: T::AccountId, - dest: T::AccountId, + source: AccountId, + dest: AccountId, value: Balance, ) -> DispatchResult { ::Currency::transfer( - currency_id.into(), + currency_id, &source, &dest, - value.into(), + value, ExistenceRequirement::KeepAlive, ) } - pub fn create_new_token(who: &T::AccountId, amount: Balance) -> TokenId { - ::Currency::create(who, amount.into()) - .expect("Token creation failed") - .into() + pub fn create_new_token(who: &AccountId, amount: Balance) -> TokenId { + ::Currency::create(who, amount).expect("Token creation failed") } - pub fn mint_token(token_id: TokenId, who: &T::AccountId, amount: Balance) { - ::Currency::mint(token_id.into(), who, amount.into()) - .expect("Token minting failed") + pub fn mint_token(token_id: TokenId, who: &AccountId, amount: Balance) { + ::Currency::mint(token_id, who, amount).expect("Token minting failed") } } @@ -423,7 +411,7 @@ impl Pallet { // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = - system::GenesisConfig::default().build_storage::().unwrap().into(); + system::GenesisConfig::::default().build_storage().unwrap().into(); ext.execute_with(|| { System::set_block_number(1); MockMaintenanceStatusProvider::set_maintenance(false); diff --git a/pallets/xyk/src/tests.rs b/pallets/xyk/src/tests.rs index 9ffe728bf7..d4c993f61d 100644 --- a/pallets/xyk/src/tests.rs +++ b/pallets/xyk/src/tests.rs @@ -5,15 +5,13 @@ use super::{Event, *}; use crate::mock::*; use frame_support::{assert_err, assert_err_ignore_postinfo, dispatch::GetDispatchInfo}; -use mangata_support::traits::{ComputeIssuance, GetIssuance, LiquidityMiningApi}; +use mangata_support::traits::LiquidityMiningApi; use mangata_types::assets::CustomMetadata; use orml_traits::asset_registry::AssetMetadata; use serial_test::serial; use sp_runtime::{traits::Dispatchable, Permill}; use test_case::test_case; -type TokensOf = ::Currency; - const DUMMY_USER_ID: u128 = 2; const TRADER_ID: u128 = 3; @@ -156,8 +154,8 @@ fn set_info_should_work() { assert_eq!( *MockAssetRegister::instance().lock().unwrap().get(&2u32).unwrap(), AssetMetadata { - name: b"LiquidityPoolToken0x00000002".to_vec(), - symbol: b"TKN0x00000000-TKN0x00000001".to_vec(), + name: BoundedVec::truncate_from(b"LiquidityPoolToken0x00000002".to_vec()), + symbol: BoundedVec::truncate_from(b"TKN0x00000000-TKN0x00000001".to_vec()), decimals: 18u32, location: None, additional: CustomMetadata::default(), @@ -192,8 +190,8 @@ fn set_info_should_work_with_small_numbers() { assert_eq!( *MockAssetRegister::instance().lock().unwrap().get(&N).unwrap(), AssetMetadata { - name: b"LiquidityPoolToken0x00003039".to_vec(), - symbol: b"TKN0x0000000F-TKN0x00002FC9".to_vec(), + name: BoundedVec::truncate_from(b"LiquidityPoolToken0x00003039".to_vec()), + symbol: BoundedVec::truncate_from(b"TKN0x0000000F-TKN0x00002FC9".to_vec()), decimals: 18u32, location: None, additional: CustomMetadata::default(), @@ -229,8 +227,8 @@ fn set_info_should_work_with_large_numbers() { assert_eq!( *MockAssetRegister::instance().lock().unwrap().get(&1524501234u32).unwrap(), AssetMetadata { - name: b"LiquidityPoolToken0x5ADE0AF2".to_vec(), - symbol: b"TKN0x00E4E1C0-TKN0x00BAA928".to_vec(), + name: BoundedVec::truncate_from(b"LiquidityPoolToken0x5ADE0AF2".to_vec()), + symbol: BoundedVec::truncate_from(b"TKN0x00E4E1C0-TKN0x00BAA928".to_vec()), decimals: 18u32, location: None, additional: CustomMetadata::default(), @@ -740,7 +738,9 @@ fn sell_N_insufficient_output_amount_inner_function_error_upon_bad_slippage() { initialize(); assert_err!( - >::sell_asset(2, 1, 4, 250000, 500000, true), + >::sell_asset( + 2, 1, 4, 250000, 500000, true + ), Error::::InsufficientOutputAmount, ); // selling 250000 assetId 0 of pool 0 1, by the formula user should get 166333 asset 1, but is requesting 500000 }); @@ -752,7 +752,7 @@ fn sell_W_insufficient_output_amount_inner_function_NO_error_upon_bad_slippage() new_test_ext().execute_with(|| { initialize(); - assert_ok!(>::sell_asset( + assert_ok!(>::sell_asset( 2, 1, 4, 250000, 500000, false ),); // selling 250000 assetId 0 of pool 0 1, by the formula user should get 166333 asset 1, but is requesting 500000 }); @@ -1355,7 +1355,9 @@ fn buy_N_insufficient_input_amount_inner_function_error_upon_bad_slippage() { // buying 150000 liquidity assetId 1 of pool 0 1 assert_err!( - >::buy_asset(2, 1, 4, 150000, 10, true), + >::buy_asset( + 2, 1, 4, 150000, 10, true + ), Error::::InsufficientInputAmount, ); }); @@ -1368,7 +1370,7 @@ fn buy_W_insufficient_input_amount_inner_function_NO_error_upon_bad_slippage() { initialize(); // buying 150000 liquidity assetId 1 of pool 0 1 - assert_ok!(>::buy_asset( + assert_ok!(>::buy_asset( 2, 1, 4, 150000, 10, false )); }); @@ -1898,7 +1900,13 @@ fn burn_all_liq_and_mint_it_again() { assert_eq!(user_assets_4_value_after_sell, 1000000000000000000000); // minting liq again and checking if the liq. asset is generated - XykStorage::mint_liquidity(RuntimeOrigin::signed(2), 1, 4, asset_value_1, asset_value_4); + let _ = XykStorage::mint_liquidity( + RuntimeOrigin::signed(2), + 1, + 4, + asset_value_1, + asset_value_4, + ); let liq_token_id_after_burn_and_mint = XykStorage::liquidity_asset((1, 4)); @@ -2327,7 +2335,9 @@ fn unsuccessful_sell_assets_charges_fee() { fn PoolCreateApi_test_pool_exists_return_false_for_non_existing_pool() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert!(!::pool_exists(1_u32, 4_u32)); + assert!(!>::pool_exists( + 1_u32, 4_u32 + )); }); } @@ -2338,7 +2348,9 @@ fn PoolCreateApi_pool_exists_return_true_for_existing_pool() { initialize(); XykStorage::create_pool(RuntimeOrigin::signed(2), 0, 500000, 1, 10000).unwrap(); - assert!(::pool_exists(0_u32, 1_u32)); + assert!(>::pool_exists( + 0_u32, 1_u32 + )); }); } @@ -2352,13 +2364,16 @@ fn PoolCreateApi_pool_create_creates_a_pool() { let first_asset_amount = 10_000_u128; let second_asset_id = 1_u32; let second_asset_amount = 5_000_u128; - assert!(!::pool_exists(first_asset_id, second_asset_id)); + assert!(!>::pool_exists( + first_asset_id, + second_asset_id + )); let liq_token_id = Tokens::next_asset_id(); let liq_token_amount = (first_asset_amount + second_asset_amount) / 2; assert_eq!( - ::pool_create( + >::pool_create( DUMMY_USER_ID, first_asset_id, first_asset_amount, @@ -2371,7 +2386,9 @@ fn PoolCreateApi_pool_create_creates_a_pool() { assert_ne!(liq_token_id, Tokens::next_asset_id()); assert_eq!(liq_token_amount, XykStorage::balance(liq_token_id, DUMMY_USER_ID)); - assert!(::pool_exists(0_u32, 1_u32)); + assert!(>::pool_exists( + 0_u32, 1_u32 + )); }); } diff --git a/rpc/nonce/Cargo.toml b/rpc/nonce/Cargo.toml index 9aa8294e91..31e48bec91 100644 --- a/rpc/nonce/Cargo.toml +++ b/rpc/nonce/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" description = "FRAME's system exposed over Substrate RPC" readme = "README.md" @@ -13,17 +12,18 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } codec = { package = "parity-scale-codec", version = "3.0.0" } futures = "0.3.21" jsonrpsee = { version = "0.16.2", features = ["server"] } log = "0.4.17" -sp-runtime = { version = "7.0.0", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-api = { version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api ={ version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-core ={ version = "7.0.0", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-blockchain ={ version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -ver-api ={ version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-transaction-pool-api ={ version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-block-builder ={ version = "4.0.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sc-rpc-api ={ version = "0.10.0-dev", git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } + +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-client-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-rpc-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-blockchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-block-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +ver-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } diff --git a/rpc/nonce/src/lib.rs b/rpc/nonce/src/lib.rs index 3f3f359071..d12c754986 100644 --- a/rpc/nonce/src/lib.rs +++ b/rpc/nonce/src/lib.rs @@ -128,7 +128,7 @@ where async fn dry_run( &self, extrinsic: Bytes, - at: Option<::Hash>, + _at: Option<::Hash>, ) -> RpcResult { self.deny_unsafe.check_if_safe()?; let api = self.client.runtime_api(); diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 5a8b43320e..f73ed8e42d 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -9,11 +9,11 @@ license = "Unlicense" targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } [dependencies] -hex-literal = { version = '0.3.1' } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +hex-literal = { version = "0.3.1" } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.137", optional = true, features = ["derive"] } @@ -21,96 +21,94 @@ smallvec = "1.6.1" static_assertions = "1.1.0" # Local Dependencies -pallet-xyk = { path = '../../pallets/xyk', default-features = false, version = '0.1.0' } -pallet-proof-of-stake = { path = '../../pallets/proof-of-stake', default-features = false, version = '0.1.0' } -pallet-bootstrap = { path = '../../pallets/bootstrap', default-features = false, version = '0.1.0' } -xyk-runtime-api = { path = '../../pallets/xyk/runtime-api', default-features = false, version = '2.0.0' } -pallet-sudo-origin = { path = '../../pallets/sudo-origin', default-features = false } -pallet-issuance = { path = '../../pallets/issuance', default-features = false } -pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', default-features = false } -pallet-maintenance = { path = '../../pallets/maintenance', default-features = false } -pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false} -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +pallet-bootstrap = { path = "../../pallets/bootstrap", default-features = false } +pallet-fee-lock = { path = "../../pallets/fee-lock", default-features = false } +pallet-issuance = { path = "../../pallets/issuance", default-features = false } +pallet-maintenance = { path = "../../pallets/maintenance", default-features = false } +pallet-multipurpose-liquidity = { path = "../../pallets/multipurpose-liquidity", default-features = false } +pallet-proof-of-stake = { path = "../../pallets/proof-of-stake", default-features = false } +pallet-sudo-origin = { path = "../../pallets/sudo-origin", default-features = false } +pallet-xyk = { path = "../../pallets/xyk", default-features = false } +parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } +xyk-runtime-api = { path = "../../pallets/xyk/runtime-api", default-features = false } # Substrate Dependencies ## Substrate Primitive Dependencies -mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-utility-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-block-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-consensus-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-inherents = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-offchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-transaction-pool = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-ver = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-version = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-weights = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate FRAME Dependencies -frame-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +ver-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate Pallet Dependencies -pallet-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-root-testing = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } - -# Open-Runtime-Module-Library Dependencies -orml-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-traits = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xtokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm-support = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-unknown-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-asset-registry = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +pallet-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-authorship = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-collective-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-identity = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-proxy = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-root-testing = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-treasury = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Cumulus dependencies -cumulus-pallet-aura-ext = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-dmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-parachain-system = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcm = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-core = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-timestamp = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-utility = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -parachain-info = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-session-benchmarking = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false, optional = true } +cumulus-pallet-aura-ext = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-dmp-queue = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-session-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +cumulus-pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +parachain-info = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Polkadot Dependencies -polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev", default-features = false } -pallet-xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-executor = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } +pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-parachain-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } -# Staking dependencies -parachain-staking = { default-features = false, git = "https://github.com/mangata-finance/moonbeam", branch = "mangata-dev" } +# Open-Runtime-Module-Library Dependencies +orml-asset-registry = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-unknown-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm-support = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xtokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } # Crowdloan dependencies -pallet-crowdloan-rewards = { default-features = false, git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "mangata-dev" } +pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "upgrade/v1.1.0", default-features = false } [features] default = [ @@ -118,162 +116,162 @@ default = [ ] std = [ "codec/std", - "serde", - "scale-info/std", - "log/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-ver/std", - "sp-version/std", - "frame-executive/std", - "frame-support/std", - "frame-system/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-proxy/std", - "pallet-session/std", - "pallet-sudo-mangata/std", - "pallet-sudo-origin/std", - "pallet-timestamp/std", - "pallet-transaction-payment-mangata-rpc-runtime-api/std", - "pallet-transaction-payment-mangata/std", - "pallet-utility-mangata/std", "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", + "cumulus-pallet-session-benchmarking/std", "cumulus-pallet-xcm/std", "cumulus-pallet-xcmp-queue/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-session-benchmarking/std", "frame-benchmarking/std", + "frame-executive/std", + "frame-support/std", "frame-system-benchmarking/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", "frame-try-runtime/std", - "polkadot-primitives/std", - "sp-weights/std", - "parachain-info/std", - "polkadot-parachain/std", - "polkadot-runtime-common/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", - "ver-api/std", + "log/std", + "mangata-support/std", "mangata-types/std", - "orml-traits/std", + "orml-asset-registry/std", "orml-tokens/std", - "pallet-treasury/std", - "pallet-xyk/std", - "pallet-proof-of-stake/std", - "pallet-bootstrap/std", - "xyk-runtime-api/std", - "parachain-staking/std", - "orml-xtokens/std", - "orml-xcm-support/std", + "orml-traits/std", "orml-unknown-tokens/std", + "orml-xcm-support/std", "orml-xcm/std", - "orml-asset-registry/std", - "pallet-issuance/std", - "pallet-vesting-mangata/std", - "pallet-crowdloan-rewards/std", - "frame-system-rpc-runtime-api/std", + "orml-xtokens/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-bootstrap/std", "pallet-collective-mangata/std", - "pallet-multipurpose-liquidity/std", - "mangata-support/std", + "pallet-crowdloan-rewards/std", "pallet-fee-lock/std", "pallet-identity/std", + "pallet-issuance/std", "pallet-maintenance/std", + "pallet-multipurpose-liquidity/std", + "pallet-proof-of-stake/std", + "pallet-proxy/std", + "pallet-session/std", + "pallet-sudo-mangata/std", + "pallet-sudo-origin/std", + "pallet-timestamp/std", + "pallet-transaction-payment-mangata-rpc-runtime-api/std", + "pallet-transaction-payment-mangata/std", + "pallet-treasury/std", + "pallet-utility-mangata/std", + "pallet-vesting-mangata/std", + "pallet-xyk/std", + "parachain-info/std", + "parachain-staking/std", + "polkadot-parachain-primitives/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", + "scale-info/std", + "serde", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-ver/std", + "sp-version/std", + "sp-weights/std", + "ver-api/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "xyk-runtime-api/std", ] try-runtime = [ - "sp-runtime/try-runtime", - "frame-support/try-runtime", - "frame-try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", - "polkadot-runtime-common/try-runtime", - "pallet-multipurpose-liquidity/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "pallet-timestamp/try-runtime", - "parachain-info/try-runtime", + "frame-try-runtime", + "orml-asset-registry/try-runtime", "orml-tokens/try-runtime", - "pallet-transaction-payment-mangata/try-runtime", - "pallet-xyk/try-runtime", - "pallet-proof-of-stake/try-runtime", - "pallet-vesting-mangata/try-runtime", - "pallet-crowdloan-rewards/try-runtime", - "pallet-issuance/try-runtime", - "pallet-authorship/try-runtime", - "parachain-staking/try-runtime", - "pallet-session/try-runtime", - "pallet-aura/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "pallet-xcm/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", - "orml-xtokens/try-runtime", "orml-unknown-tokens/try-runtime", "orml-xcm/try-runtime", - "orml-asset-registry/try-runtime", - "pallet-treasury/try-runtime", - "pallet-sudo-mangata/try-runtime", - "pallet-sudo-origin/try-runtime", - "pallet-collective-mangata/try-runtime", + "orml-xtokens/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", "pallet-bootstrap/try-runtime", - "pallet-utility-mangata/try-runtime", - "pallet-proxy/try-runtime", + "pallet-collective-mangata/try-runtime", + "pallet-crowdloan-rewards/try-runtime", "pallet-fee-lock/try-runtime", "pallet-identity/try-runtime", + "pallet-issuance/try-runtime", "pallet-maintenance/try-runtime", - "pallet-root-testing/try-runtime" + "pallet-multipurpose-liquidity/try-runtime", + "pallet-proof-of-stake/try-runtime", + "pallet-proxy/try-runtime", + "pallet-root-testing/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo-mangata/try-runtime", + "pallet-sudo-origin/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment-mangata/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility-mangata/try-runtime", + "pallet-vesting-mangata/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xyk/try-runtime", + "parachain-info/try-runtime", + "parachain-staking/try-runtime", + "polkadot-runtime-common/try-runtime", + "sp-runtime/try-runtime", ] fast-runtime = [] runtime-benchmarks = [ - "polkadot-primitives/runtime-benchmarks", - "pallet-maintenance/runtime-benchmarks", - "polkadot-parachain/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "xcm-executor/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-system-benchmarking", "frame-support/runtime-benchmarks", + "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", "orml-tokens/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "cumulus-pallet-session-benchmarking/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "pallet-xyk/runtime-benchmarks", - "pallet-proof-of-stake/runtime-benchmarks", - "parachain-staking/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", + "pallet-bootstrap/runtime-benchmarks", "pallet-collective-mangata/runtime-benchmarks", "pallet-crowdloan-rewards/runtime-benchmarks", - "pallet-utility-mangata/runtime-benchmarks", - "pallet-vesting-mangata/runtime-benchmarks", + "pallet-fee-lock/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-issuance/runtime-benchmarks", - "pallet-bootstrap/runtime-benchmarks", + "pallet-maintenance/runtime-benchmarks", "pallet-multipurpose-liquidity/runtime-benchmarks", + "pallet-proof-of-stake/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", - "pallet-fee-lock/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-utility-mangata/runtime-benchmarks", + "pallet-vesting-mangata/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xyk/runtime-benchmarks", + "parachain-staking/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", ] diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index dd8daf70ef..5e4ace59c1 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -1,10 +1,9 @@ pub mod fee { - use crate::{consts::UNIT, weights::VerExtrinsicBaseWeight}; + use crate::{consts::UNIT, weights::VerExtrinsicBaseWeight, Balance}; use frame_support::weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use mangata_types::Balance; use smallvec::smallvec; use sp_runtime::Perbill; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 7eb1bfdb64..ba0cc248b3 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -3,13 +3,17 @@ #![recursion_limit = "256"] use codec::{Decode, Encode, MaxEncodedLen}; +pub use constants::{fee::*, parachains::*}; +pub use currency::*; +#[cfg(feature = "runtime-benchmarks")] +use frame_support::traits::OriginTrait; use frame_support::{ dispatch::{DispatchClass, DispatchResult}, ensure, parameter_types, traits::{ tokens::currency::{MultiTokenCurrency, MultiTokenImbalanceWithZeroTrait}, Contains, EnsureOrigin, EnsureOriginWithArg, ExistenceRequirement, Get, Imbalance, - OriginTrait, WithdrawReasons, + WithdrawReasons, }, unsigned::TransactionValidityError, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight}, @@ -21,49 +25,37 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; -use log::info; +use mangata_support::traits::{AssetRegistryApi, FeeLockTriggerTrait, PreValidateSwaps}; +pub use mangata_types::assets::{CustomMetadata, XcmMetadata, XykMetadata}; pub use orml_tokens; use orml_tokens::MultiTokenCurrencyExtended; use orml_traits::{ asset_registry::{AssetMetadata, AssetProcessor}, parameter_type_with_key, }; +pub use pallet_issuance::IssuanceInfo; pub use pallet_sudo_mangata; +pub use pallet_sudo_origin; use pallet_transaction_payment_mangata::{ConstFeeMultiplier, Multiplier, OnChargeTransaction}; - -// Polkadot Imports +pub use pallet_xyk; +use pallet_xyk::AssetMetadataMutationTrait; pub use polkadot_runtime_common::BlockHashCount; use scale_info::TypeInfo; - pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; - #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -use sp_runtime::{ +pub use sp_runtime::{ generic, traits::{ - AccountIdConversion, BlakeTwo256, DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero, + AccountIdConversion, BlakeTwo256, DispatchInfoOf, IdentifyAccount, PostDispatchInfoOf, + Saturating, Verify, Zero, }, transaction_validity::InvalidTransaction, - DispatchError, FixedPointNumber, Percent, RuntimeDebug, + BoundedVec, DispatchError, FixedPointNumber, MultiAddress, MultiSignature, OpaqueExtrinsic, + Perbill, Percent, Permill, RuntimeDebug, }; -pub use sp_runtime::{MultiAddress, Perbill, Permill}; use sp_std::{cmp::Ordering, marker::PhantomData, prelude::*}; - -pub use xcm::{latest::prelude::*, VersionedMultiLocation}; - -pub use constants::{fee::*, parachains::*}; -pub use currency::*; -use mangata_support::traits::{AssetRegistryApi, FeeLockTriggerTrait, PreValidateSwaps}; -pub use mangata_types::{ - assets::{CustomMetadata, XcmMetadata, XykMetadata}, - AccountId, Address, Amount, Balance, BlockNumber, Hash, Index, Signature, TokenId, -}; -pub use pallet_issuance::IssuanceInfo; -pub use pallet_sudo_origin; -pub use pallet_xyk; -// XCM Imports -use pallet_xyk::AssetMetadataMutationTrait; +pub use types::*; pub mod constants; pub mod migration; @@ -82,6 +74,33 @@ pub mod currency { } } +pub mod types { + use super::*; + + pub type TokenId = u32; + pub type Balance = u128; + pub type Amount = i128; + + // /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. + pub type Signature = MultiSignature; + + // /// Some way of identifying an account on the chain. We intentionally make it equivalent + // /// to the public key of our transaction signing scheme. + pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + + // /// Index of a transaction in the chain. + pub type Nonce = u32; + + // /// A hash of some data used by the chain. + pub type Hash = sp_core::H256; + + // /// An index to a block. + pub type BlockNumber = u32; + + // /// The address format for describing accounts. + pub type Address = MultiAddress; +} + pub mod tokens { use super::*; pub const MGX_TOKEN_ID: TokenId = 0; @@ -96,6 +115,28 @@ pub mod tokens { } } +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core data structures. +pub mod opaque { + use super::*; + use sp_runtime::{ + generic, + traits::{BlakeTwo256, Hash as HashT}, + }; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + /// Opaque block header type. + pub type Header = generic::HeaderVer; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; + /// Opaque block hash type. + pub type Hash = ::Output; +} + pub mod runtime_types { use super::*; @@ -150,7 +191,7 @@ pub mod consts { /// so there is room for new extrinsics in the next block pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( WEIGHT_REF_TIME_PER_SECOND.saturating_div(4), - polkadot_primitives::v2::MAX_POV_SIZE as u64, + polkadot_primitives::v5::MAX_POV_SIZE as u64, ); /// The existential deposit. Set to 1/10 of the Connected Relay Chain. @@ -333,12 +374,13 @@ pub mod config { pub struct AssetMetadataMutation(PhantomData); - impl AssetMetadataMutationTrait for AssetMetadataMutation + impl AssetMetadataMutationTrait for AssetMetadataMutation where T: ::orml_asset_registry::Config< CustomMetadata = CustomMetadata, AssetId = TokenId, Balance = Balance, + StringLimit = orml_asset_registry::StringLimit, >, { fn set_asset_info( @@ -348,8 +390,8 @@ pub mod config { decimals: u32, ) -> DispatchResult { let metadata = AssetMetadata { - name, - symbol, + name: BoundedVec::truncate_from(name), + symbol: BoundedVec::truncate_from(symbol), decimals, existential_deposit: Default::default(), additional: Default::default(), @@ -373,7 +415,7 @@ pub mod config { } pub struct EnableAssetPoolApi(PhantomData); - impl AssetRegistryApi for EnableAssetPoolApi + impl AssetRegistryApi for EnableAssetPoolApi where T: ::orml_asset_registry::Config< CustomMetadata = CustomMetadata, @@ -476,187 +518,222 @@ pub mod config { pub struct FeeHelpers(PhantomData<(T, C, OU, OCA, OFLA)>); impl FeeHelpers -where - T: pallet_transaction_payment_mangata::Config + pallet_xyk::Config + pallet_fee_lock::Config, - T::LengthToFee: frame_support::weights::WeightToFee< - Balance = ::AccountId>>::Balance, - >, - C: MultiTokenCurrency<::AccountId>, - C::PositiveImbalance: Imbalance< - ::AccountId>>::Balance, - Opposite = C::NegativeImbalance, - >, - C::NegativeImbalance: Imbalance< - ::AccountId>>::Balance, - Opposite = C::PositiveImbalance, - >, - OU: OnMultiTokenUnbalanced>, - NegativeImbalanceOf: MultiTokenImbalanceWithZeroTrait, - OCA: OnChargeTransaction< - T, - LiquidityInfo = Option>, - Balance = ::AccountId>>::Balance, - >, - OFLA: FeeLockTriggerTrait<::AccountId>, - // T: frame_system::Config, - T::AccountId: From + Into, - Balance: From<::AccountId>>::Balance>, - sp_runtime::AccountId32: From<::AccountId>, -{ - pub fn handle_sell_asset( - who: &T::AccountId, - fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, - sold_asset_id: u32, - sold_asset_amount: u128, - bought_asset_id: u32, - min_amount_out: u128, - ) -> Result>, TransactionValidityError> { - if fee_lock_metadata.is_whitelisted(sold_asset_id) || - fee_lock_metadata.is_whitelisted(bought_asset_id) + where + T: pallet_transaction_payment_mangata::Config + + pallet_xyk::Config + + pallet_fee_lock::Config, + T::LengthToFee: frame_support::weights::WeightToFee< + Balance = >::Balance, + >, + C: MultiTokenCurrency, + C::PositiveImbalance: Imbalance< + >::Balance, + Opposite = C::NegativeImbalance, + >, + C::NegativeImbalance: Imbalance< + >::Balance, + Opposite = C::PositiveImbalance, + >, + OU: OnMultiTokenUnbalanced>, + NegativeImbalanceOf: MultiTokenImbalanceWithZeroTrait, + OCA: OnChargeTransaction< + T, + LiquidityInfo = Option>, + Balance = >::Balance, + >, + OFLA: FeeLockTriggerTrait< + T::AccountId, + >::Balance, + >::CurrencyId, + >, + // T: frame_system::Config, + T::AccountId: From + Into, + sp_runtime::AccountId32: From, { - let (_, _, _, _, _, bought_asset_amount) = - as PreValidateSwaps>::pre_validate_sell_asset( + pub fn handle_sell_asset( + who: &T::AccountId, + fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, + sold_asset_id: TokenId, + sold_asset_amount: Balance, + bought_asset_id: TokenId, + min_amount_out: Balance, + ) -> Result>, TransactionValidityError> { + if fee_lock_metadata.is_whitelisted(sold_asset_id) || + fee_lock_metadata.is_whitelisted(bought_asset_id) + { + let (_, _, _, _, _, bought_asset_amount) = + as PreValidateSwaps< + T::AccountId, + Balance, + TokenId, + >>::pre_validate_sell_asset( + &who.clone(), + sold_asset_id, + bought_asset_id, + sold_asset_amount, + min_amount_out, + ) + .map_err(|_| { + TransactionValidityError::Invalid( + InvalidTransaction::SwapPrevalidation.into(), + ) + })?; + if Self::is_high_value_swap( + &fee_lock_metadata, + sold_asset_id, + sold_asset_amount, + ) || Self::is_high_value_swap( + &fee_lock_metadata, + bought_asset_id, + bought_asset_amount, + ) { + let _ = OFLA::unlock_fee(who); + } else { + OFLA::process_fee_lock(who).map_err(|_| { + TransactionValidityError::Invalid( + InvalidTransaction::ProcessFeeLock.into(), + ) + })?; + } + } else { + OFLA::process_fee_lock(who).map_err(|_| { + TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) + })?; + } + Ok(Some(LiquidityInfoEnum::FeeLock)) + } + + pub fn is_high_value_swap( + fee_lock_metadata: &pallet_fee_lock::FeeLockMetadataInfo, + asset_id: u32, + asset_amount: u128, + ) -> bool { + if let (true, Some(valuation)) = ( + fee_lock_metadata.is_whitelisted(asset_id), + OFLA::get_swap_valuation_for_token(asset_id, asset_amount), + ) { + valuation >= fee_lock_metadata.swap_value_threshold + } else { + false + } + } + + pub fn handle_buy_asset( + who: &T::AccountId, + fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, + sold_asset_id: TokenId, + bought_asset_amount: Balance, + bought_asset_id: TokenId, + max_amount_in: Balance, + ) -> Result>, TransactionValidityError> { + if fee_lock_metadata.is_whitelisted(sold_asset_id) || + fee_lock_metadata.is_whitelisted(bought_asset_id) + { + let (_, _, _, _, _, sold_asset_amount) = + as PreValidateSwaps< + T::AccountId, + Balance, + TokenId, + >>::pre_validate_buy_asset( + &who.clone(), + sold_asset_id, + bought_asset_id, + bought_asset_amount, + max_amount_in, + ) + .map_err(|_| { + TransactionValidityError::Invalid( + InvalidTransaction::SwapPrevalidation.into(), + ) + })?; + if Self::is_high_value_swap( + &fee_lock_metadata, + sold_asset_id, + sold_asset_amount, + ) || Self::is_high_value_swap( + &fee_lock_metadata, + bought_asset_id, + bought_asset_amount, + ) { + let _ = OFLA::unlock_fee(who); + } else { + OFLA::process_fee_lock(who).map_err(|_| { + TransactionValidityError::Invalid( + InvalidTransaction::ProcessFeeLock.into(), + ) + })?; + } + } else { + // "swap on non-curated token" branch + OFLA::process_fee_lock(who).map_err(|_| { + TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) + })?; + } + Ok(Some(LiquidityInfoEnum::FeeLock)) + } + + pub fn handle_multiswap_buy_asset( + who: &T::AccountId, + _fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, + swap_token_list: Vec, + bought_asset_amount: Balance, + max_amount_in: Balance, + ) -> Result>, TransactionValidityError> { + // ensure swap cannot fail + // This is to ensure that xyk swap fee is always charged + // We also ensure that the user has enough funds to transact + let _ = as PreValidateSwaps< + T::AccountId, + Balance, + TokenId, + >>::pre_validate_multiswap_buy_asset( &who.clone(), - sold_asset_id, - bought_asset_id, - sold_asset_amount, - min_amount_out, + swap_token_list, + bought_asset_amount, + max_amount_in, ) .map_err(|_| { TransactionValidityError::Invalid(InvalidTransaction::SwapPrevalidation.into()) })?; - if Self::is_high_value_swap(&fee_lock_metadata, sold_asset_id, sold_asset_amount) || - Self::is_high_value_swap( - &fee_lock_metadata, - bought_asset_id, - bought_asset_amount, - ) { - let _ = OFLA::unlock_fee(who); - } else { + + // This is the "low value swap on curated token" branch OFLA::process_fee_lock(who).map_err(|_| { TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) })?; + Ok(Some(LiquidityInfoEnum::FeeLock)) } - } else { - OFLA::process_fee_lock(who).map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) - })?; - } - Ok(Some(LiquidityInfoEnum::FeeLock)) - } - pub fn is_high_value_swap( - fee_lock_metadata: &pallet_fee_lock::FeeLockMetadataInfo, - asset_id: u32, - asset_amount: u128, - ) -> bool { - if let (true, Some(valuation)) = ( - fee_lock_metadata.is_whitelisted(asset_id), - OFLA::get_swap_valuation_for_token(asset_id, asset_amount), - ) { - valuation >= fee_lock_metadata.swap_value_threshold - } else { - false - } - } - - pub fn handle_buy_asset( - who: &T::AccountId, - fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, - sold_asset_id: u32, - bought_asset_amount: u128, - bought_asset_id: u32, - max_amount_in: u128, - ) -> Result>, TransactionValidityError> { - if fee_lock_metadata.is_whitelisted(sold_asset_id) || - fee_lock_metadata.is_whitelisted(bought_asset_id) - { - let (_, _, _, _, _, sold_asset_amount) = - as PreValidateSwaps>::pre_validate_buy_asset( + pub fn handle_multiswap_sell_asset( + who: &::AccountId, + _fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, + swap_token_list: Vec, + sold_asset_amount: Balance, + min_amount_out: Balance, + ) -> Result>, TransactionValidityError> { + // ensure swap cannot fail + // This is to ensure that xyk swap fee is always charged + // We also ensure that the user has enough funds to transact + let _ = as PreValidateSwaps< + T::AccountId, + Balance, + TokenId, + >>::pre_validate_multiswap_sell_asset( &who.clone(), - sold_asset_id, - bought_asset_id, - bought_asset_amount, - max_amount_in, + swap_token_list.clone(), + sold_asset_amount, + min_amount_out, ) .map_err(|_| { TransactionValidityError::Invalid(InvalidTransaction::SwapPrevalidation.into()) })?; - if Self::is_high_value_swap(&fee_lock_metadata, sold_asset_id, sold_asset_amount) || - Self::is_high_value_swap( - &fee_lock_metadata, - bought_asset_id, - bought_asset_amount, - ) { - let _ = OFLA::unlock_fee(who); - } else { + + // This is the "low value swap on curated token" branch OFLA::process_fee_lock(who).map_err(|_| { TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) })?; + Ok(Some(LiquidityInfoEnum::FeeLock)) } - } else { - // "swap on non-curated token" branch - OFLA::process_fee_lock(who).map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) - })?; } - Ok(Some(LiquidityInfoEnum::FeeLock)) - } - - pub fn handle_multiswap_buy_asset( - who: &T::AccountId, - _fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, - swap_token_list: Vec, - bought_asset_amount: u128, - max_amount_in: u128, - ) -> Result>, TransactionValidityError> { - // ensure swap cannot fail - // This is to ensure that xyk swap fee is always charged - // We also ensure that the user has enough funds to transact - let _ = as PreValidateSwaps>::pre_validate_multiswap_buy_asset( - &who.clone(), - swap_token_list, - bought_asset_amount, - max_amount_in, - ) - .map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::SwapPrevalidation.into()) - })?; - - // This is the "low value swap on curated token" branch - OFLA::process_fee_lock(who).map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) - })?; - Ok(Some(LiquidityInfoEnum::FeeLock)) - } - - pub fn handle_multiswap_sell_asset( - who: &::AccountId, - _fee_lock_metadata: pallet_fee_lock::FeeLockMetadataInfo, - swap_token_list: Vec, - sold_asset_amount: u128, - min_amount_out: u128, - ) -> Result>, TransactionValidityError> { - // ensure swap cannot fail - // This is to ensure that xyk swap fee is always charged - // We also ensure that the user has enough funds to transact - let _ = as PreValidateSwaps>::pre_validate_multiswap_sell_asset( - &who.clone(), - swap_token_list.clone(), - sold_asset_amount, - min_amount_out, - ) - .map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::SwapPrevalidation.into()) - })?; - - // This is the "low value swap on curated token" branch - OFLA::process_fee_lock(who).map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::ProcessFeeLock.into()) - })?; - Ok(Some(LiquidityInfoEnum::FeeLock)) - } -} const SINGLE_HOP_MULTISWAP: usize = 2; #[derive(Encode, Decode, Clone, TypeInfo)] @@ -667,106 +744,115 @@ where /// The unbalance handler is given 2 unbalanceds in [`OnUnbalanced::on_unbalanceds`]: fee and /// then tip. impl OnChargeTransaction for OnChargeHandler -where - T: pallet_transaction_payment_mangata::Config + pallet_xyk::Config + pallet_fee_lock::Config, - ::RuntimeCall: Into, - T::LengthToFee: frame_support::weights::WeightToFee< - Balance = ::AccountId>>::Balance, - >, - C: MultiTokenCurrency<::AccountId>, - C::PositiveImbalance: Imbalance< - ::AccountId>>::Balance, - Opposite = C::NegativeImbalance, - >, - C::NegativeImbalance: Imbalance< - ::AccountId>>::Balance, - Opposite = C::PositiveImbalance, - >, - OU: OnMultiTokenUnbalanced>, - NegativeImbalanceOf: MultiTokenImbalanceWithZeroTrait, - OCA: OnChargeTransaction< - T, - LiquidityInfo = Option>, - Balance = ::AccountId>>::Balance, - >, - OFLA: FeeLockTriggerTrait<::AccountId>, - // T: frame_system::Config, - T::AccountId: From + Into, - Balance: From<::AccountId>>::Balance>, - sp_runtime::AccountId32: From<::AccountId>, -{ - type LiquidityInfo = Option>; - type Balance = ::AccountId>>::Balance; - - /// Withdraw the predicted fee from the transaction origin. - /// - /// Note: The `fee` already includes the `tip`. - fn withdraw_fee( - who: &T::AccountId, - call: &T::RuntimeCall, - info: &DispatchInfoOf, - fee: Self::Balance, - tip: Self::Balance, - ) -> Result { - let call_type: crate::CallType = (*call).clone().into(); - - match call_type{ - crate::CallType::MultiSell{..} | - crate::CallType::MultiBuy{..} | - crate::CallType::AtomicBuy{..} | - crate::CallType::AtomicSell{..} => { - ensure!( - tip.is_zero(), - TransactionValidityError::Invalid( - InvalidTransaction::TippingNotAllowedForSwaps.into(), + where + T: pallet_transaction_payment_mangata::Config + + pallet_xyk::Config + + pallet_fee_lock::Config, + ::RuntimeCall: Into, + T::LengthToFee: frame_support::weights::WeightToFee< + Balance = >::Balance, + >, + C: MultiTokenCurrency, + C::PositiveImbalance: Imbalance< + >::Balance, + Opposite = C::NegativeImbalance, + >, + C::NegativeImbalance: Imbalance< + >::Balance, + Opposite = C::PositiveImbalance, + >, + OU: OnMultiTokenUnbalanced>, + NegativeImbalanceOf: MultiTokenImbalanceWithZeroTrait, + OCA: OnChargeTransaction< + T, + LiquidityInfo = Option>, + Balance = >::Balance, + >, + OFLA: FeeLockTriggerTrait< + T::AccountId, + >::Balance, + >::CurrencyId, + >, + // T: frame_system::Config, + T::AccountId: From + Into, + Balance: From<>::Balance>, + sp_runtime::AccountId32: From, + { + type LiquidityInfo = Option>; + type Balance = >::Balance; + + /// Withdraw the predicted fee from the transaction origin. + /// + /// Note: The `fee` already includes the `tip`. + fn withdraw_fee( + who: &T::AccountId, + call: &T::RuntimeCall, + info: &DispatchInfoOf, + fee: Self::Balance, + tip: Self::Balance, + ) -> Result { + let call_type: crate::CallType = (*call).clone().into(); + + match call_type { + crate::CallType::MultiSell { .. } | + crate::CallType::MultiBuy { .. } | + crate::CallType::AtomicBuy { .. } | + crate::CallType::AtomicSell { .. } => { + ensure!( + tip.is_zero(), + TransactionValidityError::Invalid( + InvalidTransaction::TippingNotAllowedForSwaps.into(), ) ); - } - _ => {} - }; + }, + _ => {}, + }; - // call.is_unlock_fee(); + // call.is_unlock_fee(); - // THIS IS NOT PROXY PALLET COMPATIBLE, YET - // Also ugly implementation to keep it maleable for now - match (call_type, pallet_fee_lock::FeeLockMetadata::::get()) { - (crate::CallType::AtomicSell{sold_asset_id, - sold_asset_amount, - bought_asset_id, - min_amount_out}, - Some(fee_lock_metadata)) => - { - FeeHelpers::::handle_sell_asset( - who, - fee_lock_metadata, - sold_asset_id, - sold_asset_amount, - bought_asset_id, - min_amount_out, - ) - }, - (crate::CallType::AtomicBuy{ - sold_asset_id, - bought_asset_amount, - bought_asset_id, - max_amount_in}, - Some(fee_lock_metadata)) => - { - FeeHelpers::::handle_buy_asset( - who, - fee_lock_metadata, - sold_asset_id, - bought_asset_amount, - bought_asset_id, - max_amount_in, - ) - }, - (crate::CallType::MultiBuy{ - swap_token_list, - bought_asset_amount, - max_amount_in}, - Some(fee_lock_metadata)) if swap_token_list.len() == SINGLE_HOP_MULTISWAP => - { + // THIS IS NOT PROXY PALLET COMPATIBLE, YET + // Also ugly implementation to keep it maleable for now + match (call_type, pallet_fee_lock::FeeLockMetadata::::get()) { + ( + crate::CallType::AtomicSell { + sold_asset_id, + sold_asset_amount, + bought_asset_id, + min_amount_out, + }, + Some(fee_lock_metadata), + ) => FeeHelpers::::handle_sell_asset( + who, + fee_lock_metadata, + sold_asset_id, + sold_asset_amount, + bought_asset_id, + min_amount_out, + ), + ( + crate::CallType::AtomicBuy { + sold_asset_id, + bought_asset_amount, + bought_asset_id, + max_amount_in, + }, + Some(fee_lock_metadata), + ) => FeeHelpers::::handle_buy_asset( + who, + fee_lock_metadata, + sold_asset_id, + bought_asset_amount, + bought_asset_id, + max_amount_in, + ), + ( + crate::CallType::MultiBuy { + swap_token_list, + bought_asset_amount, + max_amount_in, + }, + Some(fee_lock_metadata), + ) if swap_token_list.len() == SINGLE_HOP_MULTISWAP => { let sold_asset_id = swap_token_list.get(0).ok_or(TransactionValidityError::Invalid( InvalidTransaction::SwapPrevalidation.into(), @@ -783,25 +869,29 @@ where *bought_asset_id, max_amount_in, ) - }, - (crate::CallType::MultiBuy{ - swap_token_list, - bought_asset_amount, - max_amount_in}, - Some(fee_lock_metadata)) => - { - FeeHelpers::::handle_multiswap_buy_asset( - who, - fee_lock_metadata, - swap_token_list.clone(), - bought_asset_amount, - max_amount_in) - }, - (crate::CallType::MultiSell{ - swap_token_list, - sold_asset_amount, - min_amount_out}, - Some(fee_lock_metadata)) if swap_token_list.len() == SINGLE_HOP_MULTISWAP => { + }, + ( + crate::CallType::MultiBuy { + swap_token_list, + bought_asset_amount, + max_amount_in, + }, + Some(fee_lock_metadata), + ) => FeeHelpers::::handle_multiswap_buy_asset( + who, + fee_lock_metadata, + swap_token_list.clone(), + bought_asset_amount, + max_amount_in, + ), + ( + crate::CallType::MultiSell { + swap_token_list, + sold_asset_amount, + min_amount_out, + }, + Some(fee_lock_metadata), + ) if swap_token_list.len() == SINGLE_HOP_MULTISWAP => { let sold_asset_id = swap_token_list.get(0).ok_or(TransactionValidityError::Invalid( InvalidTransaction::SwapPrevalidation.into(), @@ -818,69 +908,70 @@ where *bought_asset_id, min_amount_out, ) - }, - (crate::CallType::MultiSell{ - swap_token_list, - sold_asset_amount, - min_amount_out}, - Some(fee_lock_metadata)) => { - FeeHelpers::::handle_multiswap_sell_asset( - who, - fee_lock_metadata, - swap_token_list.clone(), - sold_asset_amount, - min_amount_out, - ) - }, - (crate::CallType::UnlockFee, _) => { - let imb = C::withdraw( - tokens::MgxTokenId::get().into(), - who, - Balance::from(tip).into(), - WithdrawReasons::TIP, - ExistenceRequirement::KeepAlive, - ) - .map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::Payment.into()) - })?; - - OU::on_unbalanceds(tokens::MgxTokenId::get().into(), Some(imb).into_iter()); - OFLA::can_unlock_fee(who).map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::UnlockFee.into()) - })?; - Ok(Some(LiquidityInfoEnum::FeeLock)) - }, - _ => OCA::withdraw_fee(who, call, info, fee, tip), - } - } + }, + ( + crate::CallType::MultiSell { + swap_token_list, + sold_asset_amount, + min_amount_out, + }, + Some(fee_lock_metadata), + ) => FeeHelpers::::handle_multiswap_sell_asset( + who, + fee_lock_metadata, + swap_token_list.clone(), + sold_asset_amount, + min_amount_out, + ), + (crate::CallType::UnlockFee, _) => { + let imb = C::withdraw( + tokens::MgxTokenId::get().into(), + who, + tip, + WithdrawReasons::TIP, + ExistenceRequirement::KeepAlive, + ) + .map_err(|_| { + TransactionValidityError::Invalid(InvalidTransaction::Payment.into()) + })?; + + OU::on_unbalanceds(tokens::MgxTokenId::get().into(), Some(imb).into_iter()); + OFLA::can_unlock_fee(who).map_err(|_| { + TransactionValidityError::Invalid(InvalidTransaction::UnlockFee.into()) + })?; + Ok(Some(LiquidityInfoEnum::FeeLock)) + }, + _ => OCA::withdraw_fee(who, call, info, fee, tip), + } + } - /// Hand the fee and the tip over to the `[OnUnbalanced]` implementation. - /// Since the predicted fee might have been too high, parts of the fee may - /// be refunded. - /// - /// Note: The `corrected_fee` already includes the `tip`. - fn correct_and_deposit_fee( - who: &T::AccountId, - dispatch_info: &DispatchInfoOf, - post_info: &PostDispatchInfoOf, - corrected_fee: Self::Balance, - tip: Self::Balance, - already_withdrawn: Self::LiquidityInfo, - ) -> Result<(), TransactionValidityError> { - match already_withdrawn { - Some(LiquidityInfoEnum::Imbalance(_)) => OCA::correct_and_deposit_fee( - who, - dispatch_info, - post_info, - corrected_fee, - tip, - already_withdrawn, - ), - Some(LiquidityInfoEnum::FeeLock) => Ok(()), - None => Ok(()), + /// Hand the fee and the tip over to the `[OnUnbalanced]` implementation. + /// Since the predicted fee might have been too high, parts of the fee may + /// be refunded. + /// + /// Note: The `corrected_fee` already includes the `tip`. + fn correct_and_deposit_fee( + who: &T::AccountId, + dispatch_info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, + corrected_fee: Self::Balance, + tip: Self::Balance, + already_withdrawn: Self::LiquidityInfo, + ) -> Result<(), TransactionValidityError> { + match already_withdrawn { + Some(LiquidityInfoEnum::Imbalance(_)) => OCA::correct_and_deposit_fee( + who, + dispatch_info, + post_info, + corrected_fee, + tip, + already_withdrawn, + ), + Some(LiquidityInfoEnum::FeeLock) => Ok(()), + None => Ok(()), + } + } } - } -} #[derive(Encode, Decode, Clone, TypeInfo)] pub struct ThreeCurrencyOnChargeAdapter( @@ -1076,11 +1167,19 @@ where pub const CouncilProposalCloseDelay: BlockNumber = 6 * consts::MINUTES; } + #[cfg(feature = "runtime-benchamarks")] + parameter_types! { + pub const CouncilProposalCloseDelay: BlockNumber = 0.into(); + } + parameter_types! { pub const CouncilMotionDuration: BlockNumber = 5 * consts::DAYS; pub const CouncilMaxProposals: u32 = 100; pub const CouncilMaxMembers: u32 = 100; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * config::frame_system::RuntimeBlockWeights::get().max_block; } + + pub type SetMembersOrigin = EnsureRoot; } pub mod pallet_maintenance { @@ -1200,15 +1299,20 @@ where pub mod orml_asset_registry { use crate::*; - pub type AssetMetadataOf = AssetMetadata; + parameter_types! { + pub const StringLimit: u32 = 50; + } + + pub type AssetMetadataOf = AssetMetadata; type CurrencyAdapter = orml_tokens::MultiTokenCurrencyAdapter; pub struct SequentialIdWithCreation(PhantomData); impl AssetProcessor for SequentialIdWithCreation where - T: ::orml_asset_registry::Config, - T: ::orml_tokens::Config, - T: ::pallet_treasury::Config, + T: orml_asset_registry::Config, + T: orml_tokens::Config, + T: pallet_treasury::Config, + TokenId: From<::CurrencyId>, { fn pre_register( id: Option, @@ -1246,7 +1350,7 @@ where origin: T::RuntimeOrigin, _asset_id: &Option, ) -> Result { - EnsureRoot::try_origin(origin) + as EnsureOrigin>::try_origin(origin) } #[cfg(feature = "runtime-benchmarks")] @@ -1317,6 +1421,8 @@ where use super::*; parameter_types! { pub const MinVestedTransfer: Balance = 100 * currency::DOLLARS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } } diff --git a/runtime/common/src/migration.rs b/runtime/common/src/migration.rs index 2b0f1cf70f..07c2810d1d 100644 --- a/runtime/common/src/migration.rs +++ b/runtime/common/src/migration.rs @@ -1,11 +1,10 @@ -use crate::config::orml_asset_registry::AssetMetadataOf; +use crate::{config::orml_asset_registry::StringLimit, Balance, TokenId}; use frame_support::{ - traits::{Get, OnRuntimeUpgrade}, + traits::{Get, GetStorageVersion, OnRuntimeUpgrade, StorageVersion}, weights::Weight, }; use log::info; -use mangata_types::{assets::CustomMetadata, Balance, TokenId}; -use sp_runtime::traits::Zero; +use mangata_types::assets::CustomMetadata; use sp_std::marker::PhantomData; pub struct AssetRegistryMigration(PhantomData); @@ -16,6 +15,7 @@ where CustomMetadata = CustomMetadata, AssetId = TokenId, Balance = Balance, + StringLimit = StringLimit, > + orml_tokens::Config, { fn on_runtime_upgrade() -> Weight { @@ -24,60 +24,13 @@ where "on_runtime_upgrade: Attempted to apply AssetRegistry migration" ); - let mut weight: Weight = Weight::zero(); - - orml_asset_registry::Metadata::::translate(|token_id, meta: AssetMetadataOf| { - weight - .saturating_accrue(::DbWeight::get().reads_writes(1, 1)); - - let issuance = orml_tokens::Pallet::::total_issuance(token_id); - let name = sp_std::str::from_utf8(&meta.name); - if issuance.is_zero() && name.map_or(false, |n| n.starts_with("Liquidity")) { - // By returning None from f for an element, we’ll remove it from the map. - // Based on the docs of translate method - None - } else { - Some(meta) - } - }); - - weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { - info!( - target: "asset_registry", - "pre_upgrade: checks" - ); - let mut has_zero_issuance: Vec = vec![]; - orml_asset_registry::Metadata::::iter().for_each(|(token_id, meta)| { - let issuance = orml_tokens::Pallet::::total_issuance(token_id); - let name = sp_std::str::from_utf8(&meta.name); - if issuance.is_zero() && name.map_or(false, |n| n.starts_with("Liquidity")) { - has_zero_issuance.push(token_id); - } - }); - - assert!(!has_zero_issuance.is_empty(), "No migration is required as we have identified only those liquidity assets with non-zero issuance."); - - Ok(Vec::new()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), &'static str> { - info!( - target: "asset_registry", - "post_upgrade: checks" - ); - orml_asset_registry::Metadata::::iter().for_each(|(token_id, meta)| { - let issuance = orml_tokens::Pallet::::total_issuance(token_id); - let name = sp_std::str::from_utf8(&meta.name); - if name.map_or(false, |n| n.starts_with("Liquidity")) { - assert!(!issuance.is_zero()); - } - }); - - Ok(()) + let version = orml_asset_registry::Pallet::::on_chain_storage_version(); + if version == 2 { + info!(target: "asset-registry", "No migration applied, remove"); + T::DbWeight::get().reads(1) + } else { + StorageVersion::new(2).put::>(); + T::DbWeight::get().reads_writes(1, 1) + } } } diff --git a/runtime/common/src/xcm_config.rs b/runtime/common/src/xcm_config.rs index 9df4c29e1b..a1878c14d2 100644 --- a/runtime/common/src/xcm_config.rs +++ b/runtime/common/src/xcm_config.rs @@ -12,7 +12,7 @@ use orml_asset_registry::{AssetRegistryTrader, FixedRateAssetRegistryTrader}; use orml_traits::{parameter_type_with_key, FixedConversionRateProvider, GetByKey, MultiCurrency}; use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter}; use pallet_xcm::XcmPassthrough; -use polkadot_parachain::primitives::Sibling; +use polkadot_parachain_primitives::primitives::Sibling; use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::{prelude::*, Weight as XcmWeight}; @@ -217,11 +217,12 @@ impl TakeRevenue for ToTreasury where T: orml_tokens::Config< AccountId = sp_runtime::AccountId32, - CurrencyId = mangata_types::TokenId, + CurrencyId = crate::TokenId, + Balance = crate::Balance, >, T: pallet_treasury::Config, T: parachain_info::Config, - T: orml_asset_registry::Config, + T: orml_asset_registry::Config, { fn take_revenue(revenue: MultiAsset) { if let MultiAsset { id: Concrete(location), fun: Fungible(amount) } = revenue { @@ -232,7 +233,7 @@ where let _ = orml_tokens::Pallet::::deposit( currency_id.into(), &crate::config::TreasuryAccountIdOf::::get(), - amount.into(), + amount, ); } } @@ -315,8 +316,8 @@ impl DropAssets for MangataDropAssets where X: DropAssets, T: TakeRevenue, - C: Convert>, - GK: GetByKey, + C: Convert>, + GK: GetByKey, { fn drop_assets( origin: &MultiLocation, @@ -381,8 +382,8 @@ parameter_type_with_key! { } pub struct AccountIdToMultiLocation; -impl Convert for AccountIdToMultiLocation { - fn convert(account: mangata_types::AccountId) -> MultiLocation { +impl Convert for AccountIdToMultiLocation { + fn convert(account: crate::AccountId) -> MultiLocation { X1(AccountId32 { network: None, id: account.into() }).into() } } @@ -404,4 +405,4 @@ where /// No local origins on this chain are allowed to dispatch XCM sends/executions. pub type LocalOriginToLocation = - SignedToAccountId32; + SignedToAccountId32; diff --git a/runtime/integration-test/Cargo.toml b/runtime/integration-test/Cargo.toml index 0417623dc0..14858372d8 100644 --- a/runtime/integration-test/Cargo.toml +++ b/runtime/integration-test/Cargo.toml @@ -3,67 +3,64 @@ name = "runtime-integration-test" version = "0.1.0" edition = "2021" -[dependencies] +[dev-dependencies] +env_logger = "0.9.1" +log = "0.4.17" + # Substrate -mangata-types = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } -parachain-staking = { git = "https://github.com/mangata-finance/moonbeam.git", branch = "mangata-dev" } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-balances = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-identity = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-proxy = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +sp-storage = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } # Polkadot -pallet-xcm = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -polkadot-runtime-parachains = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -xcm = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } +kusama-runtime = { package = "staging-kusama-runtime", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +kusama-runtime-constants = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +polkadot-parachain-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +polkadot-runtime-parachains = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +xcm = { package = "staging-xcm", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } # Cumulus -cumulus-primitives-core = { git = "https://github.com/mangata-finance/cumulus", branch = "mangata-dev" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance/cumulus", branch = "mangata-dev" } -parachain-info = { git = "https://github.com/mangata-finance/cumulus", branch = "mangata-dev" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +cumulus-primitives-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } +parachain-info = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } # Open-Runtime-Module-Library Dependencies -orml-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-traits = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xtokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm-support = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-unknown-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-asset-registry = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } - -# Local -mangata-kusama-runtime = { path = "../mangata-kusama", optional = true } -common-runtime = { path = "../common"} +orml-asset-registry = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-traits = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-unknown-tokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-xcm = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-xcm-support = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } +orml-xtokens = { git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop" } -pallet-xyk = { path = '../../pallets/xyk', version = '0.1.0' } -pallet-proof-of-stake = { path = '../../pallets/proof-of-stake', version = '0.1.0' } -pallet-bootstrap = { path = '../../pallets/bootstrap', version = '0.1.0' } -xyk-runtime-api = { path = '../../pallets/xyk/runtime-api', version = '2.0.0' } -pallet-sudo-origin = { path = '../../pallets/sudo-origin' } -pallet-issuance = { path = '../../pallets/issuance' } -pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity' } -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +xcm-emulator = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } -[dev-dependencies] -env_logger = "0.9.1" -log = "0.4.17" -sp-io = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } - -kusama-runtime = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -kusama-runtime-constants = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } - -xcm-executor = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev" } -xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "bea35c799d725a4233db6b9108ee2ed5bbfc1aed" } +# Local +common-runtime = { path = "../common" } +mangata-kusama-runtime = { path = "../mangata-kusama" } +pallet-bootstrap = { path = "../../pallets/bootstrap" } +pallet-issuance = { path = "../../pallets/issuance" } +pallet-multipurpose-liquidity = { path = "../../pallets/multipurpose-liquidity" } +pallet-proof-of-stake = { path = "../../pallets/proof-of-stake" } +pallet-sudo-origin = { path = "../../pallets/sudo-origin" } +pallet-xyk = { path = "../../pallets/xyk" } +parachain-staking = { path = "../../pallets/parachain-staking" } +xyk-runtime-api = { path = "../../pallets/xyk/runtime-api" } [features] default = ["with-kusama-runtime"] with-kusama-runtime = [ - "mangata-kusama-runtime", + # "mangata-kusama-runtime", ] diff --git a/runtime/integration-test/src/bootstrap.rs b/runtime/integration-test/src/bootstrap.rs index ac619fa03e..92561ac201 100644 --- a/runtime/integration-test/src/bootstrap.rs +++ b/runtime/integration-test/src/bootstrap.rs @@ -1,10 +1,3 @@ -use frame_support::{assert_err, assert_ok, traits::OnInitialize}; -use std::default::Default; - -use mangata_types::{ - assets::{CustomMetadata, XykMetadata}, - AccountId, -}; use pallet_bootstrap::{BootstrapPhase, Phase}; use crate::setup::*; @@ -22,8 +15,8 @@ fn bootstrap_updates_metadata_and_creates_pool_correctly() { ASSET_ID_1, AssetMetadataOf { decimals: 18, - name: b"Asset".to_vec(), - symbol: b"Asset".to_vec(), + name: BoundedVec::truncate_from(b"Asset".to_vec()), + symbol: BoundedVec::truncate_from(b"Asset".to_vec()), location: None, existential_deposit: Default::default(), additional: CustomMetadata { diff --git a/runtime/integration-test/src/identity.rs b/runtime/integration-test/src/identity.rs index 4a7ae9882e..e4f7b48610 100644 --- a/runtime/integration-test/src/identity.rs +++ b/runtime/integration-test/src/identity.rs @@ -1,5 +1,4 @@ use crate::setup::*; -use frame_support::error::BadOrigin; #[test] fn identity_permissions_correct() { diff --git a/runtime/integration-test/src/proof_of_stake.rs b/runtime/integration-test/src/proof_of_stake.rs index 7458de8776..c2d52123fe 100644 --- a/runtime/integration-test/src/proof_of_stake.rs +++ b/runtime/integration-test/src/proof_of_stake.rs @@ -1,5 +1,5 @@ use crate::setup::*; -use frame_support::traits::Hooks; +use frame_support::traits::{OnFinalize, OnInitialize}; use orml_tokens::MultiTokenCurrencyExtended; type TokensOf = ::Currency; diff --git a/runtime/integration-test/src/setup.rs b/runtime/integration-test/src/setup.rs index 6bc4dfd02d..8dad8966da 100644 --- a/runtime/integration-test/src/setup.rs +++ b/runtime/integration-test/src/setup.rs @@ -1,10 +1,12 @@ pub use std::default::Default; -use frame_support::traits::GenesisBuild; -pub use frame_support::{assert_err, assert_noop, assert_ok, dispatch::DispatchResultWithPostInfo}; +pub use frame_support::{ + assert_err, assert_noop, assert_ok, dispatch::DispatchResultWithPostInfo, error::BadOrigin, + traits::OnInitialize, +}; pub use orml_traits::currency::{MultiCurrency, MultiCurrencyExtended}; pub use sp_io::TestExternalities; -pub use sp_runtime::{codec::Encode, traits::BadOrigin, MultiAddress, Permill}; +pub use sp_runtime::{codec::Encode, BoundedVec, BuildStorage, MultiAddress, Permill}; pub use xcm::latest::prelude::*; #[cfg(feature = "with-kusama-runtime")] @@ -21,12 +23,11 @@ mod kusama_imports { pub use mangata_kusama_runtime::{ xcm_config::*, AccountId, AssetRegistry, Balance, Bootstrap, CustomMetadata, Identity, PolkadotXcm, ProofOfStake, Proxy, Runtime, RuntimeCall, RuntimeOrigin, System, TokenId, - Tokens, VersionedMultiLocation, XTokens, XcmMetadata, XcmpQueue, Xyk, XykMetadata, + Tokens, XTokens, XcmMetadata, XcmpQueue, Xyk, XykMetadata, }; - pub use xcm::latest::Weight as XcmWeight; + pub use xcm::{latest::Weight as XcmWeight, VersionedMultiLocation}; pub const NATIVE_ASSET_ID: TokenId = common_runtime::tokens::MGX_TOKEN_ID; - pub const RELAY_ASSET_ID: TokenId = common_runtime::tokens::RELAY_TOKEN_ID; } /// Accounts @@ -82,7 +83,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let _ = env_logger::builder().is_test(true).try_init(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); orml_tokens::GenesisConfig:: { tokens_endowment: self.balances, @@ -108,14 +109,17 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - >::assimilate_storage( - ¶chain_info::GenesisConfig { parachain_id: self.parachain_id.into() }, + >::assimilate_storage( + ¶chain_info::GenesisConfig { + parachain_id: self.parachain_id.into(), + ..Default::default() + }, &mut t, ) .unwrap(); - >::assimilate_storage( - &pallet_xcm::GenesisConfig { safe_xcm_version: Some(2) }, + >::assimilate_storage( + &pallet_xcm::GenesisConfig { safe_xcm_version: Some(3), ..Default::default() }, &mut t, ) .unwrap(); diff --git a/runtime/integration-test/src/xcm/kusama_xcm_transfer.rs b/runtime/integration-test/src/xcm/kusama_xcm_transfer.rs index be547c8b05..072aa01c79 100644 --- a/runtime/integration-test/src/xcm/kusama_xcm_transfer.rs +++ b/runtime/integration-test/src/xcm/kusama_xcm_transfer.rs @@ -19,7 +19,7 @@ fn asset_location(para: u32, key: Vec) -> VersionedMultiLocation { } fn reserve_account(id: u32) -> AccountId { - polkadot_parachain::primitives::Sibling::from(id).into_account_truncating() + polkadot_parachain_primitives::primitives::Sibling::from(id).into_account_truncating() } #[test] @@ -49,7 +49,7 @@ fn transfer_to_relay_chain() { let weight: XcmWeight = Weight::from_parts(299_506_000, 0); let fee = WeightToFee::weight_to_fee(&weight); - assert_eq!(94_172_727, fee); + assert_eq!(80_056_560, fee); Mangata::execute_with(|| { assert_ok!(XTokens::transfer( @@ -72,7 +72,6 @@ fn transfer_to_relay_chain() { #[test] fn transfer_asset() { - TestNet::reset(); let unit = unit(18); let fee = native_per_second_as_fee(4); let registered_asset_id = RELAY_ASSET_ID + 1; @@ -86,8 +85,8 @@ fn transfer_asset() { RuntimeOrigin::root(), AssetMetadataOf { decimals: 18, - name: b"MGX".to_vec(), - symbol: b"MGX".to_vec(), + name: BoundedVec::truncate_from(b"MGX".to_vec()), + symbol: BoundedVec::truncate_from(b"MGX".to_vec()), location: None, existential_deposit: Default::default(), additional: CustomMetadata { @@ -186,7 +185,6 @@ fn transfer_asset() { #[test] fn receive_asset() { - TestNet::reset(); let unit = unit(18); let registered_asset_id = RELAY_ASSET_ID + 1; @@ -225,8 +223,8 @@ fn receive_asset() { RuntimeOrigin::root(), AssetMetadataOf { decimals: 18, - name: b"TKN_f".to_vec(), - symbol: b"TKN_f".to_vec(), + name: BoundedVec::truncate_from(b"TKN_f".to_vec()), + symbol: BoundedVec::truncate_from(b"TKN_f".to_vec()), location: Some(asset_location(SIBLING_ID, NATIVE_ASSET_ID.encode())), existential_deposit: Default::default(), additional: Default::default(), @@ -310,7 +308,7 @@ fn receive_asset() { assert!(System::events().iter().any(|r| matches!( r.event, mangata_kusama_runtime::RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::Success { message_hash: Some(_), .. } + cumulus_pallet_xcmp_queue::Event::Success { message_hash: _, .. } ) ))); assert_eq!(Tokens::free_balance(registered_asset_id, &AccountId::from(BOB)), 20 * unit); @@ -319,8 +317,6 @@ fn receive_asset() { #[test] fn send_arbitrary_xcm_fails() { - TestNet::reset(); - Mangata::execute_with(|| { assert_noop!( PolkadotXcm::send( diff --git a/runtime/integration-test/src/xcm/mod.rs b/runtime/integration-test/src/xcm/mod.rs index b8a4689d1c..75bb443cca 100644 --- a/runtime/integration-test/src/xcm/mod.rs +++ b/runtime/integration-test/src/xcm/mod.rs @@ -1,8 +1,8 @@ -#[cfg(feature = "with-kusama-runtime")] -pub mod kusama_test_net; +// #[cfg(feature = "with-kusama-runtime")] +// pub mod kusama_test_net; -#[cfg(feature = "with-kusama-runtime")] -pub mod kusama_xcm_transfer; +// #[cfg(feature = "with-kusama-runtime")] +// pub mod kusama_xcm_transfer; pub use fee_test::{asset_unit_cost, native_per_second_as_fee, relay_per_second_as_fee}; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; @@ -70,12 +70,12 @@ fn weight_to_fee_works() { let weight: Weight = base_weight.saturating_mul(4); let fee = WeightToFee::weight_to_fee(&weight); - assert_eq!(1_257_707_380, fee); + assert_eq!(1_069_181_380, fee); // transfer_to_relay_chain weight in KusamaRelay let weight: Weight = Weight::from_parts(299_506_000, 0); let fee = WeightToFee::weight_to_fee(&weight); - assert_eq!(94_172_727, fee); + assert_eq!(80_056_560, fee); } // Mangata diff --git a/runtime/integration-test/src/xyk.rs b/runtime/integration-test/src/xyk.rs index 5579650dae..97c54acf98 100644 --- a/runtime/integration-test/src/xyk.rs +++ b/runtime/integration-test/src/xyk.rs @@ -12,8 +12,8 @@ fn test_env(xyk_metadata: Option) -> TestExternalities { ASSET_ID_1, AssetMetadataOf { decimals: 18, - name: b"Asset".to_vec(), - symbol: b"Asset".to_vec(), + name: BoundedVec::truncate_from(b"Asset".to_vec()), + symbol: BoundedVec::truncate_from(b"Asset".to_vec()), location: None, existential_deposit: Default::default(), additional: CustomMetadata { xyk: xyk_metadata, ..CustomMetadata::default() }, diff --git a/runtime/mangata-kusama/Cargo.toml b/runtime/mangata-kusama/Cargo.toml index 9c6ca2cd7d..2ae438e32b 100644 --- a/runtime/mangata-kusama/Cargo.toml +++ b/runtime/mangata-kusama/Cargo.toml @@ -9,11 +9,11 @@ license = "Unlicense" targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } [dependencies] -hex-literal = { version = '0.3.1' } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +hex-literal = { version = "0.3.1" } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.137", optional = true, features = ["derive"] } @@ -21,97 +21,96 @@ smallvec = "1.6.1" static_assertions = "1.1.0" # Local Dependencies -common-runtime = { path = '../common', default-features = false, version = '4.0.0' } -pallet-xyk = { path = '../../pallets/xyk', default-features = false, version = '0.1.0' } -pallet-proof-of-stake = { path = '../../pallets/proof-of-stake', default-features = false, version = '0.1.0' } -pallet-bootstrap = { path = '../../pallets/bootstrap', default-features = false, version = '0.1.0' } -xyk-runtime-api = { path = '../../pallets/xyk/runtime-api', default-features = false, version = '2.0.0' } -pallet-sudo-origin = { path = '../../pallets/sudo-origin', default-features = false } -pallet-issuance = { path = '../../pallets/issuance', default-features = false } -pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', default-features = false } -pallet-maintenance = { path = '../../pallets/maintenance', default-features = false } -pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false} -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +common-runtime = { path = "../common", default-features = false, version = "4.0.0" } +pallet-bootstrap = { path = "../../pallets/bootstrap", default-features = false, version = "0.1.0" } +pallet-fee-lock = { path = "../../pallets/fee-lock", default-features = false } +pallet-issuance = { path = "../../pallets/issuance", default-features = false } +pallet-maintenance = { path = "../../pallets/maintenance", default-features = false } +pallet-multipurpose-liquidity = { path = "../../pallets/multipurpose-liquidity", default-features = false } +pallet-proof-of-stake = { path = "../../pallets/proof-of-stake", default-features = false, version = "0.1.0" } +pallet-sudo-origin = { path = "../../pallets/sudo-origin", default-features = false } +pallet-xyk = { path = "../../pallets/xyk", default-features = false, version = "0.1.0" } +parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } +xyk-runtime-api = { path = "../../pallets/xyk/runtime-api", default-features = false, version = "2.0.0" } # Substrate Dependencies ## Substrate Primitive Dependencies -mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } - +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-utility-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-block-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-consensus-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-inherents = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-offchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-storage = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-transaction-pool = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-ver = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-version = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-weights = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate FRAME Dependencies -frame-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +ver-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate Pallet Dependencies -pallet-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +pallet-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-authorship = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-balances = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-collective-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-identity = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-proxy = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-treasury = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Open-Runtime-Module-Library Dependencies -orml-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-traits = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xtokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm-support = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-unknown-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-asset-registry = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +orml-asset-registry = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-traits = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-unknown-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm-support = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xtokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } # Cumulus dependencies -cumulus-pallet-aura-ext = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-dmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-parachain-system = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcm = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-core = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-timestamp = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-utility = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -parachain-info = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-session-benchmarking = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false, optional = true } +cumulus-pallet-aura-ext = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-dmp-queue = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-session-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +cumulus-pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +parachain-info = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Polkadot Dependencies -pallet-xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev", default-features = false } -xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-executor = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } - -# Staking dependencies -parachain-staking = { default-features = false, git = "https://github.com/mangata-finance/moonbeam.git", branch = "mangata-dev" } +pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-parachain-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Crowdloan dependencies -pallet-crowdloan-rewards = { default-features = false, git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "mangata-dev" } +pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "upgrade/v1.1.0", default-features = false } [features] default = [ @@ -119,27 +118,39 @@ default = [ ] std = [ "codec/std", - "serde", - "scale-info/std", - "log/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-ver/std", - "sp-version/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", "frame-executive/std", "frame-support/std", + "frame-system-rpc-runtime-api/std", "frame-system/std", + "log/std", + "mangata-support/std", + "mangata-types/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-traits/std", + "orml-unknown-tokens/std", + "orml-xcm-support/std", + "orml-xcm/std", + "orml-xtokens/std", "pallet-aura/std", "pallet-authorship/std", + "pallet-bootstrap/std", + "pallet-collective-mangata/std", + "pallet-crowdloan-rewards/std", + "pallet-fee-lock/std", + "pallet-identity/std", + "pallet-issuance/std", + "pallet-maintenance/std", + "pallet-multipurpose-liquidity/std", + "pallet-proof-of-stake/std", "pallet-proxy/std", "pallet-session/std", "pallet-sudo-mangata/std", @@ -147,127 +158,117 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-mangata-rpc-runtime-api/std", "pallet-transaction-payment-mangata/std", + "pallet-treasury/std", "pallet-utility-mangata/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "cumulus-primitives-utility/std", - "cumulus-pallet-dmp-queue/std", + "pallet-vesting-mangata/std", + "pallet-xyk/std", "parachain-info/std", - "polkadot-parachain/std", + "parachain-staking/std", + "polkadot-parachain-primitives/std", "polkadot-runtime-common/std", + "scale-info/std", + "serde", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-storage/std", + "sp-transaction-pool/std", + "sp-ver/std", + "sp-version/std", + "ver-api/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", - "ver-api/std", - "mangata-types/std", - "orml-traits/std", - "orml-tokens/std", - "pallet-treasury/std", - "pallet-xyk/std", - "pallet-proof-of-stake/std", - "pallet-bootstrap/std", "xyk-runtime-api/std", - "parachain-staking/std", - "orml-xtokens/std", - "orml-xcm-support/std", - "orml-unknown-tokens/std", - "orml-xcm/std", - "orml-asset-registry/std", - "pallet-issuance/std", - "pallet-vesting-mangata/std", - "pallet-crowdloan-rewards/std", - "pallet-collective-mangata/std", - "frame-system-rpc-runtime-api/std", - "pallet-multipurpose-liquidity/std", - "mangata-support/std", - "pallet-fee-lock/std", - "pallet-identity/std", - "pallet-maintenance/std", ] try-runtime = [ - "frame-support/try-runtime", - "frame-try-runtime", + "common-runtime/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", - "polkadot-runtime-common/try-runtime", - "pallet-multipurpose-liquidity/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "pallet-timestamp/try-runtime", - "parachain-info/try-runtime", + "frame-try-runtime", + "orml-asset-registry/try-runtime", "orml-tokens/try-runtime", - "pallet-transaction-payment-mangata/try-runtime", - "pallet-xyk/try-runtime", - "pallet-proof-of-stake/try-runtime", - "pallet-vesting-mangata/try-runtime", - "pallet-crowdloan-rewards/try-runtime", - "pallet-issuance/try-runtime", - "pallet-authorship/try-runtime", - "parachain-staking/try-runtime", - "pallet-session/try-runtime", - "pallet-aura/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "pallet-xcm/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", - "orml-xtokens/try-runtime", "orml-unknown-tokens/try-runtime", "orml-xcm/try-runtime", - "orml-asset-registry/try-runtime", - "pallet-treasury/try-runtime", - "pallet-sudo-mangata/try-runtime", - "pallet-sudo-origin/try-runtime", - "pallet-collective-mangata/try-runtime", + "orml-xtokens/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", "pallet-bootstrap/try-runtime", - "pallet-utility-mangata/try-runtime", - "pallet-proxy/try-runtime", + "pallet-collective-mangata/try-runtime", + "pallet-crowdloan-rewards/try-runtime", "pallet-fee-lock/try-runtime", "pallet-identity/try-runtime", + "pallet-issuance/try-runtime", "pallet-maintenance/try-runtime", - "sp-runtime/try-runtime" + "pallet-multipurpose-liquidity/try-runtime", + "pallet-proof-of-stake/try-runtime", + "pallet-proxy/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo-mangata/try-runtime", + "pallet-sudo-origin/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment-mangata/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility-mangata/try-runtime", + "pallet-vesting-mangata/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xyk/try-runtime", + "parachain-info/try-runtime", + "parachain-staking/try-runtime", + "polkadot-runtime-common/try-runtime", + "sp-runtime/try-runtime", ] fast-runtime = ["common-runtime/fast-runtime"] runtime-benchmarks = [ "common-runtime/runtime-benchmarks", - "polkadot-primitives/runtime-benchmarks", - "pallet-maintenance/runtime-benchmarks", - "polkadot-parachain/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "xcm-executor/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-system-benchmarking", "frame-support/runtime-benchmarks", + "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "pallet-collective-mangata/runtime-benchmarks", "orml-asset-registry/runtime-benchmarks", "orml-tokens/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", - "cumulus-pallet-session-benchmarking/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "pallet-xyk/runtime-benchmarks", - "pallet-proof-of-stake/runtime-benchmarks", - "parachain-staking/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", + "pallet-bootstrap/runtime-benchmarks", + "pallet-collective-mangata/runtime-benchmarks", "pallet-crowdloan-rewards/runtime-benchmarks", - "pallet-utility-mangata/runtime-benchmarks", - "pallet-vesting-mangata/runtime-benchmarks", + "pallet-fee-lock/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-issuance/runtime-benchmarks", - "pallet-bootstrap/runtime-benchmarks", + "pallet-maintenance/runtime-benchmarks", "pallet-multipurpose-liquidity/runtime-benchmarks", + "pallet-proof-of-stake/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", - "pallet-fee-lock/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-utility-mangata/runtime-benchmarks", + "pallet-vesting-mangata/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xyk/runtime-benchmarks", + "parachain-staking/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", ] diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index ac4dc22e4e..97363c575a 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -3,6 +3,7 @@ #![recursion_limit = "256"] use codec::Encode; +pub use common_runtime::{currency::*, deposit, runtime_types, tokens, types::*, CallType}; use frame_support::{ construct_runtime, parameter_types, traits::{Everything, InstanceFilter}, @@ -11,24 +12,24 @@ use frame_support::{ #[cfg(any(feature = "std", test))] pub use frame_system::Call as SystemCall; use frame_system::EnsureRoot; +use mangata_support::traits::ProofOfStakeRewardsApi; +pub use mangata_types::assets::{CustomMetadata, XcmMetadata, XykMetadata}; pub use orml_tokens; - +pub use pallet_issuance::IssuanceInfo; pub use pallet_sudo_mangata; - -use pallet_vesting_mangata::VestingInfo; -// Polkadot Imports +pub use pallet_sudo_origin; +pub use pallet_xyk; pub use polkadot_runtime_common::BlockHashCount; - use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ create_runtime_str, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - StaticLookup, + SignedExtension, StaticLookup, }, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, @@ -43,21 +44,8 @@ use sp_std::{ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use static_assertions::const_assert; -pub use xcm::{latest::prelude::*, VersionedMultiLocation}; - -pub use common_runtime::{currency::*, deposit, runtime_types, tokens, CallType}; - -use mangata_support::traits::ProofOfStakeRewardsApi; -pub use mangata_types::{ - assets::{CustomMetadata, XcmMetadata, XykMetadata}, - AccountId, Address, Amount, Balance, BlockNumber, Hash, Index, Signature, TokenId, -}; -pub use pallet_issuance::IssuanceInfo; -pub use pallet_sudo_origin; -pub use pallet_xyk; -// XCM Imports - use xyk_runtime_api::RpcAssetMetadata; + // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); @@ -89,9 +77,15 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - common_runtime::migration::AssetRegistryMigration, + Migrations, >; +type Migrations = ( + common_runtime::migration::AssetRegistryMigration, + pallet_xcm::migration::v1::VersionUncheckedMigrateToV1, + orml_unknown_tokens::Migration, +); + /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -149,19 +143,17 @@ impl frame_system::Config for Runtime { /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; + /// The block type. + type Block = Block; /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; - /// The header type. - type Header = runtime_types::Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). @@ -449,11 +441,13 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = cfg::pallet_aura::MaxAuthorities; + type AllowMultipleBlocksPerSlot = ConstBool; } impl pallet_sudo_mangata::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type WeightInfo = (); } impl pallet_sudo_origin::Config for Runtime { @@ -474,6 +468,8 @@ impl pallet_collective_mangata::Config for Runtime { type FoundationAccountsProvider = cfg::pallet_maintenance::FoundationAccountsProvider; type DefaultVote = pallet_collective_mangata::PrimeDefaultVote; type WeightInfo = weights::pallet_collective_mangata_weights::ModuleWeight; + type SetMembersOrigin = cfg::pallet_collective_mangata::SetMembersOrigin; + type MaxProposalWeight = cfg::pallet_collective_mangata::MaxProposalWeight; } // To ensure that BlocksPerRound is not zero, breaking issuance calculations @@ -511,6 +507,10 @@ impl parachain_staking::Config for Runtime { } impl parachain_staking::StakingBenchmarkConfig for Runtime { + #[cfg(feature = "runtime-benchmarks")] + type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type CurrencyId = TokenId; #[cfg(feature = "runtime-benchmarks")] type RewardsApi = ProofOfStake; #[cfg(feature = "runtime-benchmarks")] @@ -556,6 +556,8 @@ impl pallet_vesting_mangata::Config for Runtime { // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 50; + type UnvestedFundsAllowedWithdrawReasons = + cfg::pallet_vesting_mangata::UnvestedFundsAllowedWithdrawReasons; } impl pallet_crowdloan_rewards::Config for Runtime { @@ -596,8 +598,6 @@ impl orml_xcm::Config for Runtime { type SovereignOrigin = EnsureRoot; } -use common_runtime::config::orml_asset_registry::AssetMetadataOf; - impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CustomMetadata = CustomMetadata; @@ -606,10 +606,12 @@ impl orml_asset_registry::Config for Runtime { type AssetProcessor = cfg::orml_asset_registry::SequentialIdWithCreation; type Balance = Balance; type WeightInfo = weights::orml_asset_registry_weights::ModuleWeight; + type StringLimit = cfg::orml_asset_registry::StringLimit; } use cfg::pallet_proxy::ProxyType; +// TODO: ideally should be moved to common runtime impl InstanceFilter for ProxyType { fn filter(&self, c: &RuntimeCall) -> bool { match self { @@ -668,73 +670,68 @@ impl pallet_maintenance::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { // System support stuff. - System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - ParachainSystem: cumulus_pallet_parachain_system::{ - Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, - } = 1, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, - Utility: pallet_utility_mangata::{Pallet, Call, Event} = 4, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 5, - Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event} = 6, + System: frame_system = 0, + ParachainSystem: cumulus_pallet_parachain_system = 1, + Timestamp: pallet_timestamp = 2, + ParachainInfo: parachain_info = 3, + Utility: pallet_utility_mangata = 4, + Proxy: pallet_proxy = 5, + Maintenance: pallet_maintenance = 6, // Monetary stuff. - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config} = 10, - TransactionPayment: pallet_transaction_payment_mangata::{Pallet, Storage, Event} = 11, + Tokens: orml_tokens = 10, + TransactionPayment: pallet_transaction_payment_mangata = 11, // Xyk stuff - Xyk: pallet_xyk::{Pallet, Call, Storage, Event, Config} = 13, - ProofOfStake: pallet_proof_of_stake::{Pallet, Call, Storage, Event} = 14, + Xyk: pallet_xyk = 13, + ProofOfStake: pallet_proof_of_stake = 14, // Fee Locks - FeeLock: pallet_fee_lock::{Pallet, Storage, Call, Event, Config} = 15, + FeeLock: pallet_fee_lock = 15, // Vesting - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event} = 17, + Vesting: pallet_vesting_mangata = 17, // Crowdloan - Crowdloan: pallet_crowdloan_rewards::{Pallet, Call, Storage, Event} = 18, + Crowdloan: pallet_crowdloan_rewards = 18, // Issuance - Issuance: pallet_issuance::{Pallet, Event, Storage, Call} = 19, + Issuance: pallet_issuance = 19, // MultiPurposeLiquidity - MultiPurposeLiquidity: pallet_multipurpose_liquidity::{Pallet, Call, Storage, Event} = 20, + MultiPurposeLiquidity: pallet_multipurpose_liquidity = 20, // Bootstrap - Bootstrap: pallet_bootstrap::{Pallet, Call, Storage, Event} = 21, + Bootstrap: pallet_bootstrap = 21, // Collator support. The order of these 4 are important and shall not change. - Authorship: pallet_authorship::{Pallet, Storage} = 30, - ParachainStaking: parachain_staking::{Pallet, Call, Storage, Event, Config} = 31, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 32, - Aura: pallet_aura::{Pallet, Storage, Config} = 33, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 34, + Authorship: pallet_authorship = 30, + ParachainStaking: parachain_staking = 31, + Session: pallet_session = 32, + Aura: pallet_aura = 33, + AuraExt: cumulus_pallet_aura_ext = 34, // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 40, - PolkadotXcm: pallet_xcm::{Pallet, Storage, Call, Event, Origin, Config} = 41, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 42, - DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 43, + XcmpQueue: cumulus_pallet_xcmp_queue = 40, + PolkadotXcm: pallet_xcm = 41, + CumulusXcm: cumulus_pallet_xcm = 42, + DmpQueue: cumulus_pallet_dmp_queue = 43, // ORML XCM - XTokens: orml_xtokens::{Pallet, Storage, Call, Event} = 50, - UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 51, - OrmlXcm: orml_xcm::{Pallet, Call, Event} = 52, - AssetRegistry: orml_asset_registry::{Pallet, Call, Storage, Event, Config} = 53, + XTokens: orml_xtokens = 50, + UnknownTokens: orml_unknown_tokens = 51, + OrmlXcm: orml_xcm = 52, + AssetRegistry: orml_asset_registry = 53, // Governance stuff - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 60, - Sudo: pallet_sudo_mangata::{Pallet, Call, Config, Storage, Event} = 61, - SudoOrigin: pallet_sudo_origin::{Pallet, Call, Event} = 62, - Council: pallet_collective_mangata::::{Pallet, Call, Storage, Origin, Event, Config} = 63, - Identity: pallet_identity::{Pallet, Call, Storage, Event} = 64, + Treasury: pallet_treasury = 60, + Sudo: pallet_sudo_mangata = 61, + SudoOrigin: pallet_sudo_origin = 62, + Council: pallet_collective_mangata:: = 63, + Identity: pallet_identity = 64, } ); @@ -793,16 +790,20 @@ impl_runtime_apis! { System::set_block_seed(&seed); } - fn get_previous_block_txs() -> Vec> { System::get_previous_blocks_txs() } - fn pop_txs(count: u64) -> Vec>{ + fn pop_txs(count: u64) -> Vec> { System::pop_txs(count as usize) } - fn create_enqueue_txs_inherent(txs: Vec<::Extrinsic>) -> ::Extrinsic{ + fn create_enqueue_txs_inherent(txs: Vec<::Extrinsic>) -> ::Extrinsic { + for t in txs.iter() { + if let Some((_, _, extra)) = &t.signature { + let _ = extra.additional_signed(); + } + } UncheckedExtrinsic::new_unsigned( RuntimeCall::System(frame_system::Call::enqueue_txs{txs: txs.into_iter() @@ -814,7 +815,7 @@ impl_runtime_apis! { ).collect()})) } - fn can_enqueue_txs() -> bool{ + fn can_enqueue_txs() -> bool { System::can_enqueue_txs() } @@ -1030,7 +1031,7 @@ impl_runtime_apis! { } } - fn get_tradeable_tokens() -> Vec> { + fn get_tradeable_tokens() -> Vec> { orml_asset_registry::Metadata::::iter() .filter_map(|(token_id, metadata)| { if !metadata.name.is_empty() @@ -1040,8 +1041,8 @@ impl_runtime_apis! { let rpc_metadata = RpcAssetMetadata { token_id: token_id, decimals: metadata.decimals, - name: metadata.name.clone(), - symbol: metadata.symbol.clone(), + name: metadata.name.to_vec(), + symbol: metadata.symbol.to_vec(), }; Some(rpc_metadata) } else { @@ -1050,7 +1051,6 @@ impl_runtime_apis! { }) .collect::>() } - } impl sp_consensus_aura::AuraApi for Runtime { @@ -1082,6 +1082,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl sp_block_builder::BlockBuilder for Runtime { @@ -1133,8 +1141,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } @@ -1152,6 +1160,12 @@ impl_runtime_apis! { ) -> pallet_transaction_payment_mangata::FeeDetails { TransactionPayment::query_fee_details(uxt, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } impl cumulus_primitives_core::CollectCollationInfo for Runtime { @@ -1195,7 +1209,7 @@ impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; @@ -1212,10 +1226,20 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError}; + use sp_storage::TrackedStorageKey; use frame_system_benchmarking::Pallet as SystemBench; - impl frame_system_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} @@ -1244,57 +1268,7 @@ impl_runtime_apis! { } } -struct CheckInherents; - -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(block) - } -} - -// replace validate block function with its expanded version -#[doc(hidden)] -mod parachain_validate_block { - use crate::Runtime; - - #[no_mangle] - #[cfg(not(feature = "std"))] - unsafe fn validate_block(arguments: *mut u8, arguments_len: usize) -> u64 { - let args = cumulus_pallet_parachain_system::validate_block::sp_std::boxed::Box::from_raw( - cumulus_pallet_parachain_system::validate_block::sp_std::slice::from_raw_parts_mut( - arguments, - arguments_len, - ), - ); - let args = cumulus_pallet_parachain_system::validate_block::bytes::Bytes::from(args); - - // Then we decode from these bytes the `MemoryOptimizedValidationParams`. - let params = cumulus_pallet_parachain_system::validate_block::decode_from_bytes::< - cumulus_pallet_parachain_system::validate_block::MemoryOptimizedValidationParams, - >(args) - .expect("Invalid arguments to `validate_block`."); - - let res = - cumulus_pallet_parachain_system::validate_block::implementation::validate_block::<::RuntimeBlock, - cumulus_pallet_aura_ext::BlockExecutorVer, - crate::Runtime, - crate::CheckInherents>(params); - cumulus_pallet_parachain_system::validate_block::polkadot_parachain::write_result(&res) - } +cumulus_pallet_parachain_system::register_validate_block! { + Runtime = Runtime, + BlockExecutor = cumulus_pallet_aura_ext::BlockExecutorVer::, } diff --git a/runtime/mangata-kusama/src/weights/frame_system.rs b/runtime/mangata-kusama/src/weights/frame_system.rs index e2b9f77ec8..fd47e2c3f4 100644 --- a/runtime/mangata-kusama/src/weights/frame_system.rs +++ b/runtime/mangata-kusama/src/weights/frame_system.rs @@ -111,6 +111,10 @@ impl frame_system::WeightInfo for ModuleWeight { .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } + + fn set_code() -> Weight { + Weight::from_parts(0, 0) + } } // For backwards compatibility and tests diff --git a/runtime/mangata-kusama/src/xcm_config.rs b/runtime/mangata-kusama/src/xcm_config.rs index b8cba0eba7..83397b060a 100644 --- a/runtime/mangata-kusama/src/xcm_config.rs +++ b/runtime/mangata-kusama/src/xcm_config.rs @@ -1,30 +1,24 @@ #![cfg_attr(not(feature = "std"), no_std)] +use super::{ + AccountId, AllPalletsWithSystem, Balance, Maintenance, ParachainSystem, PolkadotXcm, Runtime, + RuntimeCall, RuntimeEvent, RuntimeOrigin, TokenId, +}; use common_runtime::tokens; - pub use frame_support::{ match_types, parameter_types, traits::{Everything, Get, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; - use orml_traits::location::AbsoluteReserveProvider; - use orml_xcm_support::MultiNativeAsset; - use sp_runtime::traits::ConstU32; - use xcm_builder::EnsureXcmOrigin; use xcm_executor::XcmExecutor; -use super::{ - AccountId, AllPalletsWithSystem, Balance, Maintenance, ParachainSystem, PolkadotXcm, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, TokenId, -}; - #[cfg(feature = "runtime-benchmarks")] -use cumulus_primitives_core::{MultiLocation, Parent}; +use xcm::prelude::{MultiLocation, Parent}; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -54,6 +48,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = (); type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } #[cfg(feature = "runtime-benchmarks")] @@ -87,6 +82,9 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/runtime/mangata-rococo/Cargo.toml b/runtime/mangata-rococo/Cargo.toml index 4d78499f5d..aa23bcdb20 100644 --- a/runtime/mangata-rococo/Cargo.toml +++ b/runtime/mangata-rococo/Cargo.toml @@ -9,11 +9,11 @@ license = "Unlicense" targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } [dependencies] -hex-literal = { version = '0.3.1' } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +hex-literal = { version = '0.3.1' } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.137", optional = true, features = ["derive"] } @@ -22,96 +22,95 @@ static_assertions = "1.1.0" # Local Dependencies common-runtime = { path = '../common', default-features = false, version = '4.0.0' } -pallet-xyk = { path = '../../pallets/xyk', default-features = false, version = '0.1.0' } -pallet-proof-of-stake = { path = '../../pallets/proof-of-stake', default-features = false, version = '0.1.0' } pallet-bootstrap = { path = '../../pallets/bootstrap', default-features = false, version = '0.1.0' } -xyk-runtime-api = { path = '../../pallets/xyk/runtime-api', default-features = false, version = '2.0.0' } -pallet-sudo-origin = { path = '../../pallets/sudo-origin', default-features = false } +pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false } pallet-issuance = { path = '../../pallets/issuance', default-features = false } -pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', default-features = false } pallet-maintenance = { path = '../../pallets/maintenance', default-features = false } -pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false} -mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', default-features = false } +pallet-proof-of-stake = { path = '../../pallets/proof-of-stake', default-features = false, version = '0.1.0' } +pallet-sudo-origin = { path = '../../pallets/sudo-origin', default-features = false } +pallet-xyk = { path = '../../pallets/xyk', default-features = false, version = '0.1.0' } +parachain-staking = { path = "../../pallets/parachain-staking", default-features = false } +xyk-runtime-api = { path = '../../pallets/xyk/runtime-api', default-features = false, version = '2.0.0' } # Substrate Dependencies ## Substrate Primitive Dependencies -mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +mangata-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +mangata-types = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-utility-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-block-builder = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-consensus-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-inherents = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-offchain = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-storage = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-transaction-pool = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-ver = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-version = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +sp-weights = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate FRAME Dependencies -frame-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -frame-system-benchmarking = { git = "https://github.com/mangata-finance/substrate", default-features = false, optional = true, branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-executive = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-system-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +frame-try-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } +ver-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } ## Substrate Pallet Dependencies -pallet-aura = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } -pallet-root-testing = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } +pallet-aura = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-authorship = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-collective-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-identity = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-proxy = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-root-testing = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-session = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-timestamp = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-treasury = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Open-Runtime-Module-Library Dependencies -orml-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-traits = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xtokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm-support = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-unknown-tokens = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-xcm = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -orml-asset-registry = { default-features = false, version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +orml-asset-registry = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-traits = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-unknown-tokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xcm-support = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } +orml-xtokens = { version = "0.4.1-dev", git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "develop", default-features = false } # Cumulus dependencies -cumulus-pallet-aura-ext = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-dmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-parachain-system = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcm = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-xcmp-queue = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-core = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-timestamp = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-primitives-utility = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -parachain-info = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false } -cumulus-pallet-session-benchmarking = { git = 'https://github.com/mangata-finance/cumulus', branch = "mangata-dev", default-features = false, optional = true } +cumulus-pallet-session-benchmarking = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false, optional = true } +cumulus-pallet-aura-ext = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-pallet-dmp-queue = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-pallet-parachain-system = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-pallet-xcm = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-pallet-xcmp-queue = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-primitives-core = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-primitives-timestamp = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +cumulus-primitives-utility = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } +parachain-info = { git = 'https://github.com/mangata-finance/polkadot-sdk', branch = "develop", default-features = false } # Polkadot Dependencies -polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot", branch = "mangata-dev", default-features = false } -pallet-xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-parachain = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-builder = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } -xcm-executor = { git = "https://github.com/mangata-finance/polkadot", default-features = false, branch = "mangata-dev" } - -# Staking dependencies -parachain-staking = { default-features = false, git = "https://github.com/mangata-finance/moonbeam", branch = "mangata-dev" } +pallet-xcm = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-parachain-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-primitives = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +polkadot-runtime-common = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false } # Crowdloan dependencies -pallet-crowdloan-rewards = { default-features = false, git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "mangata-dev" } +pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance/crowdloan-rewards", branch = "upgrade/v1.1.0", default-features = false } [features] default = [ @@ -119,163 +118,165 @@ default = [ ] std = [ "codec/std", - "serde", - "scale-info/std", - "log/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-ver/std", - "sp-version/std", - "frame-executive/std", - "frame-support/std", - "frame-system/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-proxy/std", - "pallet-session/std", - "pallet-sudo-mangata/std", - "pallet-sudo-origin/std", - "pallet-timestamp/std", - "pallet-transaction-payment-mangata-rpc-runtime-api/std", - "pallet-transaction-payment-mangata/std", - "pallet-utility-mangata/std", "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", + "cumulus-pallet-session-benchmarking/std", "cumulus-pallet-xcm/std", "cumulus-pallet-xcmp-queue/std", "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-session-benchmarking/std", "frame-benchmarking/std", + "frame-executive/std", + "frame-support/std", "frame-system-benchmarking/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", "frame-try-runtime/std", - "polkadot-primitives/std", - "sp-weights/std", - "parachain-info/std", - "polkadot-parachain/std", - "polkadot-runtime-common/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", - "ver-api/std", + "log/std", + "mangata-support/std", "mangata-types/std", - "orml-traits/std", + "orml-asset-registry/std", "orml-tokens/std", - "pallet-treasury/std", - "pallet-xyk/std", - "pallet-proof-of-stake/std", - "pallet-bootstrap/std", - "xyk-runtime-api/std", - "parachain-staking/std", - "orml-xtokens/std", - "orml-xcm-support/std", + "orml-traits/std", "orml-unknown-tokens/std", + "orml-xcm-support/std", "orml-xcm/std", - "orml-asset-registry/std", - "pallet-issuance/std", - "pallet-vesting-mangata/std", - "pallet-crowdloan-rewards/std", - "frame-system-rpc-runtime-api/std", + "orml-xtokens/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-bootstrap/std", "pallet-collective-mangata/std", - "pallet-multipurpose-liquidity/std", - "mangata-support/std", + "pallet-crowdloan-rewards/std", "pallet-fee-lock/std", "pallet-identity/std", + "pallet-issuance/std", "pallet-maintenance/std", + "pallet-multipurpose-liquidity/std", + "pallet-proof-of-stake/std", + "pallet-proxy/std", + "pallet-session/std", + "pallet-sudo-mangata/std", + "pallet-sudo-origin/std", + "pallet-timestamp/std", + "pallet-transaction-payment-mangata-rpc-runtime-api/std", + "pallet-transaction-payment-mangata/std", + "pallet-treasury/std", + "pallet-utility-mangata/std", + "pallet-vesting-mangata/std", + "pallet-xyk/std", + "parachain-info/std", + "parachain-staking/std", + "polkadot-parachain-primitives/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", + "scale-info/std", + "serde", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-storage/std", + "sp-transaction-pool/std", + "sp-ver/std", + "sp-version/std", + "sp-weights/std", + "ver-api/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "xyk-runtime-api/std", ] try-runtime = [ - "sp-runtime/try-runtime", - "frame-support/try-runtime", - "frame-try-runtime", + "common-runtime/try-runtime", + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", "frame-executive/try-runtime", + "frame-support/try-runtime", "frame-system/try-runtime", - "polkadot-runtime-common/try-runtime", - "pallet-multipurpose-liquidity/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "pallet-timestamp/try-runtime", - "parachain-info/try-runtime", + "frame-try-runtime", + "orml-asset-registry/try-runtime", "orml-tokens/try-runtime", - "pallet-transaction-payment-mangata/try-runtime", - "pallet-xyk/try-runtime", - "pallet-proof-of-stake/try-runtime", - "pallet-vesting-mangata/try-runtime", - "pallet-crowdloan-rewards/try-runtime", - "pallet-issuance/try-runtime", - "pallet-authorship/try-runtime", - "parachain-staking/try-runtime", - "pallet-session/try-runtime", - "pallet-aura/try-runtime", - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "pallet-xcm/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", - "orml-xtokens/try-runtime", "orml-unknown-tokens/try-runtime", "orml-xcm/try-runtime", - "orml-asset-registry/try-runtime", - "pallet-treasury/try-runtime", - "pallet-sudo-mangata/try-runtime", - "pallet-sudo-origin/try-runtime", - "pallet-collective-mangata/try-runtime", + "orml-xtokens/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", "pallet-bootstrap/try-runtime", - "pallet-utility-mangata/try-runtime", - "pallet-proxy/try-runtime", + "pallet-collective-mangata/try-runtime", + "pallet-crowdloan-rewards/try-runtime", "pallet-fee-lock/try-runtime", "pallet-identity/try-runtime", + "pallet-issuance/try-runtime", "pallet-maintenance/try-runtime", - "pallet-root-testing/try-runtime" + "pallet-multipurpose-liquidity/try-runtime", + "pallet-proof-of-stake/try-runtime", + "pallet-proxy/try-runtime", + "pallet-root-testing/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo-mangata/try-runtime", + "pallet-sudo-origin/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment-mangata/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility-mangata/try-runtime", + "pallet-vesting-mangata/try-runtime", + "pallet-xcm/try-runtime", + "pallet-xyk/try-runtime", + "parachain-info/try-runtime", + "parachain-staking/try-runtime", + "polkadot-runtime-common/try-runtime", + "sp-runtime/try-runtime", ] fast-runtime = ["common-runtime/fast-runtime"] runtime-benchmarks = [ "common-runtime/runtime-benchmarks", - "polkadot-primitives/runtime-benchmarks", - "pallet-maintenance/runtime-benchmarks", - "polkadot-parachain/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "xcm-executor/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-system-benchmarking", "frame-support/runtime-benchmarks", + "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", "orml-tokens/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", - "orml-asset-registry/runtime-benchmarks", - "cumulus-pallet-session-benchmarking/runtime-benchmarks", - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "pallet-xyk/runtime-benchmarks", - "pallet-proof-of-stake/runtime-benchmarks", - "parachain-staking/runtime-benchmarks", - "pallet-treasury/runtime-benchmarks", + "pallet-bootstrap/runtime-benchmarks", "pallet-collective-mangata/runtime-benchmarks", "pallet-crowdloan-rewards/runtime-benchmarks", - "pallet-utility-mangata/runtime-benchmarks", - "pallet-vesting-mangata/runtime-benchmarks", + "pallet-fee-lock/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-issuance/runtime-benchmarks", - "pallet-bootstrap/runtime-benchmarks", + "pallet-maintenance/runtime-benchmarks", "pallet-multipurpose-liquidity/runtime-benchmarks", + "pallet-proof-of-stake/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", - "pallet-fee-lock/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-utility-mangata/runtime-benchmarks", + "pallet-vesting-mangata/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "pallet-xyk/runtime-benchmarks", + "parachain-staking/runtime-benchmarks", + "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", ] diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index 4544151282..aded02d3ee 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -2,34 +2,36 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -use codec::{Decode, Encode}; +use codec::Encode; +pub use common_runtime::{ + consts::DAYS, currency::*, deposit, runtime_types, tokens, types::*, CallType, +}; use frame_support::{ construct_runtime, parameter_types, - traits::{Everything, Get, InstanceFilter}, + traits::{Everything, InstanceFilter}, weights::{constants::RocksDbWeight, Weight}, }; #[cfg(any(feature = "std", test))] pub use frame_system::Call as SystemCall; use frame_system::EnsureRoot; +use mangata_support::traits::ProofOfStakeRewardsApi; +pub use mangata_types::assets::{CustomMetadata, XcmMetadata, XykMetadata}; pub use orml_tokens; - +pub use pallet_issuance::IssuanceInfo; pub use pallet_sudo_mangata; - -use pallet_vesting_mangata::VestingInfo; -// Polkadot Imports +pub use pallet_sudo_origin; +pub use pallet_xyk; pub use polkadot_runtime_common::BlockHashCount; - -pub use common_runtime::{currency::*, deposit, runtime_types, tokens, CallType}; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_core::{crypto::KeyTypeId, ConstBool, OpaqueMetadata}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; use sp_runtime::{ create_runtime_str, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - StaticLookup, + SignedExtension, StaticLookup, }, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, @@ -44,19 +46,8 @@ use sp_std::{ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use static_assertions::const_assert; -pub use xcm::{latest::prelude::*, VersionedMultiLocation}; -// pub use constants::{fee::*, parachains::*}; -use mangata_support::traits::ProofOfStakeRewardsApi; -pub use mangata_types::{ - assets::{CustomMetadata, XcmMetadata, XykMetadata}, - AccountId, Address, Amount, Balance, BlockNumber, Hash, Index, Signature, TokenId, -}; -pub use pallet_issuance::IssuanceInfo; -pub use pallet_sudo_origin; -pub use pallet_xyk; -// XCM Imports - use xyk_runtime_api::RpcAssetMetadata; + // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); @@ -88,9 +79,14 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - common_runtime::migration::AssetRegistryMigration, + Migrations, >; +type Migrations = ( + pallet_xcm::migration::v1::VersionUncheckedMigrateToV1, + orml_unknown_tokens::Migration, +); + /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -124,8 +120,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { state_version: 0, }; -use common_runtime::consts::DAYS; - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -139,28 +133,34 @@ parameter_types! { use common_runtime::config as cfg; impl frame_system::Config for Runtime { - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; + /// The basic call filter to use in dispatchable. + type BaseCallFilter = Everything; + /// Block & extrinsics weights: base values and limits. + type BlockWeights = cfg::frame_system::RuntimeBlockWeights; + /// The maximum length of a block (in bytes). + type BlockLength = cfg::frame_system::RuntimeBlockLength; + /// The ubiquitous origin type. + type RuntimeOrigin = RuntimeOrigin; /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. - type Header = runtime_types::Header; + /// The block type. + type Block = Block; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; - /// The ubiquitous origin type. - type RuntimeOrigin = RuntimeOrigin; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = BlockHashCount; + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; /// Runtime version. type Version = Version; /// Converts a module to an index of this module in the runtime. @@ -171,16 +171,8 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// The basic call filter to use in dispatchable. - type BaseCallFilter = Everything; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = weights::frame_system_weights::ModuleWeight; - /// Block & extrinsics weights: base values and limits. - type BlockWeights = cfg::frame_system::RuntimeBlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = cfg::frame_system::RuntimeBlockLength; /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = cfg::frame_system::SS58Prefix; /// The action to take on a Runtime Upgrade @@ -230,7 +222,7 @@ parameter_types! { // This is because orml_tokens uses BoundedVec for Locks storage item and does not inform on failure // Balances uses WeakBoundedVec and so does not fail const_assert!( - cfg::orml_tokens::MaxLocks::get() >= + ::MaxLocks::get() >= ::MAX_VESTING_SCHEDULES ); @@ -393,11 +385,15 @@ impl pallet_transaction_payment_mangata::Config for Runtime { OnChargeTransactionHandler, FeeLock, >; - type OperationalFeeMultiplier = - cfg::pallet_transaction_payment_mangata::OperationalFeeMultiplier; - type WeightToFee = common_runtime::constants::fee::WeightToFee; type LengthToFee = cfg::pallet_transaction_payment_mangata::LengthToFee; + type WeightToFee = common_runtime::constants::fee::WeightToFee; type FeeMultiplierUpdate = cfg::pallet_transaction_payment_mangata::FeeMultiplierUpdate; + type OperationalFeeMultiplier = + cfg::pallet_transaction_payment_mangata::OperationalFeeMultiplier; +} + +parameter_types! { + pub const MaxCuratedTokens: u32 = 100; } impl pallet_fee_lock::Config for Runtime { @@ -444,11 +440,13 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = cfg::pallet_aura::MaxAuthorities; + type AllowMultipleBlocksPerSlot = ConstBool; } impl pallet_sudo_mangata::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type WeightInfo = (); } impl pallet_sudo_origin::Config for Runtime { @@ -485,6 +483,8 @@ impl pallet_collective_mangata::Config for Runtime { type FoundationAccountsProvider = cfg::pallet_maintenance::FoundationAccountsProvider; type DefaultVote = pallet_collective_mangata::PrimeDefaultVote; type WeightInfo = weights::pallet_collective_mangata_weights::ModuleWeight; + type SetMembersOrigin = cfg::pallet_collective_mangata::SetMembersOrigin; + type MaxProposalWeight = cfg::pallet_collective_mangata::MaxProposalWeight; } // To ensure that BlocksPerRound is not zero, breaking issuance calculations @@ -521,15 +521,19 @@ impl parachain_staking::Config for Runtime { type DefaultPayoutLimit = cfg::parachain_staking::DefaultPayoutLimit; } -impl pallet_xyk::XykBenchmarkingConfig for Runtime {} - impl parachain_staking::StakingBenchmarkConfig for Runtime { + #[cfg(feature = "runtime-benchmarks")] + type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type CurrencyId = TokenId; #[cfg(feature = "runtime-benchmarks")] type RewardsApi = ProofOfStake; #[cfg(feature = "runtime-benchmarks")] type Xyk = Xyk; } +impl pallet_xyk::XykBenchmarkingConfig for Runtime {} + // Issuance history must be kept for atleast the staking reward delay const_assert!( ::RewardPaymentDelay::get() <= @@ -566,6 +570,8 @@ impl pallet_vesting_mangata::Config for Runtime { // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the // highest number of schedules that encodes less than 2^10. const MAX_VESTING_SCHEDULES: u32 = 50; + type UnvestedFundsAllowedWithdrawReasons = + cfg::pallet_vesting_mangata::UnvestedFundsAllowedWithdrawReasons; } impl pallet_crowdloan_rewards::Config for Runtime { @@ -608,8 +614,6 @@ impl orml_xcm::Config for Runtime { impl pallet_root_testing::Config for Runtime {} -use common_runtime::config::orml_asset_registry::AssetMetadataOf; - impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CustomMetadata = CustomMetadata; @@ -618,7 +622,9 @@ impl orml_asset_registry::Config for Runtime { type AssetProcessor = cfg::orml_asset_registry::SequentialIdWithCreation; type Balance = Balance; type WeightInfo = weights::orml_asset_registry_weights::ModuleWeight; + type StringLimit = cfg::orml_asset_registry::StringLimit; } + use cfg::pallet_proxy::ProxyType; // TODO: ideally should be moved to common runtime @@ -680,74 +686,68 @@ impl pallet_maintenance::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { // System support stuff. - System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - ParachainSystem: cumulus_pallet_parachain_system::{ - Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, - } = 1, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, - Utility: pallet_utility_mangata::{Pallet, Call, Event} = 4, - Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 5, - Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event} = 6, - RootTesting: pallet_root_testing::{Pallet, Call, Storage} = 9, + System: frame_system = 0, + ParachainSystem: cumulus_pallet_parachain_system = 1, + Timestamp: pallet_timestamp = 2, + ParachainInfo: parachain_info = 3, + Utility: pallet_utility_mangata = 4, + Proxy: pallet_proxy = 5, + Maintenance: pallet_maintenance = 6, // Monetary stuff. - Tokens: orml_tokens::{Pallet, Storage, Call, Event, Config} = 10, - TransactionPayment: pallet_transaction_payment_mangata::{Pallet, Storage, Event} = 11, + Tokens: orml_tokens = 10, + TransactionPayment: pallet_transaction_payment_mangata = 11, // Xyk stuff - Xyk: pallet_xyk::{Pallet, Call, Storage, Event, Config} = 13, - ProofOfStake: pallet_proof_of_stake::{Pallet, Call, Storage, Event} = 14, + Xyk: pallet_xyk = 13, + ProofOfStake: pallet_proof_of_stake = 14, // Fee Locks - FeeLock: pallet_fee_lock::{Pallet, Storage, Call, Event, Config} = 15, + FeeLock: pallet_fee_lock = 15, // Vesting - Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event} = 17, + Vesting: pallet_vesting_mangata = 17, // Crowdloan - Crowdloan: pallet_crowdloan_rewards::{Pallet, Call, Storage, Event} = 18, + Crowdloan: pallet_crowdloan_rewards = 18, // Issuance - Issuance: pallet_issuance::{Pallet, Event, Storage, Call} = 19, + Issuance: pallet_issuance = 19, // MultiPurposeLiquidity - MultiPurposeLiquidity: pallet_multipurpose_liquidity::{Pallet, Call, Storage, Event} = 20, + MultiPurposeLiquidity: pallet_multipurpose_liquidity = 20, // Bootstrap - Bootstrap: pallet_bootstrap::{Pallet, Call, Storage, Event} = 21, + Bootstrap: pallet_bootstrap = 21, // Collator support. The order of these 4 are important and shall not change. - Authorship: pallet_authorship::{Pallet, Storage} = 30, - ParachainStaking: parachain_staking::{Pallet, Call, Storage, Event, Config} = 31, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 32, - Aura: pallet_aura::{Pallet, Storage, Config} = 33, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 34, + Authorship: pallet_authorship = 30, + ParachainStaking: parachain_staking = 31, + Session: pallet_session = 32, + Aura: pallet_aura = 33, + AuraExt: cumulus_pallet_aura_ext = 34, // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 40, - PolkadotXcm: pallet_xcm::{Pallet, Storage, Call, Event, Origin, Config} = 41, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 42, - DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 43, + XcmpQueue: cumulus_pallet_xcmp_queue = 40, + PolkadotXcm: pallet_xcm = 41, + CumulusXcm: cumulus_pallet_xcm = 42, + DmpQueue: cumulus_pallet_dmp_queue = 43, // ORML XCM - XTokens: orml_xtokens::{Pallet, Storage, Call, Event} = 50, - UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 51, - OrmlXcm: orml_xcm::{Pallet, Call, Event} = 52, - AssetRegistry: orml_asset_registry::{Pallet, Call, Storage, Event, Config} = 53, + XTokens: orml_xtokens = 50, + UnknownTokens: orml_unknown_tokens = 51, + OrmlXcm: orml_xcm = 52, + AssetRegistry: orml_asset_registry = 53, // Governance stuff - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 60, - Sudo: pallet_sudo_mangata::{Pallet, Call, Config, Storage, Event} = 61, - SudoOrigin: pallet_sudo_origin::{Pallet, Call, Event} = 62, - Council: pallet_collective_mangata::::{Pallet, Call, Storage, Origin, Event, Config} = 63, - Identity: pallet_identity::{Pallet, Call, Storage, Event} = 64, + Treasury: pallet_treasury = 60, + Sudo: pallet_sudo_mangata = 61, + SudoOrigin: pallet_sudo_origin = 62, + Council: pallet_collective_mangata:: = 63, + Identity: pallet_identity = 64, } ); @@ -761,8 +761,8 @@ mod benches { [frame_system, SystemBench::] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] - [orml_tokens, Tokens] [orml_asset_registry, AssetRegistry] + [orml_tokens, Tokens] [parachain_staking, ParachainStaking] [pallet_xyk, Xyk] [pallet_treasury, Treasury] @@ -810,24 +810,28 @@ impl_runtime_apis! { System::get_previous_blocks_txs() } - fn pop_txs(count: u64) -> Vec>{ + fn pop_txs(count: u64) -> Vec> { System::pop_txs(count as usize) } - fn create_enqueue_txs_inherent(txs: Vec<::Extrinsic>) -> ::Extrinsic{ + fn create_enqueue_txs_inherent(txs: Vec<::Extrinsic>) -> ::Extrinsic { + for t in txs.iter() { + if let Some((_, _, extra)) = &t.signature { + let _ = extra.additional_signed(); + } + } UncheckedExtrinsic::new_unsigned( - RuntimeCall::System(frame_system::Call::enqueue_txs{txs: - txs.into_iter() - .map(|tx| - ( - tx.signature.clone().and_then(|sig| ::Lookup::lookup(sig.0).ok()), - tx.encode() - ) - ) - .collect()})) + RuntimeCall::System(frame_system::Call::enqueue_txs{txs: + txs.into_iter() + .map(|tx| ( + tx.signature.clone().and_then(|sig| + ::Lookup::lookup(sig.0).ok() + ), + tx.encode()) + ).collect()})) } - fn can_enqueue_txs() -> bool{ + fn can_enqueue_txs() -> bool { System::can_enqueue_txs() } @@ -1043,7 +1047,7 @@ impl_runtime_apis! { } } - fn get_tradeable_tokens() -> Vec> { + fn get_tradeable_tokens() -> Vec> { orml_asset_registry::Metadata::::iter() .filter_map(|(token_id, metadata)| { if !metadata.name.is_empty() @@ -1053,8 +1057,8 @@ impl_runtime_apis! { let rpc_metadata = RpcAssetMetadata { token_id: token_id, decimals: metadata.decimals, - name: metadata.name.clone(), - symbol: metadata.symbol.clone(), + name: metadata.name.to_vec(), + symbol: metadata.symbol.to_vec(), }; Some(rpc_metadata) } else { @@ -1094,6 +1098,14 @@ impl_runtime_apis! { fn metadata() -> OpaqueMetadata { OpaqueMetadata::new(Runtime::metadata().into()) } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } } impl sp_block_builder::BlockBuilder for Runtime { @@ -1145,8 +1157,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } @@ -1164,6 +1176,12 @@ impl_runtime_apis! { ) -> pallet_transaction_payment_mangata::FeeDetails { TransactionPayment::query_fee_details(uxt, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } impl cumulus_primitives_core::CollectCollationInfo for Runtime { @@ -1207,7 +1225,7 @@ impl_runtime_apis! { Vec, Vec, ) { - use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; @@ -1224,10 +1242,20 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError}; + use sp_storage::TrackedStorageKey; use frame_system_benchmarking::Pallet as SystemBench; - impl frame_system_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} @@ -1256,57 +1284,7 @@ impl_runtime_apis! { } } -struct CheckInherents; - -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(block) - } -} - -// replace validate block function with its expanded version -#[doc(hidden)] -mod parachain_validate_block { - use crate::Runtime; - - #[no_mangle] - #[cfg(not(feature = "std"))] - unsafe fn validate_block(arguments: *mut u8, arguments_len: usize) -> u64 { - let args = cumulus_pallet_parachain_system::validate_block::sp_std::boxed::Box::from_raw( - cumulus_pallet_parachain_system::validate_block::sp_std::slice::from_raw_parts_mut( - arguments, - arguments_len, - ), - ); - let args = cumulus_pallet_parachain_system::validate_block::bytes::Bytes::from(args); - - // Then we decode from these bytes the `MemoryOptimizedValidationParams`. - let params = cumulus_pallet_parachain_system::validate_block::decode_from_bytes::< - cumulus_pallet_parachain_system::validate_block::MemoryOptimizedValidationParams, - >(args) - .expect("Invalid arguments to `validate_block`."); - - let res = - cumulus_pallet_parachain_system::validate_block::implementation::validate_block::<::RuntimeBlock, - cumulus_pallet_aura_ext::BlockExecutorVer, - crate::Runtime, - crate::CheckInherents>(params); - cumulus_pallet_parachain_system::validate_block::polkadot_parachain::write_result(&res) - } +cumulus_pallet_parachain_system::register_validate_block! { + Runtime = Runtime, + BlockExecutor = cumulus_pallet_aura_ext::BlockExecutorVer::, } diff --git a/runtime/mangata-rococo/src/weights/frame_system.rs b/runtime/mangata-rococo/src/weights/frame_system.rs index e2b9f77ec8..fd47e2c3f4 100644 --- a/runtime/mangata-rococo/src/weights/frame_system.rs +++ b/runtime/mangata-rococo/src/weights/frame_system.rs @@ -111,6 +111,10 @@ impl frame_system::WeightInfo for ModuleWeight { .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } + + fn set_code() -> Weight { + Weight::from_parts(0, 0) + } } // For backwards compatibility and tests diff --git a/runtime/mangata-rococo/src/xcm_config.rs b/runtime/mangata-rococo/src/xcm_config.rs index 6be6a91183..83397b060a 100644 --- a/runtime/mangata-rococo/src/xcm_config.rs +++ b/runtime/mangata-rococo/src/xcm_config.rs @@ -1,27 +1,24 @@ #![cfg_attr(not(feature = "std"), no_std)] +use super::{ + AccountId, AllPalletsWithSystem, Balance, Maintenance, ParachainSystem, PolkadotXcm, Runtime, + RuntimeCall, RuntimeEvent, RuntimeOrigin, TokenId, +}; use common_runtime::tokens; - pub use frame_support::{ match_types, parameter_types, traits::{Everything, Get, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; - use orml_traits::location::AbsoluteReserveProvider; use orml_xcm_support::MultiNativeAsset; - use sp_runtime::traits::ConstU32; - use xcm_builder::EnsureXcmOrigin; use xcm_executor::XcmExecutor; -use super::{ - AccountId, AllPalletsWithSystem, Balance, Maintenance, ParachainSystem, PolkadotXcm, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, TokenId, -}; -use cumulus_primitives_core::{MultiLocation, Parent}; +#[cfg(feature = "runtime-benchmarks")] +use xcm::prelude::{MultiLocation, Parent}; pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -51,6 +48,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = (); type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } #[cfg(feature = "runtime-benchmarks")] @@ -84,6 +82,9 @@ impl pallet_xcm::Config for Runtime { type WeightInfo = pallet_xcm::TestWeightInfo; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 30299a1708..caa6a41d1d 100755 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -6,7 +6,7 @@ if [ -z "${SKIP_BUILD}" ]; then else echo "build skipped because SKIP_BUILD flag is set" fi -BUILD_DIR=${BUILD_DIR:-${REPO_ROOT}/docker-cargo/release} +BUILD_DIR=${BUILD_DIR:-./docker-cargo/release} GIT_REV=$(git -C ${REPO_ROOT} rev-parse HEAD) if git -C ${REPO_ROOT} diff --quiet HEAD; then diff --git a/scripts/dev_manifest.sh b/scripts/dev_manifest.sh index 52c67c8ffd..2c42dc4750 100755 --- a/scripts/dev_manifest.sh +++ b/scripts/dev_manifest.sh @@ -14,7 +14,7 @@ fi ALL_DEPENDENCIES=`cargo tree --manifest-path $REPO_ROOT/Cargo.toml --prefix=none | cut -d " " -f 1 | sort | uniq` echo "" >> $MANIFEST_PATH -echo "# patch generated by ./scripts/dev_manifest.sh" >> $MANIFEST_PATH +echo "# patch generated by './scripts/dev_manifest.sh $LOCAL_SUBSTRATE_REPO_PATH'" >> $MANIFEST_PATH echo "[patch.\"https://github.com/mangata-finance/$(basename $LOCAL_SUBSTRATE_REPO_PATH)\"]" >> $MANIFEST_PATH # recursively find all packages from local repository and patch them temporarly @@ -26,7 +26,7 @@ for i in `find $LOCAL_SUBSTRATE_REPO_PATH -name Cargo.toml`; do PACKAGE_NAME=`sed -n 's/.*name.*=.*\"\(.*\)\"/\1/p' $i | head -1` IS_DEPENDENCY=`echo $ALL_DEPENDENCIES| sed 's/ /\n/g' | grep "^$PACKAGE_NAME$"` - if [ -n "$PACKAGE_NAME" ] && [ -n "$IS_DEPENDENCY" ]; then + if [ -n "$PACKAGE_NAME" ] && [ -n "$IS_DEPENDENCY" ]; then echo "$PACKAGE_NAME = { path = \"$PACKAGE_PATH\" }" >> $MANIFEST_PATH fi fi diff --git a/scripts/run_benchmark.sh b/scripts/run_benchmark.sh index ac3972d866..5f67e229bc 100755 --- a/scripts/run_benchmark.sh +++ b/scripts/run_benchmark.sh @@ -4,7 +4,7 @@ REPO_ROOT=$(dirname $(readlink -f $0))/../ mkdir ./benchmarks ${REPO_ROOT}/target/release/mangata-node benchmark pallet \ - --chain kusama-local \ + --chain mangata-kusama-local \ --execution wasm \ --wasm-execution compiled \ --pallet $1 \