diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..512de3b3e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + + +### What does it do? + +### What important points should reviewers know? + +### Is there something left for follow-up PRs? + +### What alternative implementations were considered? + +### Are there relevant PRs or issues? + + + + + + + +### References + diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e39b9c046..30b81bdff 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -33,12 +33,8 @@ jobs: uses: actions/checkout@v2 if: github.event_name == 'workflow_dispatch' - # TODO(#839): `rustup show` installs the rustc version specified in the `rust-toolchain` file - # according to https://rust-lang.github.io/rustup/overrides.html. We don't use actions-rs due - # to the lack of support of `rust-toolchain` files with TOML syntax: - # https://github.com/actions-rs/toolchain/issues/126. - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - name: Cache dependencies uses: Swatinem/rust-cache@v1 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..4087b70ee --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,56 @@ +name: Coverage + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + +jobs: + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install rust toolchain + run: rustup show + + - uses: actions-rs/install@v0.1 + with: + crate: grcov + use-tool-cache: true + + # No disk space: https://github.com/zeitgeistpm/zeitgeist/actions/runs/5085081984/jobs/9144298675?pr=1006 + # Workaround: https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 + - name: Free up disk space on GitHub hosted runners + run: | + # Ensure context is GitHub hosted runner + # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context + if [[ "${{ runner.name }}" == "GitHub Actions"* ]]; then + echo "Freeing up space in GitHub hosted runner" + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + fi + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Generate coverage report + run: ./scripts/tests/coverage.sh + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ runner.temp }}/zeitgeist-test-coverage.lcov + fail_ci_if_error: true + flags: tests + verbose: true + name: unit-tests \ No newline at end of file diff --git a/.github/workflows/docker-hub-parachain.yml b/.github/workflows/docker-hub-parachain.yml index ec6769c3e..278d0c8bb 100644 --- a/.github/workflows/docker-hub-parachain.yml +++ b/.github/workflows/docker-hub-parachain.yml @@ -25,7 +25,7 @@ jobs: images: | zeitgeistpm/zeitgeist-node-parachain tags: | - type=ref + type=semver,pattern={{version}} - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/.github/workflows/migration.yml b/.github/workflows/migration.yml index 02b4857cd..967dc6510 100644 --- a/.github/workflows/migration.yml +++ b/.github/workflows/migration.yml @@ -14,11 +14,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - # TODO(#839): `rustup show` installs the rustc version specified in the `rust-toolchain` file - # according to https://rust-lang.github.io/rustup/overrides.html. We don't use actions-rs due - # to the lack of support of `rust-toolchain` files with TOML syntax: - # https://github.com/actions-rs/toolchain/issues/126. - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - run: ./scripts/runtime-upgrade/test_runtime_upgrade.sh ${{ github.event.inputs.block }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 20dc806f4..a943202c1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,12 +17,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - # TODO(#839): `rustup show` installs the rustc version specified in the `rust-toolchain` file - # according to https://rust-lang.github.io/rustup/overrides.html. We don't use actions-rs due - # to the lack of support of `rust-toolchain` files with TOML syntax: - # https://github.com/actions-rs/toolchain/issues/126. - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - uses: actions-rs/install@v0.1 with: @@ -34,6 +30,26 @@ jobs: - name: Format run: ./scripts/tests/format.sh --check + copyright: + name: Copyright Notices + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + - name: Install check-license and dependencies + run: | + pip install scripts/check-license + pip install -r scripts/check-license/requirements.txt + - name: Query files changed + id: files_changed + uses: Ana06/get-changed-files@v1.2 + with: + filter: '*.rs$' + - name: Check copyright notices + run: check-license ${{ steps.files_changed.outputs.added_modified }} + checks: name: Checks runs-on: ubuntu-latest @@ -48,14 +64,15 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - name: Cache Dependencies - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Checks run: ./scripts/tests/${{ matrix.scripts }}.sh + benchmark: name: Quick check benchmarks runs-on: ubuntu-latest @@ -63,47 +80,70 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - run: ./scripts/benchmarks/quick_check.sh - tests: - name: Tests + test_standalone: + name: Test standalone build runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Install rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - default: true - override: true - profile: minimal - components: rustfmt, clippy, llvm-tools-preview - - - uses: actions-rs/install@v0.1 - with: - crate: grcov - use-tool-cache: true + - name: Install build tools + run: ./scripts/init.sh + + # No disk space: https://github.com/zeitgeistpm/zeitgeist/actions/runs/5085081984/jobs/9144298675?pr=1006 + # Workaround: https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 + - name: Free up disk space on GitHub hosted runners + run: | + # Ensure context is GitHub hosted runner + # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context + if [[ "${{ runner.name }}" == "GitHub Actions"* ]]; then + echo "Freeing up space in GitHub hosted runner" + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + fi - name: Cache Dependencies uses: Swatinem/rust-cache@v1 - name: Tests - run: ./scripts/tests/misc.sh + run: ./scripts/tests/test_standalone.sh - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 - with: - files: ${{ runner.temp }}/zeitgeist-test-coverage.lcov - fail_ci_if_error: true - flags: tests - verbose: true - name: unit-tests + test_parachain: + name: Test parachain build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install build tools + run: ./scripts/init.sh + + # No disk space: https://github.com/zeitgeistpm/zeitgeist/actions/runs/5085081984/jobs/9144298675?pr=1006 + # Workaround: https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 + - name: Free up disk space on GitHub hosted runners + run: | + # Ensure context is GitHub hosted runner + # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context + if [[ "${{ runner.name }}" == "GitHub Actions"* ]]; then + echo "Freeing up space in GitHub hosted runner" + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + fi + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Tests + run: ./scripts/tests/test_parachain.sh fuzz: name: Fuzz @@ -112,8 +152,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install rust toolchain - run: rustup show + - name: Install build tools + run: ./scripts/init.sh - uses: actions-rs/install@v0.1 with: @@ -123,4 +163,4 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v1 - - run: ./scripts/tests/fuzz.sh + - run: ./scripts/tests/fuzz.sh --verbose diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 000000000..39e776a07 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,36 @@ +name: Try Runtime on New Tags + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + try_runtime_battery_station: + name: Test Try Runtime + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install build tools + run: ./scripts/init.sh + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v2 + + - run: make try-runtime-upgrade-battery-station + try_runtime_zeitgeist: + name: Test Try Runtime + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install build tools + run: ./scripts/init.sh + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v2 + + - run: make try-runtime-upgrade-zeitgeist diff --git a/.gitignore b/.gitignore index 8a30b968d..cd3eee9c6 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,138 @@ **/node_modules/ # Visual Studio Code -.vscode \ No newline at end of file +.vscode + +############################## +# GitHub's Python .gitignore # +############################## + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 000000000..000207e07 --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,25 @@ +pull_request_rules: + - name: Auto merge + conditions: + - base=main + - "#approved-reviews-by>=1" + - "#changes-requested-reviews-by=0" + - check-success=format + - check-success=tests + - check-success=fuzz + - check-success=benchmark + - label=s:accepted + actions: + label: + remove: + - s:in-progress + - s:review-needed + merge: + method: squash + - name: ask to resolve conflict + conditions: + - conflict + actions: + comment: + message: This pull request is now in conflicts. Could you fix it @{{author}}? 🙏 + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 000000000..b48c5e381 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,15 @@ +# When a part of the project is modified that is owned by a code owner, +# the code owner has to be included in the respective PR's reviewer list. +# The code owner has the right to delegate the responsibility to review. +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +/node/ @sea212 +/runtime/ @sea212 +/zrml/authorized/ @Chralt98 +/zrml/court/ @Chralt98 +/zrml/global-disputes/ @Chralt98 +/zrml/prediction-markets/ @maltekliemann +/zrml/rikiddo/ @sea212 +/zrml/simple-disputes/ @Chralt98 +/zrml/styx/ @yornaath +/zrml/swaps/ @maltekliemann diff --git a/Cargo.lock b/Cargo.lock index f9d02c5c5..d9589ea46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,16 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli", + "gimli 0.26.2", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.1", ] [[package]] @@ -43,7 +52,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if 1.0.0", - "cipher 0.3.0", + "cipher", "cpufeatures", "opaque-debug 0.3.0", ] @@ -56,7 +65,7 @@ checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" dependencies = [ "aead", "aes", - "cipher 0.3.0", + "cipher", "ctr", "ghash", "subtle", @@ -108,9 +117,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "approx" @@ -123,13 +132,19 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d47fbf90d5149a107494b15a7dc8d69b351be2db3bb9691740e88ec17fd880" +checksum = "3e90af4de65aa7b293ef2d09daff88501eb254f58edde2e1ac02c82d873eadad" dependencies = [ "derive_arbitrary", ] +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + [[package]] name = "arrayref" version = "0.3.6" @@ -198,7 +213,7 @@ checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" dependencies = [ "async-lock", "async-task", - "concurrent-queue 2.0.0", + "concurrent-queue 2.1.0", "fastrand", "futures-lite", "slab", @@ -297,9 +312,9 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2f8a4a203be3325981310ab243a28e6e4ea55b6519bffce05d41ab60e09ad8" +checksum = "6ba50e24d9ee0a8950d3d03fc6d0dd10aa14b5de3b101949b4e160f7fee7c723" dependencies = [ "async-std", "async-trait", @@ -318,9 +333,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" dependencies = [ "proc-macro2", "quote", @@ -342,9 +357,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" [[package]] name = "atty" @@ -352,7 +367,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -379,16 +394,16 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line", + "addr2line 0.19.0", "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide", - "object 0.29.0", + "miniz_oxide 0.6.2", + "object 0.30.3", "rustc-demangle", ] @@ -416,9 +431,21 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + [[package]] name = "battery-station-runtime" -version = "0.3.7" +version = "0.3.9" dependencies = [ "cfg-if 1.0.0", "common-runtime", @@ -437,7 +464,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", - "kusama-runtime", "log", "nimbus-primitives", "orml-asset-registry", @@ -455,7 +481,8 @@ dependencies = [ "pallet-balances", "pallet-bounties", "pallet-collective", - "pallet-crowdloan-rewards", + "pallet-contracts", + "pallet-contracts-primitives", "pallet-democracy", "pallet-grandpa", "pallet-identity", @@ -479,6 +506,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-parachains", + "rococo-runtime", "scale-info", "session-keys-primitives", "sp-api", @@ -491,10 +519,12 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", + "sp-std", "sp-transaction-pool", "sp-version", "substrate-fixed", "substrate-wasm-builder", + "test-case", "xcm", "xcm-builder", "xcm-emulator", @@ -525,21 +555,24 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", + "async-trait", "beefy-primitives", "fnv", "futures 0.3.25", "futures-timer", - "hex", "log", "parity-scale-codec", "parking_lot 0.12.1", "sc-chain-spec", "sc-client-api", + "sc-consensus", "sc-finality-grandpa", "sc-keystore", "sc-network", + "sc-network-common", "sc-network-gossip", "sc-utils", "sp-api", @@ -559,7 +592,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -579,32 +612,30 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "beefy-primitives", "sp-api", + "sp-runtime", ] [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", + "serde", "sp-api", "sp-application-crypto", "sp-core", + "sp-io", + "sp-mmr-primitives", "sp-runtime", "sp-std", ] -[[package]] -name = "bimap" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b" - [[package]] name = "bincode" version = "1.3.3" @@ -616,9 +647,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.2" +version = "0.60.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" dependencies = [ "bitflags", "cexpr", @@ -653,9 +684,9 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ "digest 0.10.6", ] @@ -776,11 +807,12 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.17" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" dependencies = [ "memchr", + "serde", ] [[package]] @@ -794,9 +826,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" @@ -841,9 +873,9 @@ checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" [[package]] name = "camino" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" dependencies = [ "serde", ] @@ -865,16 +897,16 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.14", + "semver 1.0.16", "serde", "serde_json", ] [[package]] name = "cc" -version = "1.0.77" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" dependencies = [ "jobserver", ] @@ -888,6 +920,15 @@ dependencies = [ "nom", ] +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -913,7 +954,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" dependencies = [ "cfg-if 1.0.0", - "cipher 0.3.0", + "cipher", "cpufeatures", "zeroize", ] @@ -926,7 +967,7 @@ checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" dependencies = [ "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] @@ -968,16 +1009,6 @@ dependencies = [ "generic-array 0.14.6", ] -[[package]] -name = "cipher" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "ckb-merkle-mountain-range" version = "0.3.2" @@ -995,33 +1026,31 @@ checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" dependencies = [ "glob", "libc", - "libloading 0.7.4", + "libloading", ] [[package]] name = "clap" -version = "3.2.23" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ - "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", + "is-terminal", "once_cell", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro-error", "proc-macro2", "quote", @@ -1030,22 +1059,13 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" dependencies = [ "os_str_bytes", ] -[[package]] -name = "cmake" -version = "0.1.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" -dependencies = [ - "cc", -] - [[package]] name = "coarsetime" version = "0.1.22" @@ -1070,18 +1090,18 @@ dependencies = [ [[package]] name = "comfy-table" -version = "5.0.1" +version = "6.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b103d85ca6e209388771bfb7aa6b68a7aeec4afbf6f0a0264bfbf50360e5212e" +checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" dependencies = [ - "strum 0.23.0", - "strum_macros 0.23.1", + "strum", + "strum_macros", "unicode-width", ] [[package]] name = "common-runtime" -version = "0.3.7" +version = "0.3.9" dependencies = [ "cfg-if 1.0.0", "cumulus-pallet-xcmp-queue", @@ -1095,6 +1115,8 @@ dependencies = [ "pallet-balances", "pallet-bounties", "pallet-collective", + "pallet-contracts", + "pallet-contracts-primitives", "pallet-democracy", "pallet-identity", "pallet-membership", @@ -1123,9 +1145,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" dependencies = [ "crossbeam-utils", ] @@ -1199,25 +1221,27 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" +checksum = "52056f6d0584484b57fa6c1a65c1fcb15f3780d8b6a758426d9e3084169b2ddd" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" +checksum = "18fed94c8770dc25d01154c3ffa64ed0b3ba9d583736f305fed7beebe5d9cf74" dependencies = [ + "arrayvec 0.7.2", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.26.2", "log", "regalloc2", "smallvec", @@ -1226,33 +1250,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" +checksum = "1c451b81faf237d11c7e4f3165eeb6bac61112762c5cfe7b4c0fb7241474358f" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" +checksum = "e7c940133198426d26128f08be2b40b0bd117b84771fd36798969c4d712d81fc" [[package]] name = "cranelift-entity" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" +checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" +checksum = "34897538b36b216cc8dd324e73263596d51b8cf610da6498322838b2546baf8a" dependencies = [ "cranelift-codegen", "log", @@ -1262,15 +1286,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" +checksum = "1b2629a569fae540f16a76b70afcc87ad7decb38dc28fa6c648ac73b51e78470" [[package]] name = "cranelift-native" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" +checksum = "20937dab4e14d3e225c5adfc9c7106bafd4ac669bdb43027b911ff794c6fb318" dependencies = [ "cranelift-codegen", "libc", @@ -1279,9 +1303,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.85.3" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" +checksum = "80fc2288957a94fd342a015811479de1837850924166d1f1856d8406e6f3609b" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1380,7 +1404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.6", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1403,40 +1427,19 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "ctr" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "cuckoofilter" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" -dependencies = [ - "byteorder", - "fnv", - "rand 0.7.3", + "cipher", ] [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "clap", "parity-scale-codec", @@ -1451,12 +1454,11 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", "cumulus-primitives-core", - "cumulus-relay-chain-interface", "futures 0.3.25", "parity-scale-codec", "parking_lot 0.12.1", @@ -1475,7 +1477,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1485,7 +1487,6 @@ dependencies = [ "polkadot-primitives", "sc-client-api", "sc-consensus", - "sp-api", "sp-blockchain", "sp-consensus", "sp-runtime", @@ -1496,7 +1497,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1504,7 +1505,6 @@ dependencies = [ "cumulus-relay-chain-interface", "futures 0.3.25", "parking_lot 0.12.1", - "sc-client-api", "sc-consensus", "sp-api", "sp-block-builder", @@ -1520,11 +1520,10 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-relay-chain-interface", - "derive_more", "futures 0.3.25", "futures-timer", "parity-scale-codec", @@ -1533,7 +1532,6 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "sc-client-api", - "sp-api", "sp-blockchain", "sp-consensus", "sp-core", @@ -1545,7 +1543,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -1559,7 +1557,6 @@ dependencies = [ "rand 0.8.5", "sc-client-api", "sc-consensus", - "sp-api", "sp-consensus", "sp-maybe-compressed-blob", "sp-runtime", @@ -1569,7 +1566,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -1578,26 +1575,21 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "parking_lot 0.12.1", - "polkadot-overseer", "polkadot-primitives", "sc-client-api", "sc-consensus", - "sc-consensus-babe", "sc-service", - "sc-telemetry", - "sc-tracing", "sp-api", "sp-blockchain", "sp-consensus", "sp-core", "sp-runtime", - "tracing", ] [[package]] name = "cumulus-pallet-dmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1609,14 +1601,14 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", - "xcm-executor", ] [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ + "bytes", "cumulus-pallet-parachain-system-proc-macro", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", @@ -1625,11 +1617,9 @@ dependencies = [ "frame-system", "impl-trait-for-tuples", "log", - "pallet-balances", "parity-scale-codec", "polkadot-parachain", "scale-info", - "serde", "sp-core", "sp-externalities", "sp-inherents", @@ -1639,13 +1629,12 @@ dependencies = [ "sp-std", "sp-trie", "sp-version", - "xcm", ] [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1656,14 +1645,13 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "serde", "sp-io", "sp-runtime", "sp-std", @@ -1673,7 +1661,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "frame-benchmarking", @@ -1692,9 +1680,8 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ - "frame-support", "parity-scale-codec", "polkadot-core-primitives", "polkadot-parachain", @@ -1708,7 +1695,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1731,7 +1718,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "futures 0.3.25", @@ -1744,69 +1731,59 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "frame-support", + "log", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", "sp-runtime", "sp-std", - "sp-trie", "xcm", + "xcm-builder", + "xcm-executor", ] [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", "futures 0.3.25", "futures-timer", - "parking_lot 0.12.1", "polkadot-cli", "polkadot-client", "polkadot-service", "sc-cli", "sc-client-api", - "sc-consensus-babe", - "sc-network", "sc-sysinfo", "sc-telemetry", "sc-tracing", "sp-api", - "sp-blockchain", "sp-consensus", "sp-core", "sp-runtime", "sp-state-machine", - "tracing", ] [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "cumulus-primitives-core", - "derive_more", "futures 0.3.25", "jsonrpsee-core", "parity-scale-codec", - "parking_lot 0.12.1", "polkadot-overseer", "polkadot-service", "sc-client-api", "sp-api", "sp-blockchain", - "sp-core", - "sp-runtime", "sp-state-machine", "thiserror", ] @@ -1814,7 +1791,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "async-trait", "backoff", @@ -1824,15 +1801,17 @@ dependencies = [ "futures-timer", "jsonrpsee", "parity-scale-codec", - "parking_lot 0.12.1", "polkadot-service", "sc-client-api", "sc-rpc-api", "sp-api", + "sp-authority-discovery", + "sp-consensus-babe", "sp-core", "sp-runtime", "sp-state-machine", "sp-storage", + "tokio", "tracing", "url", ] @@ -1840,7 +1819,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1878,22 +1857,23 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-pre.1" +version = "4.0.0-pre.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4033478fbf70d6acf2655ac70da91ee65852d69daf7a67bf7a2f518fb47aafcf" +checksum = "67bc65846be335cb20f4e52d49a437b773a2c1fdb42b19fc84e79e6f6771536f" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.6.4", + "cfg-if 1.0.0", + "fiat-crypto", + "packed_simd_2", + "platforms 3.0.2", "subtle", "zeroize", ] [[package]] name = "cxx" -version = "1.0.82" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" +checksum = "b61a7545f753a88bcbe0a70de1fcc0221e10bfc752f576754fa91e663db1622e" dependencies = [ "cc", "cxxbridge-flags", @@ -1903,9 +1883,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.82" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" +checksum = "f464457d494b5ed6905c63b0c4704842aba319084a0a3561cdc1359536b53200" dependencies = [ "cc", "codespan-reporting", @@ -1918,15 +1898,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.82" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" +checksum = "43c7119ce3a3701ed81aca8410b9acf6fc399d2629d057b87e2efa4e63a3aaea" [[package]] name = "cxxbridge-macro" -version = "1.0.82" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" +checksum = "65e07508b90551e610910fa648a1878991d367064997a596135b86df30daf07e" dependencies = [ "proc-macro2", "quote", @@ -1935,9 +1915,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "data-encoding-macro" @@ -1981,9 +1961,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4903dff04948f22033ca30232ab8eca2c3fc4c913a8b6a34ee5199699814817f" +checksum = "8beee4701e2e229e8098bbdecdca12449bc3e322f137d269182fa1291e20bd00" dependencies = [ "proc-macro2", "quote", @@ -2003,6 +1983,12 @@ dependencies = [ "syn", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.8.1" @@ -2083,6 +2069,12 @@ dependencies = [ "quick-error", ] +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -2091,9 +2083,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a6eee2d5d0d113f015688310da018bd1d864d86bd567c8fca9c266889e1bfa" +checksum = "c00704156a7de8df8da0911424e30c2049957b0a714542a44e05fe693dd85313" [[package]] name = "dyn-clonable" @@ -2118,9 +2110,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" [[package]] name = "ecdsa" @@ -2136,9 +2128,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature", ] @@ -2157,6 +2149,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "either" version = "1.8.0" @@ -2183,11 +2189,11 @@ dependencies = [ [[package]] name = "enum-as-inner" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro2", "quote", "syn", @@ -2215,9 +2221,9 @@ dependencies = [ [[package]] name = "enumn" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038b1afa59052df211f9efd58f8b1d84c242935ede1c3dbaed26b018a9e06ae2" +checksum = "e88bcb3a067a6555d577aba299e75eff9942da276e6506fc6274327daa026132" dependencies = [ "proc-macro2", "quote", @@ -2237,6 +2243,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" version = "1.1.3" @@ -2369,21 +2388,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" + [[package]] name = "file-per-thread-logger" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e16290574b39ee41c71aeb90ae960c504ebaf1e2a1c87bd52aa56ed6e1a02f" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger", + "env_logger 0.10.0", "log", ] [[package]] name = "filetime" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9663d381d07ae25dc88dbdf27df458faa83a9b25336bcac83d5e452b5fc9d3" +checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9" dependencies = [ "cfg-if 1.0.0", "libc", @@ -2393,9 +2418,9 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22349c6a11563a202d95772a68e0fcf56119e74ea8a2a19cf2301460fcd0df5" +checksum = "e24e6c429951433ccb7c87fd528c60084834dcd14763182c1f83291bcde24c34" dependencies = [ "either", "futures 0.3.25", @@ -2409,9 +2434,9 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", "rand 0.8.5", @@ -2433,7 +2458,16 @@ checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.5.4", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", ] [[package]] @@ -2445,7 +2479,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", ] @@ -2459,10 +2493,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -2474,6 +2514,7 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", + "sp-core", "sp-io", "sp-runtime", "sp-runtime-interface", @@ -2484,9 +2525,10 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "Inflector", + "array-bytes", "chrono", "clap", "comfy-table", @@ -2496,7 +2538,6 @@ dependencies = [ "gethostname", "handlebars", "hash-db", - "hex", "itertools", "kvdb", "lazy_static", @@ -2535,7 +2576,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2546,7 +2587,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2562,10 +2603,11 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", + "frame-try-runtime", "parity-scale-codec", "scale-info", "sp-core", @@ -2590,7 +2632,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "bitflags", "frame-metadata", @@ -2604,6 +2646,7 @@ dependencies = [ "scale-info", "serde", "smallvec", + "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", @@ -2614,16 +2657,19 @@ dependencies = [ "sp-state-machine", "sp-std", "sp-tracing", + "sp-weights", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "Inflector", + "cfg-expr", "frame-support-procedural-tools", + "itertools", "proc-macro2", "quote", "syn", @@ -2632,7 +2678,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2644,7 +2690,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro2", "quote", @@ -2654,7 +2700,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "log", @@ -2666,12 +2712,13 @@ dependencies = [ "sp-runtime", "sp-std", "sp-version", + "sp-weights", ] [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -2686,7 +2733,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "sp-api", @@ -2695,9 +2742,10 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", + "parity-scale-codec", "sp-api", "sp-runtime", "sp-std", @@ -2709,18 +2757,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" -[[package]] -name = "fs-swap" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d47dad3685eceed8488986cad3d5027165ea5edb164331770e2059555f10a5" -dependencies = [ - "lazy_static", - "libc", - "libloading 0.5.2", - "winapi", -] - [[package]] name = "fs2" version = "0.4.3" @@ -2887,7 +2923,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2896,7 +2932,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "version_check", ] @@ -2955,17 +2991,23 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" + [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ "aho-corasick", "bstr", @@ -2976,9 +3018,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ "futures-channel", "futures-core", @@ -3018,9 +3060,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.5" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e4ab33f1213cdc25b5fa45c76881240cfe79284cf2b395e8b9e312a30a2fd" +checksum = "035ef95d03713f2c347a72547b7cd38cbc9af7cd51e6099fb62d586d4a6dee3a" dependencies = [ "log", "pest", @@ -3063,15 +3105,6 @@ dependencies = [ "ahash", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -3087,6 +3120,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -3099,12 +3141,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hex_fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" - [[package]] name = "hmac" version = "0.8.1" @@ -3213,9 +3249,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59df7c4e19c950e6e0e868dcc0a300b09a9b88e9ec55bd879ca819087a77355d" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ "http", "hyper", @@ -3283,9 +3319,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "1.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015a7df1eb6dda30df37f34b63ada9b7b352984b0e84de2a20ed526345000791" +checksum = "065c008e570a43c00de6aed9714035e5ea6a498c255323db9091722af6ee67dd" dependencies = [ "async-io", "core-foundation", @@ -3310,9 +3346,9 @@ dependencies = [ [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ "serde", ] @@ -3339,15 +3375,6 @@ dependencies = [ "serde", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.6", -] - [[package]] name = "instant" version = "0.1.12" @@ -3372,18 +3399,22 @@ dependencies = [ "num-traits", ] -[[package]] -name = "io-lifetimes" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" - [[package]] name = "io-lifetimes" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" +[[package]] +name = "io-lifetimes" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + [[package]] name = "ip_network" version = "0.4.1" @@ -3404,9 +3435,21 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.1" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "is-terminal" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes 1.0.4", + "rustix 0.36.7", + "windows-sys 0.42.0", +] [[package]] name = "itertools" @@ -3419,9 +3462,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "jobserver" @@ -3443,9 +3486,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11e017217fcd18da0a25296d3693153dd19c8a6aadab330b3595285d075385d1" +checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-server", @@ -3458,9 +3501,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce395539a14d3ad4ec1256fde105abd36a2da25d578a291cabe98f45adfdb111" +checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" dependencies = [ "futures-util", "http", @@ -3479,9 +3522,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16efcd4477de857d4a2195a45769b2fe9ebb54f3ef5a4221d3b014a4fe33ec0b" +checksum = "f3dc3e9cf2ba50b7b1d7d76a667619f82846caa39e8e8daa8a4962d74acaddca" dependencies = [ "anyhow", "arrayvec 0.7.2", @@ -3492,6 +3535,7 @@ dependencies = [ "futures-timer", "futures-util", "globset", + "http", "hyper", "jsonrpsee-types", "lazy_static", @@ -3504,14 +3548,15 @@ dependencies = [ "thiserror", "tokio", "tracing", + "tracing-futures", "unicase", ] [[package]] name = "jsonrpsee-http-server" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd69efeb3ce2cba767f126872f4eeb4624038a29098e75d77608b2b4345ad03" +checksum = "03802f0373a38c2420c70b5144742d800b509e2937edc4afb116434f07120117" dependencies = [ "futures-channel", "futures-util", @@ -3522,13 +3567,14 @@ dependencies = [ "serde_json", "tokio", "tracing", + "tracing-futures", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874cf3f6a027cebf36cae767feca9aa2e8a8f799880e49eb5540819fcbd8eada" +checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3538,9 +3584,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcf76cd316f5d3ad48138085af1f45e2c58c98e02f0779783dbb034d43f7c86" +checksum = "e290bba767401b646812f608c099b922d8142603c9e73a50fb192d3ac86f4a0d" dependencies = [ "anyhow", "beef", @@ -3552,10 +3598,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee043cb5dd0d51d3eb93432e998d5bae797691a7b10ec4a325e036bcdb48c48a" +checksum = "6ee5feddd5188e62ac08fcf0e56478138e581509d4730f3f7be9b57dd402a4ff" dependencies = [ + "http", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -3563,12 +3610,13 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-server" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2e4d266774a671f8def3794255b28eddd09b18d76e0b913fa439f34588c0a" +checksum = "d488ba74fb369e5ab68926feb75a483458b88e768d44319f37e4ecad283c7325" dependencies = [ "futures-channel", "futures-util", + "http", "jsonrpsee-core", "jsonrpsee-types", "serde_json", @@ -3577,6 +3625,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tracing", + "tracing-futures", ] [[package]] @@ -3602,8 +3651,8 @@ dependencies = [ [[package]] name = "kusama-runtime" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "bitvec", @@ -3626,10 +3675,12 @@ dependencies = [ "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-gilt", "pallet-grandpa", "pallet-identity", @@ -3639,11 +3690,14 @@ dependencies = [ "pallet-multisig", "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", @@ -3657,6 +3711,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", @@ -3694,14 +3749,16 @@ dependencies = [ [[package]] name = "kusama-runtime-constants" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] @@ -3715,9 +3772,9 @@ dependencies = [ [[package]] name = "kvdb" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a301d8ecb7989d4a6e2c57a49baca77d353bdbf879909debe3f375fe25d61f86" +checksum = "585089ceadba0197ffe9af6740ab350b325e3c1f5fccfbc3522e0250c750409b" dependencies = [ "parity-util-mem", "smallvec", @@ -3725,9 +3782,9 @@ dependencies = [ [[package]] name = "kvdb-memorydb" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece7e668abd21387aeb6628130a6f4c802787f014fa46bc83221448322250357" +checksum = "40d109c87bfb7759edd2a49b2649c1afe25af785d930ad6a38479b4dc70dd873" dependencies = [ "kvdb", "parity-util-mem", @@ -3736,15 +3793,13 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca7fbdfd71cd663dceb0faf3367a99f8cf724514933e9867cec4995b6027cbc1" +checksum = "c076cc2cdbac89b9910c853a36c957d3862a779f31c2661174222cefb49ee597" dependencies = [ - "fs-swap", "kvdb", "log", "num_cpus", - "owning_ref", "parity-util-mem", "parking_lot 0.12.1", "regex", @@ -3766,9 +3821,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.137" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libfuzzer-sys" @@ -3781,16 +3836,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi", -] - [[package]] name = "libloading" version = "0.7.4" @@ -3801,6 +3846,12 @@ 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.6" @@ -3809,9 +3860,9 @@ checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libp2p" -version = "0.46.1" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81327106887e42d004fbdab1fef93675be2e2e07c1b95fce45e2cc813485611d" +checksum = "ec878fda12ebec479186b3914ebc48ff180fa4c51847e11a1a68bf65249e02c1" dependencies = [ "bytes", "futures 0.3.25", @@ -3819,12 +3870,8 @@ dependencies = [ "getrandom 0.2.8", "instant", "lazy_static", - "libp2p-autonat", "libp2p-core", - "libp2p-deflate", "libp2p-dns", - "libp2p-floodsub", - "libp2p-gossipsub", "libp2p-identify", "libp2p-kad", "libp2p-mdns", @@ -3832,49 +3879,24 @@ dependencies = [ "libp2p-mplex", "libp2p-noise", "libp2p-ping", - "libp2p-plaintext", - "libp2p-pnet", - "libp2p-relay", - "libp2p-rendezvous", "libp2p-request-response", "libp2p-swarm", "libp2p-swarm-derive", "libp2p-tcp", - "libp2p-uds", "libp2p-wasm-ext", "libp2p-websocket", "libp2p-yamux", "multiaddr", "parking_lot 0.12.1", "pin-project", - "rand 0.7.3", "smallvec", ] -[[package]] -name = "libp2p-autonat" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4decc51f3573653a9f4ecacb31b1b922dd20c25a6322bb15318ec04287ec46f9" -dependencies = [ - "async-trait", - "futures 0.3.25", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-request-response", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.8.5", -] - [[package]] name = "libp2p-core" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf9b94cefab7599b2d3dff2f93bee218c6621d68590b23ede4485813cbcece6" +checksum = "799676bb0807c788065e57551c6527d461ad572162b0519d1958946ff9e0539d" dependencies = [ "asn1_der", "bs58", @@ -3885,7 +3907,6 @@ dependencies = [ "futures-timer", "instant", "lazy_static", - "libsecp256k1", "log", "multiaddr", "multihash", @@ -3895,7 +3916,6 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "ring", "rw-stream-sink", "sha2 0.10.6", "smallvec", @@ -3905,22 +3925,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "libp2p-deflate" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0183dc2a3da1fbbf85e5b6cf51217f55b14f5daea0c455a9536eef646bfec71" -dependencies = [ - "flate2", - "futures 0.3.25", - "libp2p-core", -] - [[package]] name = "libp2p-dns" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cbf54723250fa5d521383be789bf60efdabe6bacfb443f87da261019a49b4b5" +checksum = "2322c9fb40d99101def6a01612ee30500c89abbbecb6297b3cd252903a4c1720" dependencies = [ "async-std-resolver", "futures 0.3.25", @@ -3931,57 +3940,11 @@ dependencies = [ "trust-dns-resolver", ] -[[package]] -name = "libp2p-floodsub" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a4b6ffd53e355775d24b76f583fdda54b3284806f678499b57913adb94f231" -dependencies = [ - "cuckoofilter", - "fnv", - "futures 0.3.25", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.7.3", - "smallvec", -] - -[[package]] -name = "libp2p-gossipsub" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b4b888cfbeb1f5551acd3aa1366e01bf88ede26cc3c4645d0d2d004d5ca7b0" -dependencies = [ - "asynchronous-codec", - "base64", - "byteorder", - "bytes", - "fnv", - "futures 0.3.25", - "hex_fmt", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "prometheus-client", - "prost", - "prost-build", - "rand 0.7.3", - "regex", - "sha2 0.10.6", - "smallvec", - "unsigned-varint", - "wasm-timer", -] - [[package]] name = "libp2p-identify" -version = "0.37.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50b585518f8efd06f93ac2f976bd672e17cdac794644b3117edd078e96bda06" +checksum = "dcf9a121f699e8719bda2e6e9e9b6ddafc6cff4602471d6481c1067930ccb29b" dependencies = [ "asynchronous-codec", "futures 0.3.25", @@ -3989,7 +3952,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru 0.7.8", + "lru 0.8.1", "prost", "prost-build", "prost-codec", @@ -4000,9 +3963,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.38.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740862893bb5f06ac24acc9d49bdeadc3a5e52e51818a30a25c1f3519da2c851" +checksum = "6721c200e2021f6c3fab8b6cf0272ead8912d871610ee194ebd628cecf428f22" dependencies = [ "arrayvec 0.7.2", "asynchronous-codec", @@ -4017,7 +3980,7 @@ dependencies = [ "log", "prost", "prost-build", - "rand 0.7.3", + "rand 0.8.5", "sha2 0.10.6", "smallvec", "thiserror", @@ -4028,16 +3991,15 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.38.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e5e5919509603281033fd16306c61df7a4428ce274b67af5e14b07de5cdcb2" +checksum = "761704e727f7d68d58d7bc2231eafae5fc1b9814de24290f126df09d4bd37a15" dependencies = [ "async-io", "data-encoding", "dns-parser", "futures 0.3.25", "if-watch", - "lazy_static", "libp2p-core", "libp2p-swarm", "log", @@ -4049,25 +4011,23 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8aff4a1abef42328fbb30b17c853fff9be986dc39af17ee39f9c5f755c5e0c" +checksum = "9ee31b08e78b7b8bfd1c4204a9dd8a87b4fcdf6dafc57eb51701c1c264a81cb9" dependencies = [ "libp2p-core", - "libp2p-gossipsub", "libp2p-identify", "libp2p-kad", "libp2p-ping", - "libp2p-relay", "libp2p-swarm", "prometheus-client", ] [[package]] name = "libp2p-mplex" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fd1b20638ec209c5075dfb2e8ce6a7ea4ec3cd3ad7b77f7a477c06d53322e2" +checksum = "692664acfd98652de739a8acbb0a0d670f1d67190a49be6b4395e22c37337d89" dependencies = [ "asynchronous-codec", "bytes", @@ -4076,16 +4036,16 @@ dependencies = [ "log", "nohash-hasher", "parking_lot 0.12.1", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "unsigned-varint", ] [[package]] name = "libp2p-noise" -version = "0.37.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "762408cb5d84b49a600422d7f9a42c18012d8da6ebcd570f9a4a4290ba41fb6f" +checksum = "048155686bd81fe6cb5efdef0c6290f25ad32a0a42e8f4f72625cf6a505a206f" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -4105,9 +4065,9 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.37.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100a6934ae1dbf8a693a4e7dd1d730fd60b774dafc45688ed63b554497c6c925" +checksum = "7228b9318d34689521349a86eb39a3c3a802c9efc99a0568062ffb80913e3f91" dependencies = [ "futures 0.3.25", "futures-timer", @@ -4115,95 +4075,15 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand 0.7.3", - "void", -] - -[[package]] -name = "libp2p-plaintext" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be27bf0820a6238a4e06365b096d428271cce85a129cf16f2fe9eb1610c4df86" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures 0.3.25", - "libp2p-core", - "log", - "prost", - "prost-build", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-pnet" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5a702574223aa55d8878bdc8bf55c84a6086f87ddaddc28ce730b4caa81538" -dependencies = [ - "futures 0.3.25", - "log", - "pin-project", "rand 0.8.5", - "salsa20", - "sha3", -] - -[[package]] -name = "libp2p-relay" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4931547ee0cce03971ccc1733ff05bb0c4349fd89120a39e9861e2bbe18843c3" -dependencies = [ - "asynchronous-codec", - "bytes", - "either", - "futures 0.3.25", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "pin-project", - "prost", - "prost-build", - "prost-codec", - "rand 0.8.5", - "smallvec", - "static_assertions", - "thiserror", - "void", -] - -[[package]] -name = "libp2p-rendezvous" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9511c9672ba33284838e349623319c8cad2d18cfad243ae46c6b7e8a2982ea4e" -dependencies = [ - "asynchronous-codec", - "bimap", - "futures 0.3.25", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.8.5", - "sha2 0.10.6", - "thiserror", - "unsigned-varint", "void", ] [[package]] name = "libp2p-request-response" -version = "0.19.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "508a189e2795d892c8f5c1fa1e9e0b1845d32d7b0b249dbf7b05b18811361843" +checksum = "8827af16a017b65311a410bb626205a9ad92ec0473967618425039fa5231adc1" dependencies = [ "async-trait", "bytes", @@ -4212,16 +4092,16 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "unsigned-varint", ] [[package]] name = "libp2p-swarm" -version = "0.37.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ac5be6c2de2d1ff3f7693fda6faf8a827b1f3e808202277783fea9f527d114" +checksum = "46d13df7c37807965d82930c0e4b04a659efcb6cca237373b206043db5398ecf" dependencies = [ "either", "fnv", @@ -4231,7 +4111,7 @@ dependencies = [ "libp2p-core", "log", "pin-project", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "thiserror", "void", @@ -4239,48 +4119,36 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.28.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f54a64b6957249e0ce782f8abf41d97f69330d02bf229f0672d864f0650cc76" +checksum = "a0eddc4497a8b5a506013c40e8189864f9c3a00db2b25671f428ae9007f3ba32" dependencies = [ + "heck", "quote", "syn", ] [[package]] name = "libp2p-tcp" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a6771dc19aa3c65d6af9a8c65222bfc8fcd446630ddca487acd161fa6096f3b" +checksum = "9839d96761491c6d3e238e70554b856956fca0ab60feb9de2cd08eed4473fa92" dependencies = [ "async-io", "futures 0.3.25", "futures-timer", "if-watch", - "ipnet", "libc", "libp2p-core", "log", "socket2", ] -[[package]] -name = "libp2p-uds" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d125e3e5f0d58f3c6ac21815b20cf4b6a88b8db9dc26368ea821838f4161fd4d" -dependencies = [ - "async-std", - "futures 0.3.25", - "libp2p-core", - "log", -] - [[package]] name = "libp2p-wasm-ext" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec894790eec3c1608f8d1a8a0bdf0dbeb79ed4de2dce964222011c2896dfa05a" +checksum = "a17b5b8e7a73e379e47b1b77f8a82c4721e97eca01abcd18e9cd91a23ca6ce97" dependencies = [ "futures 0.3.25", "js-sys", @@ -4292,9 +4160,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.36.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9808e57e81be76ff841c106b4c5974fb4d41a233a7bdd2afbf1687ac6def3818" +checksum = "3758ae6f89b2531a24b6d9f5776bda6a626b60a57600d7185d43dfa75ca5ecc4" dependencies = [ "either", "futures 0.3.25", @@ -4311,12 +4179,13 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.38.0" +version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6dea686217a06072033dc025631932810e2f6ad784e4fafa42e27d311c7a81c" +checksum = "0d6874d66543c4f7e26e3b8ca9a6bead351563a13ab4fafd43c7927f7c0d6c12" dependencies = [ "futures 0.3.25", "libp2p-core", + "log", "parking_lot 0.12.1", "thiserror", "yamux", @@ -4324,9 +4193,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.6.1+6.28.2" +version = "0.8.0+7.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" +checksum = "611804e4666a25136fcc5f8cf425ab4d26c7f74ea245ffe92ea23b85b6420b5d" dependencies = [ "bindgen", "bzip2-sys", @@ -4344,7 +4213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.1", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", @@ -4353,7 +4222,7 @@ dependencies = [ "rand 0.8.5", "serde", "sha2 0.9.9", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4398,9 +4267,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -4432,15 +4301,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.0.42" +version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" [[package]] name = "linux-raw-sys" -version = "0.0.46" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "lock_api" @@ -4454,11 +4323,10 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" dependencies = [ - "cfg-if 1.0.0", "value-bag", ] @@ -4535,9 +4403,9 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" @@ -4556,11 +4424,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.4.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6627dc657574b49d6ad27105ed671822be56e0d2547d413bfbf3e8d8fa92e7a" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "libc", + "rustix 0.36.7", ] [[package]] @@ -4592,9 +4460,9 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" +checksum = "34ac11bb793c28fa095b7554466f53b3a60a2cd002afdac01bcf135cbd73a269" dependencies = [ "hash-db", "hashbrown 0.12.3", @@ -4612,9 +4480,9 @@ dependencies = [ [[package]] name = "memory_units" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merlin" @@ -4654,6 +4522,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.5" @@ -4666,10 +4543,37 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "mockall" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" +dependencies = [ + "cfg-if 1.0.0", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "moonbeam-vrf" version = "0.1.0" -source = "git+https://github.com/zeitgeistpm/moonbeam?branch=polkadot-v0.9.26#5d24d606a8a2cfeb75a3ab95b77087ebe6522cb0" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "nimbus-primitives", "parity-scale-codec", @@ -4757,9 +4661,9 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", "futures 0.3.25", @@ -4784,7 +4688,7 @@ dependencies = [ "rand 0.8.5", "rand_distr", "simba", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4868,9 +4772,9 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b654097027250401127914afb37cb1f311df6610a9891ff07a757e94199027" +checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" dependencies = [ "async-io", "bytes", @@ -4882,7 +4786,7 @@ dependencies = [ [[package]] name = "nimbus-consensus" version = "0.9.0" -source = "git+https://github.com/zeitgeistpm/nimbus?branch=polkadot-v0.9.26#34792127cfe1a3a446b097b52fcd41830cdd24c5" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -4913,7 +4817,7 @@ dependencies = [ [[package]] name = "nimbus-primitives" version = "0.9.0" -source = "git+https://github.com/zeitgeistpm/nimbus?branch=polkadot-v0.9.26#34792127cfe1a3a446b097b52fcd41830cdd24c5" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "async-trait", "frame-benchmarking", @@ -4943,29 +4847,55 @@ dependencies = [ name = "nodrop" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] [[package]] -name = "nohash-hasher" -version = "0.2.0" +name = "normalize-line-endings" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] -name = "nom" -version = "7.1.1" +name = "num-bigint" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "memchr", - "minimal-lexical", + "autocfg", + "num-integer", + "num-traits", ] [[package]] name = "num-bigint" -version = "0.2.6" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", "num-integer", @@ -4974,9 +4904,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] @@ -5008,7 +4938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.2.6", "num-integer", "num-traits", ] @@ -5020,6 +4950,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", + "num-bigint 0.4.3", "num-integer", "num-traits", ] @@ -5031,45 +4962,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm", + "libm 0.2.6", ] [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.11.2", + "hashbrown 0.12.3", "indexmap", "memchr", ] [[package]] name = "object" -version = "0.29.0" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "opaque-debug" @@ -5091,8 +5022,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "orchestra" -version = "0.0.1" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aab54694ddaa8a9b703724c6ef04272b2d27bc32d2c855aae5cdd1857216b43" dependencies = [ "async-trait", "dyn-clonable", @@ -5107,8 +5039,9 @@ dependencies = [ [[package]] name = "orchestra-proc-macro" -version = "0.0.1" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a702b2f6bf592b3eb06c00d80d05afaf7a8eff6b41bb361e397d799acc21b45a" dependencies = [ "expander 0.0.6", "itertools", @@ -5131,7 +5064,7 @@ dependencies = [ [[package]] name = "orml-asset-registry" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "frame-system", @@ -5150,7 +5083,7 @@ dependencies = [ [[package]] name = "orml-benchmarking" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-benchmarking", "frame-support", @@ -5170,7 +5103,7 @@ dependencies = [ [[package]] name = "orml-currencies" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "frame-system", @@ -5187,7 +5120,7 @@ dependencies = [ [[package]] name = "orml-tokens" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "frame-system", @@ -5202,7 +5135,7 @@ dependencies = [ [[package]] name = "orml-traits" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -5220,7 +5153,7 @@ dependencies = [ [[package]] name = "orml-unknown-tokens" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "frame-system", @@ -5235,7 +5168,7 @@ dependencies = [ [[package]] name = "orml-utilities" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "parity-scale-codec", @@ -5249,7 +5182,7 @@ dependencies = [ [[package]] name = "orml-xcm-support" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "frame-support", "orml-traits", @@ -5263,7 +5196,7 @@ dependencies = [ [[package]] name = "orml-xtokens" version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.26#33dbc5e35305d0cf5937c896dae8655ca7da95d8" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?branch=polkadot-v0.9.32#f336875e48599b5e9500b301385259354821f01f" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -5288,18 +5221,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] -name = "owning_ref" -version = "0.4.1" +name = "packed_simd_2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" dependencies = [ - "stable_deref_trait", + "cfg-if 1.0.0", + "libm 0.1.4", ] [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5315,7 +5249,7 @@ dependencies = [ [[package]] name = "pallet-author-inherent" version = "0.9.0" -source = "git+https://github.com/zeitgeistpm/nimbus?branch=polkadot-v0.9.26#34792127cfe1a3a446b097b52fcd41830cdd24c5" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "frame-benchmarking", "frame-support", @@ -5335,7 +5269,7 @@ dependencies = [ [[package]] name = "pallet-author-mapping" version = "2.0.5" -source = "git+https://github.com/zeitgeistpm/moonbeam?branch=polkadot-v0.9.26#5d24d606a8a2cfeb75a3ab95b77087ebe6522cb0" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "frame-benchmarking", "frame-support", @@ -5353,7 +5287,7 @@ dependencies = [ [[package]] name = "pallet-author-slot-filter" version = "0.9.0" -source = "git+https://github.com/zeitgeistpm/nimbus?branch=polkadot-v0.9.26#34792127cfe1a3a446b097b52fcd41830cdd24c5" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "frame-benchmarking", "frame-support", @@ -5371,7 +5305,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5387,7 +5321,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5402,7 +5336,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5426,7 +5360,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5446,7 +5380,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5461,7 +5395,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "beefy-primitives", "frame-support", @@ -5477,13 +5411,13 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "beefy-merkle-tree", "beefy-primitives", "frame-support", "frame-system", - "hex", "log", "pallet-beefy", "pallet-mmr", @@ -5500,7 +5434,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5518,7 +5452,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5537,7 +5471,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5552,38 +5486,86 @@ dependencies = [ ] [[package]] -name = "pallet-crowdloan-rewards" -version = "0.6.0" -source = "git+https://github.com/zeitgeistpm/crowdloan-rewards?branch=polkadot-v0.9.26#1dab0b1971f80c707e3fa4ae59d597d099f23980" +name = "pallet-contracts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ - "ed25519-dalek", + "bitflags", "frame-benchmarking", "frame-support", "frame-system", + "impl-trait-for-tuples", "log", - "pallet-balances", - "pallet-utility", + "pallet-contracts-primitives", + "pallet-contracts-proc-macro", "parity-scale-codec", + "rand 0.8.5", + "rand_pcg 0.3.1", "scale-info", "serde", + "smallvec", + "sp-api", "sp-core", "sp-io", "sp-runtime", + "sp-sandbox", + "sp-std", + "wasm-instrument", + "wasmi-validation", +] + +[[package]] +name = "pallet-contracts-primitives" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "bitflags", + "parity-scale-codec", + "sp-runtime", + "sp-std", + "sp-weights", +] + +[[package]] +name = "pallet-contracts-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pallet-conviction-voting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "assert_matches", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-io", + "sp-runtime", "sp-std", - "sp-trie", ] [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "serde", + "sp-core", "sp-io", "sp-runtime", "sp-std", @@ -5592,13 +5574,14 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", "rand 0.7.3", "scale-info", @@ -5609,13 +5592,13 @@ dependencies = [ "sp-runtime", "sp-std", "static_assertions", - "strum 0.23.0", + "strum", ] [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5628,7 +5611,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5643,10 +5626,31 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-fast-unstake" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5661,7 +5665,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5684,7 +5688,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5700,7 +5704,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5720,7 +5724,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5737,7 +5741,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5754,7 +5758,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5772,7 +5776,7 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -5787,11 +5791,12 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-io", @@ -5802,7 +5807,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5819,7 +5824,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5831,14 +5836,25 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", + "sp-runtime-interface", "sp-staking", "sp-std", ] +[[package]] +name = "pallet-nomination-pools-runtime-api" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-std", +] + [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5855,7 +5871,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5878,7 +5894,7 @@ dependencies = [ [[package]] name = "pallet-parachain-staking" version = "3.0.0" -source = "git+https://github.com/zeitgeistpm/moonbeam?branch=polkadot-v0.9.26#5d24d606a8a2cfeb75a3ab95b77087ebe6522cb0" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "frame-benchmarking", "frame-support", @@ -5896,11 +5912,12 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -5912,7 +5929,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5927,7 +5944,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5938,16 +5955,52 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-ranked-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-referenda" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "assert_matches", "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "serde", + "sp-arithmetic", "sp-io", "sp-runtime", "sp-std", @@ -5956,7 +6009,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5972,7 +6025,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -5993,7 +6046,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6009,7 +6062,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -6023,7 +6076,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6046,7 +6099,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6057,7 +6110,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "sp-arithmetic", @@ -6066,7 +6119,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -6080,7 +6133,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6098,7 +6151,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6117,7 +6170,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-support", "frame-system", @@ -6133,7 +6186,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6143,23 +6196,25 @@ dependencies = [ "sp-core", "sp-rpc", "sp-runtime", + "sp-weights", ] [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", "sp-api", "sp-runtime", + "sp-weights", ] [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6176,7 +6231,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6192,7 +6247,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6204,10 +6259,25 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-whitelist" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-xcm" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "frame-system", @@ -6224,8 +6294,8 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-benchmarking", "frame-support", @@ -6242,14 +6312,13 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.26#be9e23c377555cabb867326ace51e0ab72bee1b9" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.32#6abd385ce49f7feb882218646410feb063404b77" dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "serde", ] [[package]] @@ -6273,13 +6342,14 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.2.1" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +checksum = "e7ab01d0f889e957861bc65888d5ccbe82c158d0270136ba46820d43837cdf72" dependencies = [ "arrayvec 0.7.2", "bitvec", "byte-slice-cast", + "bytes", "impl-trait-for-tuples", "parity-scale-codec-derive", "serde", @@ -6287,9 +6357,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6305,9 +6375,9 @@ checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" [[package]] name = "parity-util-mem" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" +checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" dependencies = [ "cfg-if 1.0.0", "hashbrown 0.12.3", @@ -6341,9 +6411,9 @@ dependencies = [ [[package]] name = "parity-wasm" -version = "0.42.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" @@ -6359,7 +6429,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", ] [[package]] @@ -6369,14 +6439,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.4", + "parking_lot_core 0.9.6", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if 1.0.0", "instant", @@ -6388,9 +6458,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" dependencies = [ "cfg-if 1.0.0", "libc", @@ -6401,9 +6471,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" [[package]] name = "pbkdf2" @@ -6437,9 +6507,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.4.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a528564cc62c19a7acac4d81e01f39e53e25e17b934878f4c6d25cc2836e62f8" +checksum = "4ab62d2fa33726dbe6321cc97ef96d8cde531e3eeaf858a058de53a8a6d40d8f" dependencies = [ "thiserror", "ucd-trie", @@ -6447,9 +6517,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.4.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fd9bc6500181952d34bd0b2b0163a54d794227b498be0b7afa7698d0a7b18f" +checksum = "8bf026e2d0581559db66d837fe5242320f525d85c76283c61f4d51a1238d65ea" dependencies = [ "pest", "pest_generator", @@ -6457,9 +6527,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.4.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2610d5ac5156217b4ff8e46ddcef7cdf44b273da2ac5bca2ecbfa86a330e7c4" +checksum = "2b27bd18aa01d91c8ed2b61ea23406a676b42d82609c6e2581fba42f0c15f17f" dependencies = [ "pest", "pest_meta", @@ -6470,13 +6540,13 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.4.1" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824749bf7e21dd66b36fbe26b3f45c713879cccd4a009a917ab8e045ca8246fe" +checksum = "9f02b677c1859756359fc9983c2e56a0237f18624a3789528804406b7e915e5d" dependencies = [ "once_cell", "pest", - "sha1", + "sha2 0.10.6", ] [[package]] @@ -6527,6 +6597,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "pkg-config" version = "0.3.26" @@ -6539,10 +6620,16 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + [[package]] name = "polkadot-approval-distribution" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "polkadot-node-network-protocol", @@ -6556,8 +6643,8 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "polkadot-node-network-protocol", @@ -6570,13 +6657,13 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "derive_more", "fatality", "futures 0.3.25", - "lru 0.7.8", + "lru 0.8.1", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6593,12 +6680,12 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "fatality", "futures 0.3.25", - "lru 0.7.8", + "lru 0.8.1", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6614,8 +6701,8 @@ dependencies = [ [[package]] name = "polkadot-cli" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "clap", "frame-benchmarking-cli", @@ -6631,6 +6718,7 @@ dependencies = [ "sc-sysinfo", "sc-tracing", "sp-core", + "sp-keyring", "sp-trie", "substrate-build-script-utils", "thiserror", @@ -6639,8 +6727,8 @@ dependencies = [ [[package]] name = "polkadot-client" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "frame-benchmarking", @@ -6679,10 +6767,11 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "always-assert", + "bitvec", "fatality", "futures 0.3.25", "futures-timer", @@ -6700,8 +6789,8 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "parity-scale-codec", "parity-util-mem", @@ -6713,13 +6802,15 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "derive_more", "fatality", "futures 0.3.25", - "lru 0.7.8", + "futures-timer", + "indexmap", + "lru 0.8.1", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6736,8 +6827,8 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -6750,8 +6841,8 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "futures-timer", @@ -6770,12 +6861,13 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "always-assert", "async-trait", "bytes", + "fatality", "futures 0.3.25", "parity-scale-codec", "parking_lot 0.12.1", @@ -6785,14 +6877,16 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "sc-network", + "sc-network-common", "sp-consensus", + "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-collation-generation" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "parity-scale-codec", @@ -6809,15 +6903,15 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitvec", "derive_more", "futures 0.3.25", "futures-timer", "kvdb", - "lru 0.7.8", + "lru 0.8.1", "merlin", "parity-scale-codec", "polkadot-node-jaeger", @@ -6838,8 +6932,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitvec", "futures 0.3.25", @@ -6858,8 +6952,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitvec", "fatality", @@ -6877,8 +6971,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "polkadot-node-subsystem", @@ -6892,8 +6986,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-trait", "futures 0.3.25", @@ -6910,8 +7004,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "polkadot-node-subsystem", @@ -6925,8 +7019,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "futures-timer", @@ -6942,13 +7036,13 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "fatality", "futures 0.3.25", "kvdb", - "lru 0.7.8", + "lru 0.8.1", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -6961,8 +7055,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-trait", "futures 0.3.25", @@ -6978,8 +7072,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitvec", "fatality", @@ -6996,8 +7090,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "always-assert", "assert_matches", @@ -7008,7 +7102,7 @@ dependencies = [ "parity-scale-codec", "pin-project", "polkadot-core-primitives", - "polkadot-node-subsystem-util", + "polkadot-node-metrics", "polkadot-parachain", "rand 0.8.5", "rayon", @@ -7028,8 +7122,8 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "polkadot-node-primitives", @@ -7044,25 +7138,24 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "futures 0.3.25", "memory-lru", "parity-util-mem", "polkadot-node-subsystem", + "polkadot-node-subsystem-types", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-api", - "sp-authority-discovery", "sp-consensus-babe", "tracing-gum", ] [[package]] name = "polkadot-node-jaeger" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-std", "lazy_static", @@ -7079,8 +7172,8 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bs58", "futures 0.3.25", @@ -7098,13 +7191,14 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-trait", "derive_more", "fatality", "futures 0.3.25", + "hex", "parity-scale-codec", "polkadot-node-jaeger", "polkadot-node-primitives", @@ -7112,15 +7206,16 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum 0.24.1", + "sc-network-common", + "strum", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-primitives" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bounded-vec", "futures 0.3.25", @@ -7141,8 +7236,8 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -7151,9 +7246,10 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ + "async-trait", "derive_more", "futures 0.3.25", "orchestra", @@ -7164,14 +7260,17 @@ dependencies = [ "polkadot-statement-table", "sc-network", "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-consensus-babe", "substrate-prometheus-endpoint", "thiserror", ] [[package]] name = "polkadot-node-subsystem-util" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-trait", "derive_more", @@ -7179,7 +7278,7 @@ dependencies = [ "futures 0.3.25", "itertools", "kvdb", - "lru 0.7.8", + "lru 0.8.1", "parity-db", "parity-scale-codec", "parity-util-mem", @@ -7203,12 +7302,13 @@ dependencies = [ [[package]] name = "polkadot-overseer" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ + "async-trait", "futures 0.3.25", "futures-timer", - "lru 0.7.8", + "lru 0.8.1", "orchestra", "parity-util-mem", "parking_lot 0.12.1", @@ -7225,8 +7325,8 @@ dependencies = [ [[package]] name = "polkadot-parachain" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "derive_more", "frame-support", @@ -7242,10 +7342,10 @@ dependencies = [ [[package]] name = "polkadot-performance-test" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ - "env_logger", + "env_logger 0.9.3", "kusama-runtime", "log", "polkadot-erasure-coding", @@ -7257,8 +7357,8 @@ dependencies = [ [[package]] name = "polkadot-primitives" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitvec", "frame-system", @@ -7287,8 +7387,8 @@ dependencies = [ [[package]] name = "polkadot-rpc" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", @@ -7319,8 +7419,8 @@ dependencies = [ [[package]] name = "polkadot-runtime" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "bitvec", @@ -7346,12 +7446,16 @@ dependencies = [ "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-multisig", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", @@ -7404,8 +7508,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "bitvec", @@ -7451,20 +7555,22 @@ dependencies = [ [[package]] name = "polkadot-runtime-constants" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "polkadot-runtime-metrics" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bs58", "parity-scale-codec", @@ -7475,8 +7581,8 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "bitflags", "bitvec", @@ -7518,19 +7624,20 @@ dependencies = [ [[package]] name = "polkadot-service" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "async-trait", "beefy-gadget", "beefy-primitives", + "frame-support", "frame-system-rpc-runtime-api", "futures 0.3.25", "hex-literal", "kusama-runtime", "kvdb", "kvdb-rocksdb", - "lru 0.7.8", + "lru 0.8.1", "pallet-babe", "pallet-im-online", "pallet-staking", @@ -7581,11 +7688,11 @@ dependencies = [ "sc-consensus", "sc-consensus-babe", "sc-consensus-slots", - "sc-consensus-uncles", "sc-executor", "sc-finality-grandpa", "sc-keystore", "sc-network", + "sc-network-common", "sc-offchain", "sc-service", "sc-sync-state-rpc", @@ -7621,8 +7728,8 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "arrayvec 0.5.2", "fatality", @@ -7642,8 +7749,8 @@ dependencies = [ [[package]] name = "polkadot-statement-table" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -7652,8 +7759,8 @@ dependencies = [ [[package]] name = "polkadot-test-runtime" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "bitvec", @@ -7713,8 +7820,8 @@ dependencies = [ [[package]] name = "polkadot-test-service" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-benchmarking", "frame-system", @@ -7743,6 +7850,7 @@ dependencies = [ "sc-executor", "sc-finality-grandpa", "sc-network", + "sc-network-common", "sc-service", "sc-tracing", "sc-transaction-pool", @@ -7766,16 +7874,16 @@ dependencies = [ [[package]] name = "polling" -version = "2.4.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2" +checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" dependencies = [ "autocfg", "cfg-if 1.0.0", "libc", "log", "wepoll-ffi", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -7790,28 +7898,68 @@ dependencies = [ ] [[package]] -name = "polyval" -version = "0.5.3" +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" + +[[package]] +name = "predicates-tree" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash", + "predicates-core", + "termtree", ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "prettyplease" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" +dependencies = [ + "proc-macro2", + "syn", +] [[package]] name = "primitive-types" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", @@ -7823,7 +7971,8 @@ dependencies = [ [[package]] name = "prioritized-metered-channel" version = "0.2.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" dependencies = [ "coarsetime", "crossbeam-queue", @@ -7837,13 +7986,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -7872,9 +8020,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" dependencies = [ "unicode-ident", ] @@ -7895,21 +8043,21 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.16.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1abe0255c04d15f571427a2d1e00099016506cf3297b53853acd2b7eb87825" +checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" dependencies = [ "dtoa", "itoa", - "owning_ref", + "parking_lot 0.12.1", "prometheus-client-derive-text-encode", ] [[package]] name = "prometheus-client-derive-text-encode" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652" +checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" dependencies = [ "proc-macro2", "quote", @@ -7918,9 +8066,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.10.4" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71adf41db68aa0daaefc69bb30bcd68ded9b9abaad5d1fbb6304c4fb390e083e" +checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" dependencies = [ "bytes", "prost-derive", @@ -7928,31 +8076,31 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.10.4" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae5a4388762d5815a9fc0dea33c56b021cdc8dde0c55e0c9ca57197254b0cab" +checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e" dependencies = [ "bytes", - "cfg-if 1.0.0", - "cmake", - "heck 0.4.0", + "heck", "itertools", "lazy_static", "log", "multimap", "petgraph", + "prettyplease", "prost", "prost-types", "regex", + "syn", "tempfile", "which", ] [[package]] name = "prost-codec" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00af1e92c33b4813cc79fda3f2dbf56af5169709be0202df730e9ebc3e4cd007" +checksum = "011ae9ff8359df7915f97302d591cdd9e0e27fbd5a4ddc5bd13b71079bb20987" dependencies = [ "asynchronous-codec", "bytes", @@ -7963,9 +8111,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.10.1" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b670f45da57fb8542ebdbb6105a925fe571b67f9e7ed9f47a06a84e72b4e7cc" +checksum = "8bda8c0881ea9f722eb9629376db3d0b903b462477c1aafcb0566610ac28ac5d" dependencies = [ "anyhow", "itertools", @@ -7976,9 +8124,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.10.1" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0a014229361011dc8e69c8a1ec6c2e8d0f2af7c91e3ea3f5b2170298461e68" +checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" dependencies = [ "bytes", "prost", @@ -8012,9 +8160,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -8133,20 +8281,19 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" dependencies = [ - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -8183,24 +8330,24 @@ dependencies = [ "derive_more", "fs-err", "itertools", - "static_init", + "static_init 0.5.2", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" dependencies = [ "proc-macro2", "quote", @@ -8209,9 +8356,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.2.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" +checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779" dependencies = [ "fxhash", "log", @@ -8221,9 +8368,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -8245,25 +8392,12 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "region" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ - "env_logger", - "jsonrpsee", + "env_logger 0.9.3", "log", "parity-scale-codec", "serde", @@ -8272,6 +8406,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-version", + "substrate-rpc-client", ] [[package]] @@ -8293,12 +8428,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "retain_mut" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0" - [[package]] name = "rfc6979" version = "0.1.0" @@ -8327,9 +8456,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620f4129485ff1a7128d184bc687470c21c7951b64779ebc9cfdad3dcd920290" +checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" dependencies = [ "libc", "librocksdb-sys", @@ -8337,8 +8466,8 @@ dependencies = [ [[package]] name = "rococo-runtime" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -8356,23 +8485,37 @@ dependencies = [ "pallet-balances", "pallet-beefy", "pallet-beefy-mmr", + "pallet-bounties", + "pallet-child-bounties", "pallet-collective", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-gilt", "pallet-grandpa", + "pallet-identity", "pallet-im-online", "pallet-indices", "pallet-membership", "pallet-mmr", "pallet-multisig", "pallet-offences", + "pallet-preimage", "pallet-proxy", + "pallet-recovery", + "pallet-scheduler", "pallet-session", + "pallet-society", "pallet-staking", "pallet-sudo", "pallet-timestamp", + "pallet-tips", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-utility", + "pallet-vesting", "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -8398,6 +8541,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "static_assertions", "substrate-wasm-builder", "xcm", "xcm-builder", @@ -8406,23 +8550,26 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "rpassword" -version = "5.0.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" dependencies = [ "libc", + "rtoolbox", "winapi", ] @@ -8441,6 +8588,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "rustc-demangle" version = "0.1.21" @@ -8474,42 +8631,42 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.14", + "semver 1.0.16", ] [[package]] name = "rustix" -version = "0.33.7" +version = "0.35.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" dependencies = [ "bitflags", "errno", - "io-lifetimes 0.5.3", + "io-lifetimes 0.7.5", "libc", - "linux-raw-sys 0.0.42", - "winapi", + "linux-raw-sys 0.0.46", + "windows-sys 0.42.0", ] [[package]] name = "rustix" -version = "0.35.13" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" dependencies = [ "bitflags", "errno", - "io-lifetimes 0.7.5", + "io-lifetimes 1.0.4", "libc", - "linux-raw-sys 0.0.46", + "linux-raw-sys 0.1.4", "windows-sys 0.42.0", ] [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -8531,18 +8688,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "rw-stream-sink" @@ -8557,9 +8714,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "safe-mix" @@ -8570,15 +8727,6 @@ dependencies = [ "rustc_version 0.2.3", ] -[[package]] -name = "salsa20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" -dependencies = [ - "cipher 0.4.3", -] - [[package]] name = "same-file" version = "1.0.6" @@ -8591,7 +8739,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "sp-core", @@ -8602,7 +8750,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -8615,7 +8763,7 @@ dependencies = [ "prost-build", "rand 0.7.3", "sc-client-api", - "sc-network", + "sc-network-common", "sp-api", "sp-authority-discovery", "sp-blockchain", @@ -8629,7 +8777,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "futures-timer", @@ -8652,7 +8800,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8668,13 +8816,13 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "impl-trait-for-tuples", "memmap2", "parity-scale-codec", "sc-chain-spec-derive", - "sc-network", + "sc-network-common", "sc-telemetry", "serde", "serde_json", @@ -8685,7 +8833,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8696,13 +8844,13 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "chrono", "clap", "fdlimit", "futures 0.3.25", - "hex", "libp2p", "log", "names", @@ -8714,6 +8862,7 @@ dependencies = [ "sc-client-db", "sc-keystore", "sc-network", + "sc-network-common", "sc-service", "sc-telemetry", "sc-tracing", @@ -8735,7 +8884,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "fnv", "futures 0.3.25", @@ -8763,7 +8912,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "hash-db", "kvdb", @@ -8788,7 +8937,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -8812,7 +8961,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -8841,20 +8990,19 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "fork-tree", "futures 0.3.25", "log", "merlin", - "num-bigint", + "num-bigint 0.2.6", "num-rational 0.2.4", "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "rand 0.7.3", - "retain_mut", "sc-client-api", "sc-consensus", "sc-consensus-epochs", @@ -8884,7 +9032,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "jsonrpsee", @@ -8906,7 +9054,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8919,7 +9067,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "assert_matches", "async-trait", @@ -8953,7 +9101,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -8971,25 +9119,13 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-timestamp", - "thiserror", -] - -[[package]] -name = "sc-consensus-uncles" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" -dependencies = [ - "sc-client-api", - "sp-authorship", - "sp-runtime", "thiserror", ] [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "lazy_static", "lru 0.7.8", @@ -9016,14 +9152,13 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "environmental", "parity-scale-codec", "sc-allocator", "sp-maybe-compressed-blob", "sp-sandbox", - "sp-serializer", "sp-wasm-interface", "thiserror", "wasm-instrument", @@ -9033,7 +9168,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "parity-scale-codec", @@ -9048,14 +9183,14 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "cfg-if 1.0.0", "libc", "log", "once_cell", "parity-scale-codec", - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", "rustix 0.35.13", "sc-allocator", "sc-executor-common", @@ -9068,16 +9203,16 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ahash", + "array-bytes", "async-trait", "dyn-clone", "finality-grandpa", "fork-tree", "futures 0.3.25", "futures-timer", - "hex", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -9088,6 +9223,7 @@ dependencies = [ "sc-consensus", "sc-keystore", "sc-network", + "sc-network-common", "sc-network-gossip", "sc-telemetry", "sc-utils", @@ -9108,7 +9244,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "finality-grandpa", "futures 0.3.25", @@ -9129,7 +9265,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ansi_term", "futures 0.3.25", @@ -9137,7 +9273,7 @@ dependencies = [ "log", "parity-util-mem", "sc-client-api", - "sc-network", + "sc-network-common", "sc-transaction-pool-api", "sp-blockchain", "sp-runtime", @@ -9146,10 +9282,10 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "async-trait", - "hex", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -9161,8 +9297,9 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "async-trait", "asynchronous-codec", "bitflags", @@ -9173,7 +9310,6 @@ dependencies = [ "fork-tree", "futures 0.3.25", "futures-timer", - "hex", "ip_network", "libp2p", "linked-hash-map", @@ -9184,14 +9320,11 @@ dependencies = [ "parking_lot 0.12.1", "pin-project", "prost", - "prost-build", "rand 0.7.3", "sc-block-builder", "sc-client-api", "sc-consensus", "sc-network-common", - "sc-network-light", - "sc-network-sync", "sc-peerset", "sc-utils", "serde", @@ -9201,32 +9334,63 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", - "sp-finality-grandpa", "sp-runtime", "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", - "void", "zeroize", ] +[[package]] +name = "sc-network-bitswap" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "cid", + "futures 0.3.25", + "libp2p", + "log", + "prost", + "prost-build", + "sc-client-api", + "sc-network-common", + "sp-blockchain", + "sp-runtime", + "thiserror", + "unsigned-varint", + "void", +] + [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "async-trait", + "bitflags", + "bytes", "futures 0.3.25", + "futures-timer", "libp2p", + "linked_hash_set", "parity-scale-codec", "prost-build", + "sc-consensus", "sc-peerset", + "serde", "smallvec", + "sp-blockchain", + "sp-consensus", + "sp-finality-grandpa", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", ] [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ahash", "futures 0.3.25", @@ -9234,7 +9398,8 @@ dependencies = [ "libp2p", "log", "lru 0.7.8", - "sc-network", + "sc-network-common", + "sc-peerset", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -9243,8 +9408,9 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "futures 0.3.25", "libp2p", "log", @@ -9263,15 +9429,15 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ - "bitflags", - "either", + "array-bytes", "fork-tree", "futures 0.3.25", "libp2p", "log", "lru 0.7.8", + "mockall", "parity-scale-codec", "prost", "prost-build", @@ -9279,6 +9445,7 @@ dependencies = [ "sc-consensus", "sc-network-common", "sc-peerset", + "sc-utils", "smallvec", "sp-arithmetic", "sp-blockchain", @@ -9289,25 +9456,46 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sc-network-transactions" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "array-bytes", + "futures 0.3.25", + "hex", + "libp2p", + "log", + "parity-scale-codec", + "pin-project", + "sc-network-common", + "sc-peerset", + "sp-consensus", + "sp-runtime", + "substrate-prometheus-endpoint", +] + [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "bytes", "fnv", "futures 0.3.25", "futures-timer", - "hex", "hyper", "hyper-rustls", + "libp2p", "num_cpus", "once_cell", "parity-scale-codec", "parking_lot 0.12.1", "rand 0.7.3", "sc-client-api", - "sc-network", + "sc-network-common", + "sc-peerset", "sc-utils", "sp-api", "sp-core", @@ -9320,7 +9508,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "libp2p", @@ -9333,7 +9521,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9342,7 +9530,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "hash-db", @@ -9372,7 +9560,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "jsonrpsee", @@ -9395,7 +9583,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "jsonrpsee", @@ -9405,10 +9593,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "sc-rpc-spec-v2" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "futures 0.3.25", + "hex", + "jsonrpsee", + "parity-scale-codec", + "sc-chain-spec", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-runtime", + "thiserror", +] + [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "directories", @@ -9432,10 +9639,15 @@ dependencies = [ "sc-informant", "sc-keystore", "sc-network", + "sc-network-bitswap", "sc-network-common", + "sc-network-light", + "sc-network-sync", + "sc-network-transactions", "sc-offchain", "sc-rpc", "sc-rpc-server", + "sc-rpc-spec-v2", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -9462,6 +9674,7 @@ dependencies = [ "sp-transaction-storage-proof", "sp-trie", "sp-version", + "static_init 1.0.3", "substrate-prometheus-endpoint", "tempfile", "thiserror", @@ -9473,7 +9686,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "parity-scale-codec", @@ -9487,7 +9700,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9506,7 +9719,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "libc", @@ -9525,7 +9738,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "chrono", "futures 0.3.25", @@ -9543,7 +9756,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ansi_term", "atty", @@ -9574,7 +9787,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9585,8 +9798,9 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "async-trait", "futures 0.3.25", "futures-timer", "linked-hash-map", @@ -9594,7 +9808,6 @@ dependencies = [ "parity-scale-codec", "parity-util-mem", "parking_lot 0.12.1", - "retain_mut", "sc-client-api", "sc-transaction-pool-api", "sc-utils", @@ -9612,8 +9825,9 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "async-trait", "futures 0.3.25", "log", "serde", @@ -9625,7 +9839,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "futures-timer", @@ -9637,9 +9851,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d8a765117b237ef233705cc2cc4c6a27fccd46eea6ef0c8c6dae5f3ef407f8" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -9651,9 +9865,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcd47b380d8c4541044e341dcd9475f55ba37ddc50c908d945fc036a8642496" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9663,12 +9877,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] @@ -9697,9 +9910,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "sct" @@ -9719,24 +9932,25 @@ checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" dependencies = [ "der", "generic-array 0.14.6", + "pkcs8", "subtle", "zeroize", ] [[package]] name = "secp256k1" -version = "0.21.3" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.4.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" dependencies = [ "cc", ] @@ -9752,9 +9966,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" dependencies = [ "bitflags", "core-foundation", @@ -9765,9 +9979,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" dependencies = [ "core-foundation-sys", "libc", @@ -9793,9 +10007,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" dependencies = [ "serde", ] @@ -9808,18 +10022,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -9828,9 +10042,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", @@ -9849,7 +10063,7 @@ dependencies = [ [[package]] name = "session-keys-primitives" version = "0.1.0" -source = "git+https://github.com/zeitgeistpm/moonbeam?branch=polkadot-v0.9.26#5d24d606a8a2cfeb75a3ab95b77087ebe6522cb0" +source = "git+https://github.com/zeitgeistpm/external#fc957f4629c4a4ee650d912e5d1cf1d50c1a2126" dependencies = [ "async-trait", "frame-support", @@ -9880,17 +10094,6 @@ dependencies = [ "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.6", -] - [[package]] name = "sha2" version = "0.8.2" @@ -10010,8 +10213,8 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" [[package]] name = "slot-range-helper" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "enumn", "parity-scale-codec", @@ -10050,7 +10253,7 @@ dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-pre.1", + "curve25519-dalek 4.0.0-pre.5", "rand_core 0.6.4", "ring", "rustc_version 0.4.0", @@ -10074,7 +10277,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "flate2", "futures 0.3.25", @@ -10087,7 +10290,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "hash-db", "log", @@ -10097,6 +10300,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-std", + "sp-trie", "sp-version", "thiserror", ] @@ -10104,7 +10308,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "blake2", "proc-macro-crate", @@ -10116,7 +10320,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10129,7 +10333,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "integer-sqrt", "num-traits", @@ -10144,7 +10348,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10157,7 +10361,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "parity-scale-codec", @@ -10169,7 +10373,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "sp-api", @@ -10181,7 +10385,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures 0.3.25", "log", @@ -10199,7 +10403,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -10218,7 +10422,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "parity-scale-codec", @@ -10236,7 +10440,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "merlin", @@ -10259,7 +10463,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10273,7 +10477,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10286,18 +10490,18 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "base58", "bitflags", - "blake2-rfc", + "blake2", "byteorder", "dyn-clonable", - "ed25519-dalek", + "ed25519-zebra", "futures 0.3.25", "hash-db", "hash256-std-hasher", - "hex", "impl-serde", "lazy_static", "libsecp256k1", @@ -10332,7 +10536,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "blake2", "byteorder", @@ -10346,7 +10550,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro2", "quote", @@ -10357,7 +10561,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10366,7 +10570,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "proc-macro2", "quote", @@ -10376,7 +10580,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "environmental", "parity-scale-codec", @@ -10387,7 +10591,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "finality-grandpa", "log", @@ -10405,7 +10609,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10419,8 +10623,9 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "bytes", "futures 0.3.25", "hash-db", "libsecp256k1", @@ -10444,18 +10649,18 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum 0.23.0", + "strum", ] [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures 0.3.25", @@ -10472,7 +10677,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "thiserror", "zstd", @@ -10481,10 +10686,11 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "parity-scale-codec", + "scale-info", "serde", "sp-api", "sp-core", @@ -10496,7 +10702,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10510,7 +10716,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "sp-api", "sp-core", @@ -10520,7 +10726,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "backtrace", "lazy_static", @@ -10530,7 +10736,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "rustc-hash", "serde", @@ -10540,7 +10746,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "either", "hash256-std-hasher", @@ -10557,13 +10763,15 @@ dependencies = [ "sp-core", "sp-io", "sp-std", + "sp-weights", ] [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "bytes", "impl-trait-for-tuples", "parity-scale-codec", "primitive-types", @@ -10579,7 +10787,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "Inflector", "proc-macro-crate", @@ -10591,30 +10799,21 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", - "parity-scale-codec", - "sp-core", - "sp-io", - "sp-std", - "sp-wasm-interface", - "wasmi", -] - -[[package]] -name = "sp-serializer" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" -dependencies = [ - "serde", - "serde_json", + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-std", + "sp-wasm-interface", + "wasmi", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10628,7 +10827,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "scale-info", @@ -10639,7 +10838,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "hash-db", "log", @@ -10661,12 +10860,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10679,7 +10878,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "log", "sp-core", @@ -10692,7 +10891,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "futures-timer", @@ -10708,7 +10907,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "sp-std", @@ -10720,7 +10919,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "sp-api", "sp-runtime", @@ -10729,7 +10928,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "async-trait", "log", @@ -10745,15 +10944,22 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "ahash", "hash-db", + "hashbrown 0.12.3", + "lazy_static", + "lru 0.7.8", "memory-db", + "nohash-hasher", "parity-scale-codec", + "parking_lot 0.12.1", "scale-info", "sp-core", "sp-std", "thiserror", + "tracing", "trie-db", "trie-root", ] @@ -10761,11 +10967,11 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "impl-serde", "parity-scale-codec", - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", "scale-info", "serde", "sp-core-hashing-proc-macro", @@ -10778,7 +10984,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10789,7 +10995,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "impl-trait-for-tuples", "log", @@ -10799,17 +11005,43 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "impl-trait-for-tuples", + "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 = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "ss58-registry" -version = "1.35.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0813c10b9dbdc842c2305f949f724c64866e4ef4d09c9151e96f6a2106773c" +checksum = "e40c020d72bc0a9c5660bb71e4a6fdef081493583062c474740a7d59f55f0e7b" dependencies = [ "Inflector", "num-format", @@ -10841,7 +11073,22 @@ dependencies = [ "cfg_aliases", "libc", "parking_lot 0.11.2", - "static_init_macro", + "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", + "cfg_aliases", + "libc", + "parking_lot 0.11.2", + "parking_lot_core 0.8.6", + "static_init_macro 1.0.2", + "winapi", ] [[package]] @@ -10857,6 +11104,19 @@ dependencies = [ "syn", ] +[[package]] +name = "static_init_macro" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" +dependencies = [ + "cfg_aliases", + "memchr", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "statrs" version = "0.15.0" @@ -10876,35 +11136,13 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "strum" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" -dependencies = [ - "strum_macros 0.23.1", -] - [[package]] name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros 0.24.3", -] - -[[package]] -name = "strum_macros" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" -dependencies = [ - "heck 0.3.3", - "proc-macro2", - "quote", - "rustversion", - "syn", + "strum_macros", ] [[package]] @@ -10913,7 +11151,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -10936,9 +11174,9 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ - "platforms", + "platforms 2.0.0", ] [[package]] @@ -10949,13 +11187,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "typenum 1.16.0", + "typenum 1.16.0 (git+https://github.com/encointer/typenum?tag=v1.16.0)", ] [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.25", @@ -10976,7 +11214,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "futures-util", "hyper", @@ -10986,10 +11224,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "substrate-rpc-client" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" +dependencies = [ + "async-trait", + "jsonrpsee", + "log", + "sc-rpc-api", + "serde", + "sp-runtime", +] + [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "jsonrpsee", "log", @@ -11010,11 +11261,11 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ + "array-bytes", "async-trait", "futures 0.3.25", - "hex", "parity-scale-codec", "sc-client-api", "sc-client-db", @@ -11036,14 +11287,14 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "ansi_term", "build-helper", "cargo_metadata", "filetime", "sp-maybe-compressed-blob", - "strum 0.23.0", + "strum", "tempfile", "toml", "walkdir", @@ -11058,9 +11309,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", @@ -11128,13 +11379,19 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" + [[package]] name = "test-case" version = "2.2.2" @@ -11159,36 +11416,32 @@ dependencies = [ [[package]] name = "test-runtime-constants" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -11234,9 +11487,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.4.3+5.2.1-patched.2" +version = "0.5.2+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49" +checksum = "ec45c14da997d0925c7835883e4d5c181f196fa142f8c19d7643d1e9af2592c3" dependencies = [ "cc", "fs_extra", @@ -11290,9 +11543,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.22.0" +version = "1.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" +checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" dependencies = [ "autocfg", "bytes", @@ -11305,7 +11558,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -11358,13 +11611,30 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" + +[[package]] +name = "toml_edit" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729bfd096e40da9c001f778f5cdecbd2957929a24e10e5883d9392220a751581" +dependencies = [ + "indexmap", + "nom8", + "toml_datetime", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -11373,9 +11643,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.34" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", "pin-project-lite 0.2.9", @@ -11396,11 +11666,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.26" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ - "lazy_static", + "once_cell", "valuable", ] @@ -11416,8 +11686,8 @@ dependencies = [ [[package]] name = "tracing-gum" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "polkadot-node-jaeger", "polkadot-primitives", @@ -11427,8 +11697,8 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "expander 0.0.6", "proc-macro-crate", @@ -11443,10 +11713,8 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" dependencies = [ - "ahash", "lazy_static", "log", - "lru 0.7.8", "tracing-core", ] @@ -11485,9 +11753,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.23.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" +checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" dependencies = [ "hash-db", "hashbrown 0.12.3", @@ -11507,9 +11775,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -11521,46 +11789,46 @@ dependencies = [ "idna 0.2.3", "ipnet", "lazy_static", - "log", "rand 0.8.5", "smallvec", "thiserror", "tinyvec", + "tracing", "url", ] [[package]] name = "trust-dns-resolver" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" dependencies = [ "cfg-if 1.0.0", "futures-util", "ipconfig", "lazy_static", - "log", "lru-cache", "parking_lot 0.12.1", "resolv-conf", "smallvec", "thiserror", + "tracing", "trust-dns-proto", ] [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.26#1cca061ede75a4c693a3b71bd1b61d7275fe29e4" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.32#5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1" dependencies = [ "clap", - "jsonrpsee", + "frame-try-runtime", "log", "parity-scale-codec", "remote-externalities", @@ -11576,14 +11844,16 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-version", + "sp-weights", + "substrate-rpc-client", "zstd", ] [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "twox-hash" @@ -11599,9 +11869,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "typenum" @@ -11641,15 +11911,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-normalization" @@ -11660,12 +11930,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" - [[package]] name = "unicode-width" version = "0.1.10" @@ -11725,13 +11989,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.0.0-alpha.9" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" -dependencies = [ - "ctor", - "version_check", -] +checksum = "a4d330786735ea358f3bc09eea4caa098569c1c93f342d9aca0514915022fe7e" [[package]] name = "vcpkg" @@ -11875,11 +12135,11 @@ dependencies = [ [[package]] name = "wasm-instrument" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "962e5b0401bbb6c887f54e69b8c496ea36f704df65db73e81fd5ff8dc3e63a9f" +checksum = "aa1dafb3e60065305741e83db35c6c2584bb3725b692b5b66148a38d72ace6cd" dependencies = [ - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", ] [[package]] @@ -11899,58 +12159,63 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.9.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" dependencies = [ - "downcast-rs", - "libc", - "libm", - "memory_units", - "num-rational 0.2.4", - "num-traits", - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", "wasmi-validation", + "wasmi_core", ] [[package]] name = "wasmi-validation" -version = "0.4.1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm 0.45.0", +] + +[[package]] +name = "wasmi_core" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ - "parity-wasm 0.42.2", + "downcast-rs", + "libm 0.2.6", + "memory_units", + "num-rational 0.4.1", + "num-traits", ] [[package]] name = "wasmparser" -version = "0.85.0" +version = "0.89.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" dependencies = [ "indexmap", ] [[package]] name = "wasmtime" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" +checksum = "4ad5af6ba38311282f2a21670d96e78266e8c8e2f38cbcd52c254df6ccbc7731" dependencies = [ "anyhow", - "backtrace", "bincode", "cfg-if 1.0.0", "indexmap", - "lazy_static", "libc", "log", - "object 0.28.4", + "object 0.29.0", "once_cell", "paste", "psm", "rayon", - "region", "serde", "target-lexicon", "wasmparser", @@ -11959,34 +12224,43 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "winapi", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45de63ddfc8b9223d1adc8f7b2ee5f35d1f6d112833934ad7ea66e4f4339e597" +dependencies = [ + "cfg-if 1.0.0", ] [[package]] name = "wasmtime-cache" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" +checksum = "bcd849399d17d2270141cfe47fa0d91ee52d5f8ea9b98cf7ddde0d53e5f79882" dependencies = [ "anyhow", - "base64", + "base64 0.13.1", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.33.7", + "rustix 0.35.13", "serde", "sha2 0.9.9", "toml", - "winapi", + "windows-sys 0.36.1", "zstd", ] [[package]] name = "wasmtime-cranelift" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" +checksum = "4bd91339b742ff20bfed4532a27b73c86b5bcbfedd6bea2dcdf2d64471e1b5c6" dependencies = [ "anyhow", "cranelift-codegen", @@ -11994,10 +12268,9 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.26.2", "log", - "more-asserts", - "object 0.28.4", + "object 0.29.0", "target-lexicon", "thiserror", "wasmparser", @@ -12006,17 +12279,16 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" +checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" dependencies = [ "anyhow", "cranelift-entity", - "gimli", + "gimli 0.26.2", "indexmap", "log", - "more-asserts", - "object 0.28.4", + "object 0.29.0", "serde", "target-lexicon", "thiserror", @@ -12026,49 +12298,47 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" +checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" dependencies = [ - "addr2line", + "addr2line 0.17.0", "anyhow", "bincode", "cfg-if 1.0.0", "cpp_demangle", - "gimli", + "gimli 0.26.2", "log", - "object 0.28.4", - "region", + "object 0.29.0", "rustc-demangle", - "rustix 0.33.7", + "rustix 0.35.13", "serde", "target-lexicon", "thiserror", "wasmtime-environ", "wasmtime-jit-debug", "wasmtime-runtime", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-jit-debug" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" +checksum = "f671b588486f5ccec8c5a3dba6b4c07eac2e66ab8c60e6f4e53717c77f709731" dependencies = [ - "lazy_static", - "object 0.28.4", - "rustix 0.33.7", + "object 0.29.0", + "once_cell", + "rustix 0.35.13", ] [[package]] name = "wasmtime-runtime" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" +checksum = "ee8f92ad4b61736339c29361da85769ebc200f184361959d1792832e592a1afd" dependencies = [ "anyhow", - "backtrace", "cc", "cfg-if 1.0.0", "indexmap", @@ -12077,21 +12347,21 @@ dependencies = [ "mach", "memfd", "memoffset 0.6.5", - "more-asserts", + "paste", "rand 0.8.5", - "region", - "rustix 0.33.7", + "rustix 0.35.13", "thiserror", + "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-types" -version = "0.38.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" +checksum = "d23d61cb4c46e837b431196dd06abb11731541021916d03476a178b54dc07aeb" dependencies = [ "cranelift-entity", "serde", @@ -12121,9 +12391,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ "webpki", ] @@ -12139,8 +12409,8 @@ dependencies = [ [[package]] name = "westend-runtime" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "beefy-primitives", "bitvec", @@ -12164,6 +12434,7 @@ dependencies = [ "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", + "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", "pallet-im-online", @@ -12172,6 +12443,7 @@ dependencies = [ "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", @@ -12227,21 +12499,23 @@ dependencies = [ [[package]] name = "westend-runtime-constants" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "which" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", "libc", @@ -12318,19 +12592,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.42.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" @@ -12346,9 +12620,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -12364,9 +12638,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -12382,9 +12656,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -12400,15 +12674,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -12424,9 +12698,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "winreg" @@ -12459,8 +12733,8 @@ dependencies = [ [[package]] name = "xcm" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "derivative", "impl-trait-for-tuples", @@ -12473,8 +12747,8 @@ dependencies = [ [[package]] name = "xcm-builder" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-support", "frame-system", @@ -12494,7 +12768,7 @@ dependencies = [ [[package]] name = "xcm-emulator" version = "0.1.0" -source = "git+https://github.com/shaunxw/xcm-simulator?rev=ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe#ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe" +source = "git+https://github.com/shaunxw/xcm-simulator?rev=158a6bd2768c679563efa891aa17329635b2764b#158a6bd2768c679563efa891aa17329635b2764b" dependencies = [ "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -12510,6 +12784,7 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-parachains", "quote", + "sp-arithmetic", "sp-io", "sp-std", "xcm", @@ -12518,8 +12793,8 @@ dependencies = [ [[package]] name = "xcm-executor" -version = "0.9.26" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "frame-benchmarking", "frame-support", @@ -12536,8 +12811,8 @@ dependencies = [ [[package]] name = "xcm-procedural" -version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.26#d8785970175dce344f2a6ad1cd88297529a6dd59" +version = "0.9.32" +source = "git+https://github.com/zeitgeistpm/polkadot.git?branch=v0.9.32-recent-bootnodes#90e98fe87db4b62c7722e802549d2b3739b07017" dependencies = [ "Inflector", "proc-macro2", @@ -12561,7 +12836,7 @@ dependencies = [ [[package]] name = "zeitgeist-node" -version = "0.3.7" +version = "0.3.9" dependencies = [ "battery-station-runtime", "cfg-if 1.0.0", @@ -12606,6 +12881,7 @@ dependencies = [ "sc-finality-grandpa", "sc-keystore", "sc-network", + "sc-network-common", "sc-rpc", "sc-rpc-api", "sc-service", @@ -12636,7 +12912,6 @@ dependencies = [ "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", - "tracing-core", "try-runtime-cli", "zeitgeist-primitives", "zeitgeist-runtime", @@ -12646,7 +12921,7 @@ dependencies = [ [[package]] name = "zeitgeist-primitives" -version = "0.3.7" +version = "0.3.9" dependencies = [ "arbitrary", "frame-support", @@ -12664,7 +12939,7 @@ dependencies = [ [[package]] name = "zeitgeist-runtime" -version = "0.3.7" +version = "0.3.9" dependencies = [ "cfg-if 1.0.0", "common-runtime", @@ -12683,7 +12958,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", - "kusama-runtime", "log", "nimbus-primitives", "orml-asset-registry", @@ -12701,7 +12975,8 @@ dependencies = [ "pallet-balances", "pallet-bounties", "pallet-collective", - "pallet-crowdloan-rewards", + "pallet-contracts", + "pallet-contracts-primitives", "pallet-democracy", "pallet-grandpa", "pallet-identity", @@ -12723,6 +12998,7 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", + "polkadot-runtime", "polkadot-runtime-parachains", "scale-info", "session-keys-primitives", @@ -12736,10 +13012,12 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", + "sp-std", "sp-transaction-pool", "sp-version", "substrate-fixed", "substrate-wasm-builder", + "test-case", "xcm", "xcm-builder", "xcm-emulator", @@ -12781,7 +13059,7 @@ dependencies = [ [[package]] name = "zrml-authorized" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -12798,7 +13076,7 @@ dependencies = [ [[package]] name = "zrml-court" -version = "0.3.7" +version = "0.3.9" dependencies = [ "arrayvec 0.7.2", "frame-benchmarking", @@ -12818,7 +13096,7 @@ dependencies = [ [[package]] name = "zrml-global-disputes" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -12838,7 +13116,7 @@ dependencies = [ [[package]] name = "zrml-liquidity-mining" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -12856,7 +13134,7 @@ dependencies = [ [[package]] name = "zrml-market-commons" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-support", "frame-system", @@ -12872,7 +13150,7 @@ dependencies = [ [[package]] name = "zrml-orderbook-v1" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -12901,12 +13179,13 @@ dependencies = [ [[package]] name = "zrml-prediction-markets" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "more-asserts", + "orml-asset-registry", "orml-currencies", "orml-tokens", "orml-traits", @@ -12916,12 +13195,14 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "scale-info", + "serde", "sp-api", "sp-arithmetic", "sp-io", "sp-runtime", "substrate-fixed", "test-case", + "xcm", "zeitgeist-primitives", "zrml-authorized", "zrml-court", @@ -12949,7 +13230,7 @@ dependencies = [ [[package]] name = "zrml-prediction-markets-runtime-api" -version = "0.3.7" +version = "0.3.9" dependencies = [ "parity-scale-codec", "sp-api", @@ -12958,7 +13239,7 @@ dependencies = [ [[package]] name = "zrml-rikiddo" -version = "0.3.7" +version = "0.3.9" dependencies = [ "arbitrary", "cfg-if 1.0.0", @@ -12991,7 +13272,7 @@ dependencies = [ [[package]] name = "zrml-simple-disputes" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -13008,7 +13289,7 @@ dependencies = [ [[package]] name = "zrml-styx" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -13024,7 +13305,7 @@ dependencies = [ [[package]] name = "zrml-swaps" -version = "0.3.7" +version = "0.3.9" dependencies = [ "frame-benchmarking", "frame-support", @@ -13066,7 +13347,7 @@ dependencies = [ [[package]] name = "zrml-swaps-rpc" -version = "0.3.7" +version = "0.3.9" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13079,11 +13360,12 @@ dependencies = [ [[package]] name = "zrml-swaps-runtime-api" -version = "0.3.7" +version = "0.3.9" dependencies = [ "parity-scale-codec", "sp-api", "sp-runtime", + "sp-std", "zeitgeist-primitives", ] @@ -13108,10 +13390,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.1+zstd.1.5.2" +version = "2.0.5+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +checksum = "edc50ffce891ad571e9f9afe5039c4837bede781ac4bb13052ed7ae695518596" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index d23a28b70..b6b4157cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,33 +46,6 @@ members = [ "zrml/styx", ] resolver = "2" - -[patch."https://github.com/purestake/crowdloan-rewards"] -# This patch does ensure that crowdloan-rewards only uses partiytech dependencies. -# If it is not used, the Zeitgeist runtimes will contain duplicate crates from -# different repositories which results in bigger WASM-blobs, binary and the inability -# to compile with the "runtime-benchmarks" feature. -pallet-crowdloan-rewards = { git = "https://github.com/zeitgeistpm/crowdloan-rewards", branch = "polkadot-v0.9.26" } - -[patch."https://github.com/purestake/moonbeam"] -# Use dependencies from Paritytech -moonbeam-vrf = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "polkadot-v0.9.26" } -# Fix author-mapping migration -pallet-author-mapping = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "polkadot-v0.9.26" } -# Use dependencies from Paritytech -pallet-parachain-staking = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "polkadot-v0.9.26" } -session-keys-primitives = { git = "https://github.com/zeitgeistpm/moonbeam", branch = "polkadot-v0.9.26" } - -[patch."https://github.com/purestake/nimbus"] -# Use dependencies from Paritytech -nimbus-consensus = { git = "https://github.com/zeitgeistpm/nimbus", branch = "polkadot-v0.9.26" } -# Use dependencies from Paritytech -nimbus-primitives = { git = "https://github.com/zeitgeistpm/nimbus", branch = "polkadot-v0.9.26" } -# Use dependencies from Paritytech -pallet-author-inherent = { git = "https://github.com/zeitgeistpm/nimbus", branch = "polkadot-v0.9.26" } -# Use dependencies from Paritytech -pallet-author-slot-filter = { git = "https://github.com/zeitgeistpm/nimbus", branch = "polkadot-v0.9.26" } - # The list of dependencies below (which can be both direct and indirect dependencies) are crates # that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of # their debug info might be missing) or to require to be frequently recompiled. We compile these @@ -139,3 +112,22 @@ lto = true opt-level = 3 # Zeitgeist runtime requires unwinding. panic = "unwind" + +[patch."https://github.com/paritytech/polkadot"] +pallet-xcm = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-cli = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-client = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-core-primitives = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-node-primitives = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-node-subsystem = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-overseer = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-parachain = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-primitives = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-runtime = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-runtime-parachains = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-service = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +polkadot-test-service = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +rococo-runtime = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +xcm = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +xcm-builder = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } +xcm-executor = { git = "https://github.com/zeitgeistpm/polkadot.git", branch = "v0.9.32-recent-bootnodes" } diff --git a/Dockerfile b/Dockerfile index 032016ed8..7cb7bb18e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,30 @@ # Based from https://github.com/paritytech/substrate/blob/master/.maintain/Dockerfile -FROM phusion/baseimage:bionic-1.0.0 as builder +FROM phusion/baseimage:jammy-1.0.1 as builder LABEL maintainer="hi@zeitgeit.pm" LABEL description="This is the build stage for the Zeitgeist node. Here is created the binary." ENV DEBIAN_FRONTEND=noninteractive -ARG PROFILE=release +ARG PROFILE=production ARG FEATURES=default WORKDIR /zeitgeist COPY . /zeitgeist RUN apt-get update && \ - apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \ - apt-get install -y cmake pkg-config libssl-dev git clang libclang-dev + apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ - export PATH="$PATH:$HOME/.cargo/bin" && \ - rustup toolchain install nightly-2022-04-13 && \ - rustup target add wasm32-unknown-unknown --toolchain nightly-2022-04-13 && \ - rustup default stable && \ - cargo build --profile "$PROFILE" --features "$FEATURES" +RUN ./scripts/init.sh nosudo + +RUN . "$HOME/.cargo/env" && cargo build --profile "$PROFILE" --features "$FEATURES" # ==== SECOND STAGE ==== -FROM phusion/baseimage:bionic-1.0.0 +FROM phusion/baseimage:jammy-1.0.1 LABEL maintainer="hi@zeitgeist.pm" LABEL description="This is the 2nd stage: a very small image where we copy the Zeigeist node binary." -ARG PROFILE=release +ARG PROFILE=production RUN mv /usr/share/ca* /tmp && \ rm -rf /usr/share/* && \ @@ -42,13 +38,12 @@ RUN ldd /usr/local/bin/zeitgeist && \ /usr/local/bin/zeitgeist --version # Shrinking -RUN rm -rf /usr/lib/python* && \ - rm -rf /usr/bin /usr/sbin /usr/share/man +RUN rm -rf /usr/lib/python* && rm -rf /usr/share/man USER zeitgeist EXPOSE 30333 9933 9944 -RUN mkdir /zeitgeist/data +RUN mkdir -p /zeitgeist/data VOLUME ["/zeitgeist/data"] diff --git a/Makefile b/Makefile index 129668d69..c3b5d6df7 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ check-dummy: try-runtime \ --execution=Native \ --chain=${TRYRUNTIME_CHAIN} \ + --no-spec-check-panic \ on-runtime-upgrade \ live \ --uri=${TRYRUNTIME_URL} diff --git a/README.md b/README.md index 6e54a9c1e..b31e630fb 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,14 @@ # Zeitgeist: An Evolving Blockchain for Prediction Markets and Futarchy -![Rust](https://github.com/zeitgeistpm/zeitgeist/workflows/Rust/badge.svg) - - - - +![Rust](https://github.com/zeitgeistpm/zeitgeist/workflows/Rust/badge.svg) [![Codecov](https://codecov.io/gh/zeitgeistpm/zeitgeist/branch/main/graph/badge.svg)](https://codecov.io/gh/zeitgeistpm/zeitgeist) [![Discord](https://img.shields.io/badge/discord-https%3A%2F%2Fdiscord.gg%2FMD3TbH3ctv-purple)](https://discord.gg/MD3TbH3ctv) [![Telegram](https://img.shields.io/badge/telegram-https%3A%2F%2Ft.me%2Fzeitgeist__official-blue)](https://t.me/zeitgeist_official) Zeitgeist is a decentralized network for creating, betting on, and resolving prediction markets. The platform's native currency, the ZTG, is used to sway the direction of the network, and as a means of last-call dispute resolution. Additionally, Zeitgeist is a protocol for efficient trading of prediction market shares and will one day become the backbone of the decentralized finance -ecosystem by allowing for traders to create complex financial contracts on +ecosystem by allowing traders to create complex financial contracts on virtually _anything_. ## Modules @@ -46,7 +42,7 @@ virtually _anything_. constants. - [rikiddo](./zrml/rikiddo) - The module contains a completely modular implementation of our novel market scoring rule [Rikiddo][rikiddo]. It also - offer a pallet, that other pallets can use to utilize the Rikiddo market + offers a pallet, that other pallets can use to utilize the Rikiddo market scoring rule. Rikiddo can be used by the automated market maker to determine swap prices. @@ -62,7 +58,7 @@ project and type: cargo build --release ``` -To build the parachain version, execute the following conmmand: +To build the parachain version, execute the following command: ``` cargo build --features parachain --release diff --git a/docs/STYLE_GUIDE.md b/docs/STYLE_GUIDE.md new file mode 100644 index 000000000..1dc3d15f8 --- /dev/null +++ b/docs/STYLE_GUIDE.md @@ -0,0 +1,111 @@ +# Style guide + +## Comments + +- Comments **must** be wrapped at 100 chars per line. +- Comments **must** be formulated in markdown. + +## Doc comments + +- Documentation is written using Markdown syntax. +- Function documentation should be kept lean and mean. Try to avoid documenting + the parameters, and instead choose self-documenting parameter names. If + parameters interact in a complex manner (for example, if two arguments of type + `Vec` must have the same length), then add a paragraph explaining this. +- Begin every docstring with a meaningful one sentence description of the + function in third person. +- Avoid WET documentation such as this: + + ```rust + /// Rejects a market. + /// + /// # Arguments: + /// + /// - `origin`: The origin calling the dispatchable + /// - `market_id`: The market id of the market to reject + pub fn reject_market( + origin: OriginFor, + #[pallet::compact] market_id: MarketIdOf, + ) -> DispatchResultWithPostInfo { + // --- snip! --- + } + ``` + + Self-explanatory function arguments need not be documented if they are + explained in full text. Instead, focus on describing the effects of the + function. Someone who doesn't know how to read the code must be able to + understand what the function does. + +- Docstrings for dispatchable **should** contain a section on runtime complexity + (to make understanding the benchmarks easier). +- Docstrings for dispatchables need not document the `origin` parameter, but + should specify what origins the dispatchable may be called by. +- Docstrings for dispatchables **must** include the events that the dispatchable + emits. +- Use `#![doc = include_str!("../README.md")]`. +- Detail non-trivial algorithms in comments inside the function. + +An example of a good docstring would be this: + +```rust +/// Rejects a market, destroying the market and unreserving and/or slashing the creator's advisory +/// bond. +/// +/// May only be (successfully) called by `RejectOrigin`. The fraction of the advisory bond that is +/// slashed is determined by `AdvisoryBondSlashPercentage`. +pub fn reject_market( + origin: OriginFor, + #[pallet::compact] market_id: MarketIdOf, +) -> DispatchResultWithPostInfo { + // --- snip! --- +} +``` + +Info like "The fraction of the advisory bond that is slashed is determined by +`AdvisoryBondSlashPercentage`" **may** be stored in `README.md` to avoid +duplicating documentation. + +## Formatting + +- rustfmt and clippy have the last say in formatting. +- Format code contained in macro invocations (`impl_benchmarks!`, + `decl_runtime_apis!`, homebrew macros in `runtime/`, etc.) and attributes + (`#[pallet::weight(...)`, etc.) manually. +- Add trailing commas in macro invocations manually, as rustfmt won't add them + automatically. + + ```rust + ensure!( + a_very_very_very_very_very_very_very_long_variable, + b_very_very_very_very_very_very_very_long_variable, // This comma is not ensured by rustfmt. + ) + ``` + +## Code Style + +- Never use panickers. +- Prefer double turbofish `Vec::::new()` over single turbofish + `>::new()`. +- All branches of match expressions **should** be explicit. Avoid using the + catch-all `_ =>`. +- When changing enums, maintain the existing order and add variants only at the + end of the enum to prevent messing up indices. +- Maintain lexicographical ordering of traits in `#[derive(...)]` attributes. + +## Crate and Pallet Structure + +- Don't dump all code into `lib.rs`. Split code multiple files (`types.rs`, + `traits.rs`, etc.) or even modules (`types/`, `traits/`, etc.). +- Changes to pallets **must** retain order of dispatchables. +- Sort pallet contents in the following order: + - `Config` trait + - Type values + - Types + - Storage items + - Genesis info + - `Event` enum + - `Error` enum + - Hooks + - Dispatchables + - Pallet's public and private functions + - Trait impelmentations diff --git a/docs/changelog_for_devs.md b/docs/changelog_for_devs.md index 9f113d413..491cdde57 100644 --- a/docs/changelog_for_devs.md +++ b/docs/changelog_for_devs.md @@ -1,10 +1,51 @@ -# v0.3.8 +# Changelog for Developers + +Used for communicating changes to other parts of Zeitgeist infrastructure +([zeitgeistpm/ui](https://github.com/zeitgeistpm/ui), +[zeitgeistpm/sdk-next](https://github.com/zeitgeistpm/sdk-next), +[zeitgeistpm/zeitgeist-subsquid](https://github.com/zeitgeistpm/zeitgeist-subsquid)) +and does not represent a complete changelog for the zeitgeistpm/zeitgeist +repository. + +As of 0.3.9, the changelog's format is based on +https://keepachangelog.com/en/1.0.0/ and ⚠️ marks changes that might break +components which query the chain's storage, the extrinsics or the runtime +APIs/RPC interface. + +## v0.3.9 + +[#1011]: https://github.com/zeitgeistpm/zeitgeist/pull/1011 +[#937]: https://github.com/zeitgeistpm/zeitgeist/pull/937 +[#903]: https://github.com/zeitgeistpm/zeitgeist/pull/903 + +### Changed + +- ⚠️ Add `outsider` field to `MarketBonds` struct. In particular, the `Market` + struct's layout has changed ([#903]). +- Adjust `deposit` function used to calculate storage fees for the following + pallets: identity, multisig, preimage, proxy. The cost of adding an identity + reduced from a minimum of 125 ZTG to a minimum of 1.5243 ZTG ([#1011]) + +### Fixed + +- ⚠️ Fix order of arguments for `get_spot_price` ([#937]). + +## v0.3.8 - Added the `bonds` field to the `Market` struct, which tracks the status of the advisory, oracle and validity bonds. Each of its members has type `Bond`, which has three fields: `who` (the account that reserved the bond), `value` (the amount reserved), `is_settled` (a flag which determines if the bond was already unreserved and/or (partially) slashed). +- The market dispute mechanisms are now able to control their resolution. The + `CorrectionPeriod` parameter determines how long the authorized pallet can + call `authorize_market_outcome` again after the first call to it (fat-finger + protection). The authority report now includes its resolution block number. + This is the time of the first call to `authorize_market_outcome` plus the + `CorrectionPeriod`. +- Create prediction markets with Ztg or registered foreign asset which has + `allow_as_base_asset` set to `true` in `AssetRegistry` metadata. Extrinsics + related to prediction market creation/editing now have `base_asset` parameter. # v0.3.7 diff --git a/docs/review_checklist.md b/docs/review_checklist.md new file mode 100644 index 000000000..90c94b2ce --- /dev/null +++ b/docs/review_checklist.md @@ -0,0 +1,87 @@ +- [ ] All todos contain a reference to an issue like this: `TODO(#999)`. +- [ ] The PR links relevant issues and contains a detailed description. +- [ ] All relevant labels were added. +- [ ] The docstrings are up to date. +- [ ] If the PR adds or changes extrinsics or functions used by extrinsics: + - [ ] The _Weight_ section in the documentation is up to date. + - [ ] The benchmarks are up to date. + - [ ] The call filters were adjusted. + - [ ] The extrinsics emit all the required events (see [Events](#events) + below). +- [ ] The module `README.md` is up to date. +- [ ] [docs.zeitgeist.pm] is up to date. +- [ ] `docs/changelog_for_devs.md` is up to date, specifically: + - [ ] Changes relevant to the Frontend Team (extrinsics changed, new + functions) are mentioned here. + - [ ] All new events are explained so they can easily be integrated into the + indexer. + - [ ] Breaking changes are marked as such. + - [ ] The file is formatted with `prettier -w docs/changelog_for_devs.md`. +- Sanity tests: + - [ ] The local temporary development node produces blocks: + `cargo run --profile=production -- --tmp`. + - [ ] The node syncs with Zeitgeist and Battery Station: + `cargo run --profile=production --features=parachain`, + `cargo run --profile=production --features=parachain -- --chain=battery_station`. + - [ ] `try-runtime` passes on Zeitgeist and Battery Station. +- [ ] Code quality: + - [ ] Avoidable compiler warnings were resolved. + - [ ] Integer arithmetic is only saturated/checked and all panickers are + removed. + - [ ] Code contained in macro invocations (benchmarks, + `runtime/common/src/lib.rs`, `decl_runtime_apis!`) is correctly + formatted. + - [ ] All `*.toml` files are formatted with `taplo` (run + `taplo format --check`). + - [ ] All copyright notices are up to date. + - [ ] Enums are sorted alphabetically, except for enums used in storage (to + prevent migrations), errors and events. +- [ ] In case an action is required by the Frontend Team, an issue was added to + zeitgeistpm/ui. +- [ ] In case the PR adds a new pallet, the pallet is added to the benchmark + configuration in `scripts/`. +- [ ] In case configuration items or storage elements were changed: Necessary + storage migrations are provided. +- [ ] In case configuration values changed: The implications have been discussed + with the + [code owners](https://github.com/zeitgeistpm/zeitgeist/blob/main/CODEOWNERS). +- [ ] If the changes include a storage migration: + - [ ] The affected pallet's `STORAGE_VERSION` was bumped. + - [ ] Try-runtime checks were added and the following conditions were ensured: + - [ ] The storage migration bumps the pallet version correctly. + - [ ] The try-runtime _fails_ if you comment out the migration code. + - [ ] The try-runtime passes without any warnings (substrate storage + operations often just log a warning instead of failing, so these + warnings usually point to problem which could break the storage). + +## Events + +_All_ modifications of the on-chain storage **must** be broadcast to indexers by +emitting a high-level event. The term _high-level_ event refers to an event +which may or may not contextualize _low-level_ events emitted by pallets that +Zeitgeist's business logic builds on, for example pallet-balances. Examples of +high-level events are: + +- `SwapExactAmountIn` (contextualizes a couple of low-level events like + `Transfer`) +- `PoolActive` (doesn't add context, but describes a storage change of a pool + structure) + +Furthermore, these modifications need to be detailed by specifying either a diff +or the new storage content, unless the change is absolutely clear from the +context. For example, `SwapExactAmountIn` specifies the balance changes that the +accounts suffer, but `PoolActive` only provides the id of the pool, _not_ the +new status (`Active`), which is clear from the context. Information that is +implicitly already available to the indexer **may** be provided, but this is not +necessary. For example, the `MarketRejected(market_id, reason)` event not only +specifies that the market with `market_id` was rejected and for what `reason`, +but also that the advisory bond and oracle bond are settled, but it doesn't +include the info how much the oracle bond actually was. + +Additional info (similar to the remark emitted by +[`remark_with_event`](https://github.com/paritytech/substrate/blob/6a504b063cf66351b6e352ef18cc18d49146487b/frame/system/src/lib.rs#L488-L499)) +**may** be added to the event. For example, +`MarketRequestedEdit(market_id, reason)` contains a `reason` which is not stored +anywhere in the chain storage. + +[docs.zeitgeist.pm]: docs.zeitgeist.pm diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 95ee09cd1..996ae53cd 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -3297,7 +3297,7 @@ "string.prototype.trimstart": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgroccWwziwYuZw==", "dev": true, "requires": { "call-bind": "^1.0.2", diff --git a/misc/frame_weight_template.hbs b/misc/frame_weight_template.hbs index 7c49be588..88ff5802e 100644 --- a/misc/frame_weight_template.hbs +++ b/misc/frame_weight_template.hbs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -44,22 +45,22 @@ impl {{pallet}}::weights::WeightInfo for WeightInfo {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} } {{/each}} diff --git a/misc/orml_weight_template.hbs b/misc/orml_weight_template.hbs index f77d35c8e..1fcc3355b 100644 --- a/misc/orml_weight_template.hbs +++ b/misc/orml_weight_template.hbs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -45,22 +46,22 @@ impl {{pallet}}::WeightInfo for WeightInfo { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} } {{/each}} diff --git a/misc/types.json b/misc/types.json deleted file mode 100644 index 1484a1354..000000000 --- a/misc/types.json +++ /dev/null @@ -1,347 +0,0 @@ -{ - "alias": { - "tokens": { - "AccountData": "TokensAccountData" - } - }, - "AccountData": { - "free": "Balance", - "reserved": "Balance", - "miscFrozen": "Balance", - "feeFrozen": "Balance" - }, - "Address": "MultiAddress", - "Amount": "i128", - "AmountOf": "i128", - "Asset": { - "_enum": { - "CategoricalOutcome": "(MarketId, CategoryIndex)", - "ScalarOutcome": "(MarketId, ScalarPosition)", - "CombinatorialOutcome": null, - "PoolShare": "u128", - "ZTG": null - } - }, - "AuthorId": "AccountId", - "BlockNumber": "u64", - "Bond": { - "owner": "AccountId", - "amount": "Balance" - }, - "CategoryIndex": "u16", - "Collator2": { - "id": "AccountId", - "bond": "Balance", - "nominators": "Vec", - "topNominators": "Vec", - "bottomNominators": "Vec", - "totalCounted": "Balance", - "totalBacking": "Balance", - "state": "CollatorStatus" - }, - "CollatorSnapshot": { - "bond": "Balance", - "delegations": "Vec", - "total": "Balance" - }, - "CollatorStatus": { - "_enum": { - "Active": null, - "Idle": null, - "Leaving": "RoundIndex" - } - }, - "CommonPoolEventParams": { - "poolId": "u128", - "who": "AccountId" - }, - "Currency": "Asset", - "CurrencyId": "Asset", - "CurrencyIdOf": "Asset", - "DelegatorStatus": { - "_enum": { - "Active": null, - "Leaving": "RoundIndex" - } - }, - "EmaConfig": { - "emaPeriod": "Timespan", - "emaPeriodEstimateAfter": "Option", - "smoothing": "u128" - }, - "EmaMarketVolume": { - "config": "EmaConfig", - "ema": "u128", - "multiplier": "u128", - "lastTime": "UnixTimestamp", - "state": "MarketVolumeState", - "startTime": "UnixTimestamp", - "volumesPerPeriod": "u128" - }, - "ExitQ": { - "candidates": "Vec", - "nominatorsLeaving": "Vec", - "candidateSchedule": "Vec<(AccountId, RoundIndex)>", - "nominatorSchedule": "Vec<(AccountId, Option, RoundIndex)>" - }, - "FeeSigmoid": { - "config": "FeeSigmoidConfig" - }, - "FeeSigmoidConfig": { - "m": "i128", - "p": "i128", - "n": "i128", - "initialFee": "i128", - "minRevenue": "i128" - }, - "Index": "u64", - "InflationInfo": { - "expect": "RangeBalance", - "annual": "RangePerbill", - "round": "RangePerbill" - }, - "Juror": { - "status": "JurorStatus" - }, - "JurorStatus": { - "_enum": [ - "Ok", - "Tardy" - ] - }, - "Lookup": "MultiAddress", - "Market": { - "creator": "AccountId", - "creation": "MarketCreation", - "creatorFee": "u8", - "oracle": "AccountId", - "metadata": "Vec", - "marketType": "MarketType", - "period": "MarketPeriod", - "scoringRule": "ScoringRule", - "status": "MarketStatus", - "report": "Option", - "resolvedOutcome": "Option", - "dispute_mechanism": "MarketDisputeMechanism" - }, - "MarketCreation": { - "_enum": [ - "Permissionless", - "Advised" - ] - }, - "MarketDispute": { - "at": "BlockNumber", - "by": "AccountId", - "outcome": "OutcomeReport" - }, - "MarketDisputeMechanism": { - "_enum": { - "Authorized": "AccountId", - "Court": null, - "SimpleDisputes": null - } - }, - "MarketId": "u128", - "MarketIdOf": "u128", - "MarketPeriod": { - "_enum": { - "Block": "Range", - "Timestamp": "Range" - } - }, - "MarketStatus": { - "_enum": [ - "Proposed", - "Active", - "Suspended", - "Closed", - "CollectingSubsidy", - "InsufficientSubsidy", - "Reported", - "Disputed", - "Resolved" - ] - }, - "MarketType": { - "_enum": { - "Categorical": "u16", - "Scalar": "RangeInclusive" - } - }, - "MarketVolumeState": { - "_enum": [ - "Uninitialized", - "DataCollectionStarted", - "DataCollected" - ] - }, - "MaxRuntimeUsize": "u64", - "Moment": "u64", - "MultiHash": { - "_enum": { - "Sha3_384": "[u8; 50]" - } - }, - "Nominator2": { - "delegations": "Vec", - "revocations": "Vec", - "total": "Balance", - "scheduledRevocationsCount": "u32", - "scheduledRevocationsTotal": "Balance", - "status": "DelegatorStatus" - }, - "NominatorAdded": { - "_enum": { - "AddedToTop": "Balance", - "AddedToBottom": null - } - }, - "Order": { - "side": "OrderSide", - "maker": "AccountId", - "taker": "Option", - "asset": "Asset", - "total": "Balance", - "price": "Balance", - "filled": "Balance" - }, - "OrderSide": { - "_enum": [ - "Bid", - "Ask" - ] - }, - "OrderedSet": "Vec", - "OwnedValuesParams": { - "participatedBlocks": "BlockNumber", - "perpetualIncentives": "Balance", - "totalIncentives": "Balance", - "totalShares": "Balance" - }, - "RangeBalance": { - "min": "Balance", - "ideal": "Balance", - "max": "Balance" - }, - "RangePerbill": { - "min": "Perbill", - "ideal": "Perbill", - "max": "Perbill" - }, - "RelayChainAccountId": "AccountId32", - "RewardInfo": { - "totalReward": "Balance", - "claimedReward": "Balance" - }, - "Rikiddo": { - "config": "RikiddoConfig", - "fees": "FeeSigmoid", - "maShort": "EmaMarketVolume", - "maLong": "EmaMarketVolume" - }, - "RikiddoConfig": { - "initialFee": "i128", - "log2E": "i128" - }, - "ScoringRule": { - "_enum": [ - "CPMM", - "RikiddoSigmoidFeeMarketEma" - ] - }, - "OutcomeReport": { - "_enum": { - "Categorical": "u16", - "Scalar": "u128" - } - }, - "ParachainBondConfig": { - "account": "AccountId", - "percent": "Percent" - }, - "Pool": { - "assets": "Vec", - "baseAsset": "Asset", - "marketId": "MarketId", - "poolStatus": "PoolStatus", - "scoringRule": "ScoringRule", - "swapFee": "Option", - "totalSubsidy": "Option", - "totalWeight": "Option", - "weights": "Option>" - }, - "PoolAssetEvent": { - "asset": "Asset", - "bound": "Balance", - "cpep": "CommonPoolEventParams", - "transferred": "Balance" - }, - "PoolAssetsEvent": { - "assets": "Vec", - "bounds": "Vec", - "cpep": "CommonPoolEventParams", - "transferred": "Vec" - }, - "PoolId": "u128", - "PoolStatus": { - "_enum": [ - "Active", - "CollectingSubsidy", - "Closed", - "Clean", - "Initialized" - ] - }, - "RegistrationInfo": { - "account": "AccountId", - "deposit": "Balance" - }, - "Report": { - "at": "BlockNumber", - "by": "AccountId", - "outcome": "OutcomeReport" - }, - "RoundInfo": { - "current": "RoundIndex", - "first": "BlockNumber", - "length": "u32" - }, - "RoundIndex": "u32", - "ScalarPosition": { - "_enum": [ - "Long", - "Short" - ] - }, - "SerdeWrapper": "Balance", - "SubsidyUntil": { - "marketId": "MarketId", - "period": "MarketPeriod" - }, - "SwapEvent": { - "assetAmountIn": "Balance", - "assetAmountOut": "Balance", - "assetBound": "Balance", - "assetIn": "Asset", - "assetOut": "Asset", - "cpep": "CommonPoolEventParams", - "maxPrice": "Balance" - }, - "Timespan": { - "_enum": { - "Seconds": "u32", - "Minutes": "u32", - "Hours": "u32", - "Days": "u16", - "Weeks": "u16" - } - }, - "TokensAccountData": { - "free": "Balance", - "reserved": "Balance", - "frozen": "Balance" - }, - "UnixTimestamp": "u64", - "VestingBlockNumber": "u32" -} diff --git a/misc/weight_template.hbs b/misc/weight_template.hbs index 49d63138d..c5c0ec357 100644 --- a/misc/weight_template.hbs +++ b/misc/weight_template.hbs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -57,22 +58,22 @@ impl WeightInfoZeitgeist for WeightInfo { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} } {{/each}} diff --git a/node/Cargo.toml b/node/Cargo.toml index a89fc7bbf..4df5d88a8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -3,103 +3,102 @@ name = "zeitgeist" path = "./src/main.rs" [build-dependencies] -substrate-build-script-utils = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +substrate-build-script-utils = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } [dependencies] -pallet-transaction-payment = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment-rpc = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-basic-authorship = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-cli = { branch = "polkadot-v0.9.26", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } -sc-client-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-consensus = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-executor = { branch = "polkadot-v0.9.26", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } -sc-keystore = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-rpc = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-rpc-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-service = { branch = "polkadot-v0.9.26", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } -sc-sysinfo = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-telemetry = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-transaction-pool = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-transaction-pool-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-block-builder = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-blockchain = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-consensus = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-core = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-inherents = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-keyring = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-offchain = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-session = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-storage = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-transaction-pool = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-trie = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -substrate-frame-rpc-system = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment-rpc = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-basic-authorship = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-cli = { branch = "polkadot-v0.9.32", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } +sc-client-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-consensus = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-executor = { branch = "polkadot-v0.9.32", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } +sc-keystore = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-rpc = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-rpc-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-service = { branch = "polkadot-v0.9.32", features = ["wasmtime"], git = "https://github.com/paritytech/substrate" } +sc-sysinfo = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-telemetry = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-transaction-pool = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-transaction-pool-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-block-builder = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-blockchain = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-consensus = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-core = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-inherents = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-keyring = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-offchain = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-session = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-storage = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-transaction-pool = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-trie = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +substrate-frame-rpc-system = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } # Try-Runtime -try-runtime-cli = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +try-runtime-cli = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } # Benchmark -frame-benchmarking = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -frame-benchmarking-cli = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +frame-benchmarking-cli = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } # Cumulus -cumulus-client-cli = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-client-collator = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-client-consensus-common = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-client-consensus-relay-chain = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-client-network = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-client-service = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-core = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-parachain-inherent = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-relay-chain-inprocess-interface = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-relay-chain-interface = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-relay-chain-rpc-interface = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-cli = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-collator = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-consensus-common = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-consensus-relay-chain = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-network = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-client-service = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-core = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-parachain-inherent = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-relay-chain-inprocess-interface = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-relay-chain-interface = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-relay-chain-rpc-interface = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/cumulus", optional = true } # Parachain -moonbeam-vrf = { tag = "v0.26.1", git = "https://github.com/purestake/moonbeam", optional = true } -nimbus-consensus = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -nimbus-primitives = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-inherent = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-parachain-staking = { tag = "v0.26.1", git = "https://github.com/purestake/moonbeam", optional = true } +moonbeam-vrf = { git = "https://github.com/zeitgeistpm/external", optional = true } +nimbus-consensus = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +nimbus-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-inherent = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-parachain-staking = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } parity-scale-codec = { optional = true, version = "3.0.0" } -sc-chain-spec = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sc-network = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sc-tracing = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -serde = { features = ["derive"], optional = true, version = "1.0.137" } -session-keys-primitives = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -sp-keystore = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -substrate-prometheus-endpoint = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +sc-chain-spec = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sc-network = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sc-network-common = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sc-tracing = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +serde = { features = ["derive"], optional = true, version = "1.0.144" } +session-keys-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +sp-keystore = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +substrate-prometheus-endpoint = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } # Polkadot -polkadot-cli = { branch = "release-v0.9.26", git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-parachain = { branch = "release-v0.9.26", git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-primitives = { branch = "release-v0.9.26", git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-service = { branch = "release-v0.9.26", git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-test-service = { branch = "release-v0.9.26", git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-cli = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-parachain = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-primitives = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-service = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-test-service = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true } # Standalone -sc-consensus-aura = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sc-finality-grandpa = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-consensus-aura = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-finality-grandpa = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +sc-consensus-aura = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sc-finality-grandpa = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-consensus-aura = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-finality-grandpa = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } # Utility cfg-if = { version = "1.0.0" } -clap = { version = "3.2.6", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive"] } hex-literal = { version = "0.3.4" } -jsonrpsee = { version = "0.14.0", features = ["server"] } -log = { optional = true, version = "0.4.17" } -# TODO(#865): Remove in future Polkadot release -tracing-core = "=0.1.26" +jsonrpsee = { version = "0.15.1", features = ["server"] } +log = { optional = true, version = "0.4.18" } # Zeitgeist @@ -142,6 +141,7 @@ parachain = [ "session-keys-primitives", "sc-chain-spec", "sc-network", + "sc-network-common", "sc-tracing", "serde", "sp-keystore", @@ -158,6 +158,8 @@ parachain = [ runtime-benchmarks = [ "battery-station-runtime?/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", + "frame-benchmarking-cli/runtime-benchmarks", + "polkadot-cli?/runtime-benchmarks", "polkadot-service?/runtime-benchmarks", "zeitgeist-runtime?/runtime-benchmarks", ] @@ -176,7 +178,7 @@ description = "An evolving blockchain for prediction markets and futarchy." edition = "2021" homepage = "https://zeitgeist.pm" name = "zeitgeist-node" -version = "0.3.7" +version = "0.3.9" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/node/res/bs_parachain.json b/node/res/bs_parachain.json index b34034a25..24eae3dbe 100644 --- a/node/res/bs_parachain.json +++ b/node/res/bs_parachain.json @@ -16,14 +16,14 @@ 0 ] ], - "protocolId": "battery_station_v2", + "protocolId": "battery_station_v3", "properties": { "ss58Format": 73, "tokenDecimals": 10, "tokenSymbol": "ZBS" }, - "parachain_id": 2050, - "relay_chain": "battery_station_relay_v3", + "parachain_id": 2101, + "relay_chain": "rococo", "consensusEngine": null, "codeSubstitutes": {}, "genesis": { diff --git a/node/res/zeitgeist_parachain.json b/node/res/zeitgeist_parachain.json index 1b956577b..18802a0af 100644 --- a/node/res/zeitgeist_parachain.json +++ b/node/res/zeitgeist_parachain.json @@ -18,14 +18,14 @@ 0 ] ], - "protocolId": "zeitgeist", + "protocolId": "zeitgeist-polkadot", "properties": { "ss58Format": 73, "tokenDecimals": 10, "tokenSymbol": "ZTG" }, - "parachain_id": 2101, - "relay_chain": "kusama", + "parachain_id": 2092, + "relay_chain": "polkadot", "consensusEngine": null, "codeSubstitutes": {}, "genesis": { diff --git a/node/src/command_helper.rs b/node/src/benchmarking.rs similarity index 72% rename from node/src/command_helper.rs rename to node/src/benchmarking.rs index 0253d06dd..d893ff953 100644 --- a/node/src/command_helper.rs +++ b/node/src/benchmarking.rs @@ -25,18 +25,18 @@ use sp_inherents::{InherentData, InherentDataProvider}; use sp_keyring::Sr25519Keyring; use sp_runtime::{OpaqueExtrinsic, SaturatedConversion}; use std::{sync::Arc, time::Duration}; -use zeitgeist_primitives::types::Signature; +use zeitgeist_primitives::types::{AccountId, Balance, Signature}; /// Generates extrinsics for the `benchmark overhead` command. /// /// Note: Should only be used for benchmarking. -pub struct BenchmarkExtrinsicBuilder { +pub struct RemarksExtrinsicBuilder { client: Arc>, is_zeitgeist: bool, } impl - BenchmarkExtrinsicBuilder + RemarksExtrinsicBuilder { /// Creates a new [`Self`] from the given client. pub fn new(client: Arc>, is_zeitgeist: bool) -> Self { @@ -45,9 +45,17 @@ impl } impl - frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder + frame_benchmarking_cli::ExtrinsicBuilder for RemarksExtrinsicBuilder { - fn remark(&self, nonce: u32) -> std::result::Result { + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> std::result::Result { let acc = Sr25519Keyring::Bob.pair(); #[cfg(feature = "with-zeitgeist-runtime")] @@ -75,6 +83,76 @@ impl } } +/// Generates `Balances::TransferKeepAlive` extrinsics for the benchmarks. +/// +/// Note: Should only be used for benchmarking. +pub struct TransferKeepAliveBuilder { + client: Arc>, + dest: AccountId, + value: Balance, + is_zeitgeist: bool, +} + +impl + TransferKeepAliveBuilder +{ + /// Creates a new [`Self`] from the given client. + pub fn new( + client: Arc>, + dest: AccountId, + value: Balance, + is_zeitgeist: bool, + ) -> Self { + Self { client, dest, value, is_zeitgeist } + } +} + +impl + frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder +{ + fn pallet(&self) -> &str { + "balances" + } + + fn extrinsic(&self) -> &str { + "transfer_keep_alive" + } + + fn build(&self, nonce: u32) -> std::result::Result { + let acc = Sr25519Keyring::Bob.pair(); + #[cfg(feature = "with-zeitgeist-runtime")] + if self.is_zeitgeist { + return Ok(create_benchmark_extrinsic_zeitgeist( + self.client.as_ref(), + acc, + zeitgeist_runtime::BalancesCall::transfer_keep_alive { + dest: self.dest.clone().into(), + value: self.value, + } + .into(), + nonce, + ) + .into()); + } + #[cfg(feature = "with-battery-station-runtime")] + if !self.is_zeitgeist { + return Ok(create_benchmark_extrinsic_battery_station( + self.client.as_ref(), + acc, + battery_station_runtime::BalancesCall::transfer_keep_alive { + dest: self.dest.clone().into(), + value: self.value, + } + .into(), + nonce, + ) + .into()); + } + + Err(crate::BATTERY_STATION_RUNTIME_NOT_AVAILABLE) + } +} + /// Creates a transaction using the given `call`. /// /// Note: Should only be used for benchmarking. @@ -85,7 +163,7 @@ pub fn create_benchmark_extrinsic_zeitgeist< >( client: &FullClient, sender: sp_core::sr25519::Pair, - call: zeitgeist_runtime::Call, + call: zeitgeist_runtime::RuntimeCall, nonce: u32, ) -> zeitgeist_runtime::UncheckedExtrinsic { let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); @@ -143,7 +221,7 @@ pub fn create_benchmark_extrinsic_battery_station< >( client: &FullClient, sender: sp_core::sr25519::Pair, - call: battery_station_runtime::Call, + call: battery_station_runtime::RuntimeCall, nonce: u32, ) -> battery_station_runtime::UncheckedExtrinsic { let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); diff --git a/node/src/chain_spec/additional_chain_spec.rs b/node/src/chain_spec/additional_chain_spec.rs index 0498ef136..d5324fce9 100644 --- a/node/src/chain_spec/additional_chain_spec.rs +++ b/node/src/chain_spec/additional_chain_spec.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -20,15 +21,18 @@ use { cumulus_primitives_core::ParaId, nimbus_primitives::NimbusId, pallet_parachain_staking::InflationInfo, + sp_runtime::{Perbill, Percent}, zeitgeist_primitives::types::{AccountId, Balance}, }; #[cfg(feature = "parachain")] pub struct AdditionalChainSpec { + pub blocks_per_round: u32, pub candidates: Vec<(AccountId, NimbusId, Balance)>, - pub crowdloan_fund_pot: Balance, + pub collator_commission: Perbill, pub inflation_info: InflationInfo, - pub nominations: Vec<(AccountId, AccountId, Balance)>, + pub nominations: Vec<(AccountId, AccountId, Balance, Percent)>, + pub parachain_bond_reserve_percent: Percent, pub parachain_id: ParaId, } diff --git a/node/src/chain_spec/battery_station.rs b/node/src/chain_spec/battery_station.rs index 7c8835db4..e7424c51e 100644 --- a/node/src/chain_spec/battery_station.rs +++ b/node/src/chain_spec/battery_station.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -33,8 +34,13 @@ use zeitgeist_primitives::{ #[cfg(feature = "parachain")] use { - super::{Extensions, DEFAULT_COLLATOR_INFLATION_INFO}, - battery_station_runtime::{CollatorDeposit, EligibilityValue, PolkadotXcmConfig}, + super::{generate_inflation_config_function, Extensions}, + crate::BATTERY_STATION_PARACHAIN_ID, + battery_station_runtime::{ + CollatorDeposit, DefaultBlocksPerRound, DefaultCollatorCommission, + DefaultParachainBondReservePercent, EligibilityValue, PolkadotXcmConfig, + }, + zeitgeist_primitives::constants::ztg::{STAKING_PTD, TOTAL_INITIAL_ZTG}, }; cfg_if::cfg_if! { @@ -42,7 +48,6 @@ cfg_if::cfg_if! { pub(super) const DEFAULT_STAKING_AMOUNT_BATTERY_STATION: u128 = 2_000 * BASE; const DEFAULT_COLLATOR_BALANCE_BATTERY_STATION: Option = DEFAULT_STAKING_AMOUNT_BATTERY_STATION.checked_add(CollatorDeposit::get()); - const DEFAULT_INITIAL_CROWDLOAN_FUNDS_BATTERY_STATION: u128 = 100 * BASE; pub type BatteryStationChainSpec = sc_service::GenericChainSpec; } else { pub type BatteryStationChainSpec = sc_service::GenericChainSpec; @@ -56,15 +61,22 @@ fn additional_chain_spec_staging_battery_station( parachain_id: cumulus_primitives_core::ParaId, ) -> AdditionalChainSpec { AdditionalChainSpec { + blocks_per_round: DefaultBlocksPerRound::get(), candidates: vec![( hex!["302f6d7467ae2d7e3b9b962bfc3b9d929da9fae5f1e8c977a031ddf721b0790d"].into(), hex!["e6ea0b63b2b5b7247a1e8280350a14c5f9e7745dec2fe3428b68aa4167d48e66"] .unchecked_into(), DEFAULT_STAKING_AMOUNT_BATTERY_STATION, )], - crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_BATTERY_STATION, - inflation_info: DEFAULT_COLLATOR_INFLATION_INFO, + collator_commission: DefaultCollatorCommission::get(), + inflation_info: inflation_config( + STAKING_PTD * Perbill::from_percent(40), + STAKING_PTD * Perbill::from_percent(70), + STAKING_PTD, + TOTAL_INITIAL_ZTG * BASE, + ), nominations: vec![], + parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(), parachain_id, } } @@ -87,7 +99,7 @@ fn endowed_accounts_staging_battery_station() -> Vec vec![ // 5D2L4ghyiYE8p2z7VNJo9JYwRuc8uzPWtMBqdVyvjRcsnw4P EndowedAccountWithBalance( - hex!["2a6c61a907556e4c673880b5767dd4be08339ee7f2a58d5137d0c19ca9570a5c"].into(), + root_key_staging_battery_station(), DEFAULT_INITIAL_BALANCE_BATTERY_STATION, ), // 5EeeZVU4SiPG6ZRY7o8aDcav2p2mZMdu3ZLzbREWuHktYdhX @@ -108,7 +120,6 @@ fn root_key_staging_battery_station() -> AccountId { hex!["2a6c61a907556e4c673880b5767dd4be08339ee7f2a58d5137d0c19ca9570a5c"].into() } -#[inline] pub(super) fn get_wasm() -> Result<&'static [u8], String> { battery_station_runtime::WASM_BINARY.ok_or_else(|| "WASM binary is not available".to_string()) } @@ -120,6 +131,9 @@ generate_generic_genesis_function!( }, ); +#[cfg(feature = "parachain")] +generate_inflation_config_function!(battery_station_runtime); + pub fn battery_station_staging_config() -> Result { let wasm = get_wasm()?; @@ -131,7 +145,7 @@ pub fn battery_station_staging_config() -> Result Result> 4; @@ -65,15 +77,22 @@ pub fn dev_config() -> Result { generic_genesis( #[cfg(feature = "parachain")] AdditionalChainSpec { + blocks_per_round: DefaultBlocksPerRound::get(), candidates: vec![( get_account_id_from_seed::("Alice"), get_from_seed::("Alice"), super::battery_station::DEFAULT_STAKING_AMOUNT_BATTERY_STATION, )], - crowdloan_fund_pot: zeitgeist_primitives::constants::BASE.saturating_mul(100), - inflation_info: crate::chain_spec::DEFAULT_COLLATOR_INFLATION_INFO, + collator_commission: DefaultCollatorCommission::get(), + inflation_info: inflation_config( + STAKING_PTD * Perbill::from_percent(40), + STAKING_PTD * Perbill::from_percent(70), + STAKING_PTD, + TOTAL_INITIAL_ZTG * BASE, + ), nominations: vec![], - parachain_id: 2050_u32.into(), + parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(), + parachain_id: crate::BATTERY_STATION_PARACHAIN_ID.into(), }, #[cfg(not(feature = "parachain"))] AdditionalChainSpec { @@ -105,7 +124,11 @@ pub fn dev_config() -> Result { None, Some(token_properties("DEV", battery_station_runtime::SS58Prefix::get())), #[cfg(feature = "parachain")] - crate::chain_spec::Extensions { relay_chain: "rococo-dev".into(), parachain_id: 2050_u32 }, + crate::chain_spec::Extensions { + relay_chain: "rococo-dev".into(), + parachain_id: crate::BATTERY_STATION_PARACHAIN_ID, + bad_blocks: None, + }, #[cfg(not(feature = "parachain"))] Default::default(), )) diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index fa2ebaa97..bedb1a0f5 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -42,46 +43,53 @@ use zeitgeist_primitives::{ constants::BalanceFractionalDecimals, types::{AccountId, Balance}, }; -#[cfg(feature = "parachain")] -use { - sp_runtime::Perbill, - zeitgeist_primitives::constants::{ztg, MILLISECS_PER_BLOCK}, - zeitgeist_runtime::DefaultBlocksPerRound, -}; cfg_if::cfg_if! { if #[cfg(feature = "parachain")] { // Common - pub(crate) const DEFAULT_COLLATOR_INFLATION_INFO: pallet_parachain_staking::InflationInfo = { - let hours_per_year = 8766; - let millisecs_per_year = hours_per_year * 60 * 60 * 1000; - let round_millisecs = DefaultBlocksPerRound::get() as u64 * MILLISECS_PER_BLOCK as u64; - let rounds_per_year = millisecs_per_year / round_millisecs; - - let annual_inflation = ztg::STAKING_PTD; - let expected_annual_amount = ztg::COLLATORS * zeitgeist_primitives::constants::BASE; - let round_inflation_parts = annual_inflation.deconstruct() as u64 / rounds_per_year; - let round_inflation = Perbill::from_parts(round_inflation_parts as _); - - pallet_parachain_staking::InflationInfo { - annual: pallet_parachain_staking::Range { - ideal: annual_inflation, - max: annual_inflation, - min: annual_inflation, - }, - expect: pallet_parachain_staking::Range { - ideal: expected_annual_amount, - max: expected_annual_amount, - min: expected_annual_amount, - }, - round: pallet_parachain_staking::Range { - ideal: round_inflation, - min: round_inflation, - max: round_inflation, - }, + macro_rules! generate_inflation_config_function { + ($runtime:ident) => { + use sp_runtime::Perbill; + + pub(super) fn inflation_config( + annual_inflation_min: Perbill, + annual_inflation_ideal: Perbill, + annual_inflation_max: Perbill, + total_supply: zeitgeist_primitives::types::Balance + ) -> pallet_parachain_staking::inflation::InflationInfo { + fn to_round_inflation(annual: pallet_parachain_staking::inflation::Range) -> pallet_parachain_staking::inflation::Range { + use pallet_parachain_staking::inflation::{ + perbill_annual_to_perbill_round, + }; + use $runtime::parachain_params::DefaultBlocksPerRound; + + perbill_annual_to_perbill_round( + annual, + // rounds per year + u32::try_from(zeitgeist_primitives::constants::BLOCKS_PER_YEAR).unwrap() / DefaultBlocksPerRound::get() + ) + } + let annual = pallet_parachain_staking::inflation::Range { + min: annual_inflation_min, + ideal: annual_inflation_ideal, + max: annual_inflation_max, + }; + pallet_parachain_staking::inflation::InflationInfo { + // staking expectations + expect: pallet_parachain_staking::inflation::Range { + min: Perbill::from_percent(5).mul_floor(total_supply), + ideal: Perbill::from_percent(10).mul_floor(total_supply), + max: Perbill::from_percent(15).mul_floor(total_supply), + }, + // annual inflation + annual, + round: to_round_inflation(annual), + } + } } - }; + } + pub(crate) use generate_inflation_config_function; pub type DummyChainSpec = sc_service::GenericChainSpec<(), Extensions>; } else { pub type DummyChainSpec = sc_service::GenericChainSpec<()>; @@ -116,7 +124,7 @@ macro_rules! generate_generic_genesis_function { }, #[cfg(feature = "parachain")] author_filter: $runtime::AuthorFilterConfig { - eligible_count: EligibilityValue::new_unchecked(50), + eligible_count: EligibilityValue::new_unchecked(1), }, #[cfg(feature = "parachain")] author_mapping: $runtime::AuthorMappingConfig { @@ -135,8 +143,6 @@ macro_rules! generate_generic_genesis_function { members: vec![].try_into().unwrap(), phantom: Default::default(), }, - #[cfg(feature = "parachain")] - crowdloan: $runtime::CrowdloanConfig { funded_amount: acs.crowdloan_fund_pot }, democracy: Default::default(), #[cfg(not(feature = "parachain"))] grandpa: $runtime::GrandpaConfig { @@ -150,14 +156,17 @@ macro_rules! generate_generic_genesis_function { parachain_info: $runtime::ParachainInfoConfig { parachain_id: acs.parachain_id }, #[cfg(feature = "parachain")] parachain_staking: $runtime::ParachainStakingConfig { + blocks_per_round: acs.blocks_per_round, candidates: acs .candidates .iter() .cloned() .map(|(account, _, bond)| (account, bond)) .collect(), + collator_commission: acs.collator_commission, inflation_config: acs.inflation_info, delegations: acs.nominations, + parachain_bond_reserve_percent: acs.parachain_bond_reserve_percent, }, #[cfg(feature = "parachain")] parachain_system: Default::default(), @@ -219,6 +228,8 @@ pub struct Extensions { pub parachain_id: u32, /// The relay chain of the Parachain. pub relay_chain: String, + /// Known bad block hashes. + pub bad_blocks: sc_client_api::BadBlocks, } #[cfg(feature = "parachain")] diff --git a/node/src/chain_spec/zeitgeist.rs b/node/src/chain_spec/zeitgeist.rs index dfdc7b20d..ab0a0420e 100644 --- a/node/src/chain_spec/zeitgeist.rs +++ b/node/src/chain_spec/zeitgeist.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,8 +18,10 @@ #![cfg(feature = "with-zeitgeist-runtime")] -use super::{AdditionalChainSpec, EndowedAccountWithBalance}; -use crate::chain_spec::{generate_generic_genesis_function, telemetry_endpoints, token_properties}; +use super::{ + generate_generic_genesis_function, telemetry_endpoints, token_properties, AdditionalChainSpec, + EndowedAccountWithBalance, +}; use hex_literal::hex; use sc_service::ChainType; use sp_core::crypto::UncheckedInto; @@ -28,8 +31,13 @@ use zeitgeist_primitives::constants::ztg::{LIQUIDITY_MINING, LIQUIDITY_MINING_PT #[cfg(feature = "parachain")] use { - super::{Extensions, DEFAULT_COLLATOR_INFLATION_INFO}, - zeitgeist_runtime::{CollatorDeposit, EligibilityValue, MinCollatorStk, PolkadotXcmConfig}, + super::{generate_inflation_config_function, Extensions}, + crate::POLKADOT_PARACHAIN_ID, + zeitgeist_primitives::constants::ztg::{STAKING_PTD, TOTAL_INITIAL_ZTG}, + zeitgeist_runtime::{ + CollatorDeposit, DefaultBlocksPerRound, DefaultCollatorCommission, + DefaultParachainBondReservePercent, EligibilityValue, MinCollatorStk, PolkadotXcmConfig, + }, }; cfg_if::cfg_if! { @@ -37,7 +45,6 @@ cfg_if::cfg_if! { const DEFAULT_STAKING_AMOUNT_ZEITGEIST: u128 = MinCollatorStk::get(); const DEFAULT_COLLATOR_BALANCE_ZEITGEIST: Option = DEFAULT_STAKING_AMOUNT_ZEITGEIST.checked_add(CollatorDeposit::get()); - const DEFAULT_INITIAL_CROWDLOAN_FUNDS_ZEITGEIST: u128 = 0; pub type ZeitgeistChainSpec = sc_service::GenericChainSpec; } else { pub type ZeitgeistChainSpec = sc_service::GenericChainSpec; @@ -71,7 +78,10 @@ fn endowed_accounts_staging_zeitgeist() -> Vec { fn additional_chain_spec_staging_zeitgeist( parachain_id: cumulus_primitives_core::ParaId, ) -> AdditionalChainSpec { + use zeitgeist_primitives::constants::BASE; + AdditionalChainSpec { + blocks_per_round: DefaultBlocksPerRound::get(), candidates: vec![ ( hex!["524e9aac979cbb9ecdb7acd1635755c3b15696321a3345ca77f0ab0ae23f675a"].into(), @@ -92,9 +102,15 @@ fn additional_chain_spec_staging_zeitgeist( DEFAULT_STAKING_AMOUNT_ZEITGEIST, ), ], - crowdloan_fund_pot: DEFAULT_INITIAL_CROWDLOAN_FUNDS_ZEITGEIST, - inflation_info: DEFAULT_COLLATOR_INFLATION_INFO, + collator_commission: DefaultCollatorCommission::get(), + inflation_info: inflation_config( + STAKING_PTD * Perbill::from_percent(40), + STAKING_PTD * Perbill::from_percent(70), + STAKING_PTD, + TOTAL_INITIAL_ZTG * BASE, + ), nominations: vec![], + parachain_bond_reserve_percent: DefaultParachainBondReservePercent::get(), parachain_id, } } @@ -113,13 +129,15 @@ fn additional_chain_spec_staging_zeitgeist() -> AdditionalChainSpec { } } -#[inline] pub(super) fn get_wasm() -> Result<&'static [u8], String> { zeitgeist_runtime::WASM_BINARY.ok_or_else(|| "WASM binary is not available".to_string()) } generate_generic_genesis_function!(zeitgeist_runtime,); +#[cfg(feature = "parachain")] +generate_inflation_config_function!(zeitgeist_runtime); + pub fn zeitgeist_staging_config() -> Result { let wasm = get_wasm()?; @@ -131,7 +149,7 @@ pub fn zeitgeist_staging_config() -> Result { generic_genesis( additional_chain_spec_staging_zeitgeist( #[cfg(feature = "parachain")] - crate::KUSAMA_PARACHAIN_ID.into(), + POLKADOT_PARACHAIN_ID.into(), ), endowed_accounts_staging_zeitgeist(), wasm, @@ -144,8 +162,9 @@ pub fn zeitgeist_staging_config() -> Result { Some(token_properties("ZTG", SS58Prefix::get())), #[cfg(feature = "parachain")] crate::chain_spec::Extensions { - relay_chain: "kusama".into(), - parachain_id: crate::KUSAMA_PARACHAIN_ID, + relay_chain: "polkadot".into(), + parachain_id: POLKADOT_PARACHAIN_ID, + bad_blocks: None, }, #[cfg(not(feature = "parachain"))] Default::default(), diff --git a/node/src/cli.rs b/node/src/cli.rs index e0609c5eb..0446312c5 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -442,84 +442,84 @@ impl sc_client_api::BlockBackend for Client { impl sc_client_api::StorageProvider for Client { fn storage( &self, - id: &BlockId, + hash: &::Hash, key: &StorageKey, ) -> sp_blockchain::Result> { - match_client!(self, storage(id, key)) + match_client!(self, storage(hash, key)) } fn storage_keys( &self, - id: &BlockId, + hash: &::Hash, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { - match_client!(self, storage_keys(id, key_prefix)) + match_client!(self, storage_keys(hash, key_prefix)) } fn storage_hash( &self, - id: &BlockId, + hash: &::Hash, key: &StorageKey, ) -> sp_blockchain::Result::Hash>> { - match_client!(self, storage_hash(id, key)) + match_client!(self, storage_hash(hash, key)) } fn storage_pairs( &self, - id: &BlockId, + hash: &::Hash, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { - match_client!(self, storage_pairs(id, key_prefix)) + match_client!(self, storage_pairs(hash, key_prefix)) } fn storage_keys_iter<'a>( &self, - id: &BlockId, + hash: &::Hash, prefix: Option<&'a StorageKey>, start_key: Option<&StorageKey>, ) -> sp_blockchain::Result< KeyIterator<'a, >::State, Block>, > { - match_client!(self, storage_keys_iter(id, prefix, start_key)) + match_client!(self, storage_keys_iter(hash, prefix, start_key)) } fn child_storage( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key: &StorageKey, ) -> sp_blockchain::Result> { - match_client!(self, child_storage(id, child_info, key)) + match_client!(self, child_storage(hash, child_info, key)) } fn child_storage_keys( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { - match_client!(self, child_storage_keys(id, child_info, key_prefix)) + match_client!(self, child_storage_keys(hash, child_info, key_prefix)) } fn child_storage_keys_iter<'a>( &self, - id: &BlockId, + hash: &::Hash, child_info: ChildInfo, prefix: Option<&'a StorageKey>, start_key: Option<&StorageKey>, ) -> sp_blockchain::Result< KeyIterator<'a, >::State, Block>, > { - match_client!(self, child_storage_keys_iter(id, child_info, prefix, start_key)) + match_client!(self, child_storage_keys_iter(hash, child_info, prefix, start_key)) } fn child_storage_hash( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key: &StorageKey, ) -> sp_blockchain::Result::Hash>> { - match_client!(self, child_storage_hash(id, child_info, key)) + match_client!(self, child_storage_hash(hash, child_info, key)) } } diff --git a/node/src/cli/cli_parachain.rs b/node/src/cli/cli_parachain.rs index 0e544b9eb..9b7810f18 100644 --- a/node/src/cli/cli_parachain.rs +++ b/node/src/cli/cli_parachain.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -60,7 +61,7 @@ impl sc_cli::CliConfiguration for RelayChainCli { } fn base_path(&self) -> sc_cli::Result> { - Ok(self.shared_params().base_path().or_else(|| self.base_path.clone().map(Into::into))) + Ok(self.shared_params().base_path()?.or_else(|| self.base_path.clone().map(Into::into))) } fn chain_id(&self, is_dev: bool) -> sc_cli::Result { @@ -150,12 +151,11 @@ impl sc_cli::CliConfiguration for RelayChainCli { self.base.base.shared_params() } - fn state_cache_child_ratio(&self) -> sc_cli::Result> { - self.base.base.state_cache_child_ratio() - } - - fn transaction_pool(&self) -> sc_cli::Result { - self.base.base.transaction_pool() + fn transaction_pool( + &self, + is_dev: bool, + ) -> sc_cli::Result { + self.base.base.transaction_pool(is_dev) } } diff --git a/node/src/command.rs b/node/src/command.rs index 5c4936a92..c0ef23837 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -16,20 +17,25 @@ // along with Zeitgeist. If not, see . use super::{ + benchmarking::{inherent_benchmark_data, RemarksExtrinsicBuilder, TransferKeepAliveBuilder}, cli::{Cli, Subcommand}, - command_helper::{inherent_benchmark_data, BenchmarkExtrinsicBuilder}, service::{new_chain_ops, new_full, IdentifyVariant}, }; -use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; +use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; use sc_cli::SubstrateCli; -use std::sync::Arc; +use sp_keyring::Sr25519Keyring; #[cfg(feature = "with-battery-station-runtime")] use { super::service::BatteryStationExecutor, - battery_station_runtime::RuntimeApi as BatteryStationRuntimeApi, + battery_station_runtime::{ + ExistentialDeposit as BatteryStationED, RuntimeApi as BatteryStationRuntimeApi, + }, }; #[cfg(feature = "with-zeitgeist-runtime")] -use {super::service::ZeitgeistExecutor, zeitgeist_runtime::RuntimeApi as ZeitgeistRuntimeApi}; +use { + super::service::ZeitgeistExecutor, + zeitgeist_runtime::{ExistentialDeposit as ZeitgeistED, RuntimeApi as ZeitgeistRuntimeApi}, +}; #[cfg(feature = "parachain")] use { sc_client_api::client::BlockBackend, @@ -109,6 +115,11 @@ pub fn run() -> sc_cli::Result<()> { BenchmarkCmd::Machine(cmd) => { runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) } + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => Err("Storage benchmarking can be enabled with \ + `--features runtime-benchmarks`." + .into()), + #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => match chain_spec { #[cfg(feature = "with-zeitgeist-runtime")] spec if spec.is_zeitgeist() => runner.sync_run(|config| { @@ -151,12 +162,13 @@ pub fn run() -> sc_cli::Result<()> { >(&config)?; let ext_builder = - BenchmarkExtrinsicBuilder::new(params.client.clone(), true); + RemarksExtrinsicBuilder::new(params.client.clone(), true); cmd.run( config, params.client, inherent_benchmark_data()?, - Arc::new(ext_builder), + Vec::new(), + &ext_builder, ) }), #[cfg(feature = "with-battery-station-runtime")] @@ -167,12 +179,72 @@ pub fn run() -> sc_cli::Result<()> { >(&config)?; let ext_builder = - BenchmarkExtrinsicBuilder::new(params.client.clone(), false); + RemarksExtrinsicBuilder::new(params.client.clone(), false); cmd.run( config, params.client, inherent_benchmark_data()?, - Arc::new(ext_builder), + Vec::new(), + &ext_builder, + ) + }), + #[cfg(not(feature = "with-battery-station-runtime"))] + _ => panic!("{}", crate::BATTERY_STATION_RUNTIME_NOT_AVAILABLE), + } + } + + BenchmarkCmd::Extrinsic(cmd) => { + if cfg!(feature = "parachain") { + return Err("Extrinsic is only supported in standalone chain".into()); + } + match chain_spec { + #[cfg(feature = "with-zeitgeist-runtime")] + spec if spec.is_zeitgeist() => runner.sync_run(|config| { + let params = crate::service::new_partial::< + zeitgeist_runtime::RuntimeApi, + ZeitgeistExecutor, + >(&config)?; + // Register the *Remark* and *TKA* builders. + let ext_factory = ExtrinsicFactory(vec![ + Box::new(RemarksExtrinsicBuilder::new(params.client.clone(), true)), + Box::new(TransferKeepAliveBuilder::new( + params.client.clone(), + Sr25519Keyring::Alice.to_account_id(), + ZeitgeistED::get(), + true, + )), + ]); + cmd.run( + params.client, + inherent_benchmark_data()?, + Vec::new(), + &ext_factory, + ) + }), + #[cfg(feature = "with-battery-station-runtime")] + _ => runner.sync_run(|config| { + let params = crate::service::new_partial::< + battery_station_runtime::RuntimeApi, + BatteryStationExecutor, + >(&config)?; + // Register the *Remark* and *TKA* builders. + let ext_factory = ExtrinsicFactory(vec![ + Box::new(RemarksExtrinsicBuilder::new( + params.client.clone(), + false, + )), + Box::new(TransferKeepAliveBuilder::new( + params.client.clone(), + Sr25519Keyring::Alice.to_account_id(), + BatteryStationED::get(), + false, + )), + ]); + cmd.run( + params.client, + inherent_benchmark_data()?, + Vec::new(), + &ext_factory, ) }), #[cfg(not(feature = "with-battery-station-runtime"))] @@ -421,7 +493,7 @@ fn none_command(cli: &Cli) -> sc_cli::Result<()> { ); let parachain_id = cumulus_primitives_core::ParaId::from( - cli.parachain_id.or(parachain_id_extension).unwrap_or(super::KUSAMA_PARACHAIN_ID), + cli.parachain_id.or(parachain_id_extension).unwrap_or(super::POLKADOT_PARACHAIN_ID), ); let parachain_account = @@ -484,10 +556,6 @@ fn none_command(cli: &Cli) -> sc_cli::Result<()> { fn none_command(cli: &Cli) -> sc_cli::Result<()> { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { - if let sc_cli::Role::Light = config.role { - return Err("Light client not supported!".into()); - } - match &config.chain_spec { #[cfg(feature = "with-zeitgeist-runtime")] spec if spec.is_zeitgeist() => new_full::( diff --git a/node/src/main.rs b/node/src/main.rs index 202e66293..256b159d6 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,10 +18,10 @@ #![warn(unused_extern_crates)] +mod benchmarking; mod chain_spec; mod cli; mod command; -mod command_helper; mod rpc; #[macro_use] mod service; @@ -34,9 +35,9 @@ pub const ZEITGEIST_RUNTIME_NOT_AVAILABLE: &str = "Zeitgeist runtime is not avai cfg_if::cfg_if!( if #[cfg(feature = "parachain")] { - const KUSAMA_PARACHAIN_ID: u32 = 2101; - const BATTERY_STATION_PARACHAIN_ID: u32 = 2050; - const KUSAMA_BLOCK_DURATION: core::time::Duration = core::time::Duration::from_secs(6); + const POLKADOT_PARACHAIN_ID: u32 = 2092; + const BATTERY_STATION_PARACHAIN_ID: u32 = 2101; + const POLKADOT_BLOCK_DURATION: core::time::Duration = core::time::Duration::from_secs(6); const SOFT_DEADLINE_PERCENT: sp_runtime::Percent = sp_runtime::Percent::from_percent(100); } ); diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 4fa35ceec..ffa85bead 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/node/src/service.rs b/node/src/service.rs index f61e46e3e..ef120727c 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -132,7 +133,6 @@ cfg_if::cfg_if! { /// Additional APIs for parachain runtimes pub trait AdditionalRuntimeApiCollection: sp_api::ApiExt - + nimbus_primitives::AuthorFilterAPI + nimbus_primitives::NimbusApi + cumulus_primitives_core::CollectCollationInfo + session_keys_primitives::VrfApi @@ -144,7 +144,6 @@ cfg_if::cfg_if! { impl AdditionalRuntimeApiCollection for Api where Api: sp_api::ApiExt - + nimbus_primitives::AuthorFilterAPI + nimbus_primitives::NimbusApi + cumulus_primitives_core::CollectCollationInfo + session_keys_primitives::VrfApi, diff --git a/node/src/service/service_parachain.rs b/node/src/service/service_parachain.rs index 5bf6cbbe3..b9adec1c1 100644 --- a/node/src/service/service_parachain.rs +++ b/node/src/service/service_parachain.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,9 +18,8 @@ use crate::{ service::{AdditionalRuntimeApiCollection, RuntimeApiCollection}, - KUSAMA_BLOCK_DURATION, SOFT_DEADLINE_PERCENT, + POLKADOT_BLOCK_DURATION, SOFT_DEADLINE_PERCENT, }; -use cumulus_client_cli::CollatorOptions; use cumulus_client_consensus_common::ParachainConsensus; use cumulus_client_network::BlockAnnounceValidator; use cumulus_client_service::{ @@ -32,7 +32,8 @@ use nimbus_consensus::{BuildNimbusConsensusParams, NimbusConsensus}; use nimbus_primitives::NimbusId; use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_network::NetworkService; -use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; +use sc_network_common::service::NetworkBlock; +use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; use sp_keystore::SyncCryptoStorePtr; @@ -233,7 +234,7 @@ where /// 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("🌔 Zeitgeist Parachain")] +#[sc_tracing::logging::prefix_logs_with("🔮 Zeitgeist Parachain")] async fn do_new_full( parachain_config: Configuration, polkadot_config: Configuration, @@ -261,10 +262,6 @@ where bool, ) -> Result>, sc_service::Error>, { - if matches!(parachain_config.role, Role::Light) { - return Err("Light client not supported!".into()); - } - let parachain_config = prepare_node_config(parachain_config); let params = new_partial::(¶chain_config)?; @@ -293,7 +290,7 @@ where let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue); - let (network, system_rpc_tx, start_network) = + let (network, system_rpc_tx, tx_handler_controller, start_network) = sc_service::build_network(sc_service::BuildNetworkParams { config: ¶chain_config, client: client.clone(), @@ -325,6 +322,7 @@ where keystore: params.keystore_container.sync_keystore(), network: network.clone(), rpc_builder, + tx_handler_controller, system_rpc_tx, task_manager: &mut task_manager, telemetry: telemetry.as_mut(), @@ -349,7 +347,7 @@ where Arc::new(move |hash, data| network.announce_block(hash, data)) }; - let relay_chain_slot_duration = KUSAMA_BLOCK_DURATION; + let relay_chain_slot_duration = POLKADOT_BLOCK_DURATION; if collator { let parachain_consensus = build_consensus( @@ -392,7 +390,6 @@ where relay_chain_interface, relay_chain_slot_duration, import_queue, - collator_options: CollatorOptions { relay_chain_rpc_url: Default::default() }, }; start_full_node(params)?; diff --git a/node/src/service/service_standalone.rs b/node/src/service/service_standalone.rs index 235284feb..6fe00885c 100644 --- a/node/src/service/service_standalone.rs +++ b/node/src/service/service_standalone.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. use crate::service::{AdditionalRuntimeApiCollection, RuntimeApiCollection}; -use sc_client_api::{BlockBackend, ExecutorProvider}; +use sc_client_api::BlockBackend; use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams}; use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_finality_grandpa::{grandpa_peers_set_config, protocol_standard_name, SharedVoterState}; @@ -95,7 +96,7 @@ where Vec::default(), )); - let (network, system_rpc_tx, network_starter) = + let (network, system_rpc_tx, tx_handler_controller, network_starter) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, client: client.clone(), @@ -141,6 +142,7 @@ where task_manager: &mut task_manager, transaction_pool: transaction_pool.clone(), rpc_builder: rpc_builder, + tx_handler_controller: tx_handler_controller, backend, system_rpc_tx, config, @@ -169,12 +171,9 @@ where telemetry.as_ref().map(|x| x.handle()), ); - let can_author_with = - sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let aura = sc_consensus_aura::start_aura::( + let aura = sc_consensus_aura::start_aura::( StartAuraParams { slot_duration, client, @@ -190,12 +189,11 @@ where slot_duration, ); - Ok((timestamp, slot)) + Ok((slot, timestamp)) }, force_authoring, backoff_authoring_blocks, keystore: keystore_container.sync_keystore(), - can_author_with, sync_oracle: network.clone(), justification_sync_link: network.clone(), block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), @@ -340,7 +338,7 @@ where let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - let import_queue = sc_consensus_aura::import_queue::( + let import_queue = sc_consensus_aura::import_queue::( ImportQueueParams { block_import: grandpa_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import.clone())), @@ -354,12 +352,9 @@ where slot_duration, ); - Ok((timestamp, slot)) + Ok((slot, timestamp)) }, spawner: &task_manager.spawn_essential_handle(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new( - client.executor().clone(), - ), registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 4fc57091d..87a5a04ad 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,15 +1,15 @@ [dependencies] arbitrary = { default-features = false, optional = true, version = "1.0" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-currencies = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-currencies = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -serde = { default-features = false, features = ["derive"], optional = true, version = "1.0.137" } -sp-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +serde = { default-features = false, features = ["derive"], optional = true, version = "1.0.144" } +sp-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } [dev-dependencies] test-case = "2.0.2" @@ -34,4 +34,4 @@ with-global-disputes = [] authors = ["Zeitgeist PM "] edition = "2021" name = "zeitgeist-primitives" -version = "0.3.7" +version = "0.3.9" diff --git a/primitives/src/asset.rs b/primitives/src/asset.rs index 92a99dc23..094f718c9 100644 --- a/primitives/src/asset.rs +++ b/primitives/src/asset.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 5675bbc16..ec0dd7740 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ #![allow( // Constants parameters inside `parameter_types!` already check // arithmetic operations at compile time - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #[cfg(feature = "mock")] @@ -29,6 +30,7 @@ use crate::types::{Balance, BlockNumber}; use frame_support::{parameter_types, PalletId}; // Definitions for time +pub const BLOCKS_PER_YEAR: BlockNumber = (BLOCKS_PER_DAY * 36525) / 100; pub const BLOCKS_PER_DAY: BlockNumber = BLOCKS_PER_HOUR * 24; pub const MILLISECS_PER_BLOCK: u32 = 12000; pub const BLOCKS_PER_MINUTE: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); @@ -40,8 +42,10 @@ pub const CENT: Balance = BASE / 100; // 100_000_000 pub const MILLI: Balance = CENT / 10; // 10_000_000 pub const MICRO: Balance = MILLI / 1000; // 10_000 +/// Storage cost per byte and item. +// Approach: Achieve same cost per item and bytes in relation to total supply as on Polkadot. pub const fn deposit(items: u32, bytes: u32) -> Balance { - items as Balance * 20 * BASE + (bytes as Balance) * 100 * MILLI + items as Balance * 150 * CENT + (bytes as Balance) * 75 * MICRO } // Rikiddo and TokensConfig @@ -77,6 +81,8 @@ pub const GLOBAL_DISPUTES_LOCK_ID: [u8; 8] = *b"zge/gdlk"; pub const LM_PALLET_ID: PalletId = PalletId(*b"zge/lymg"); // Prediction Markets +/// The maximum allowed market life time, measured in blocks. +pub const MAX_MARKET_LIFETIME: BlockNumber = 365 * BLOCKS_PER_DAY; /// Max. categories in a prediction market. pub const MAX_CATEGORIES: u16 = 64; /// The dispute_duration is time where users can dispute the outcome. diff --git a/primitives/src/constants/mock.rs b/primitives/src/constants/mock.rs index 5ceec13d6..3c0f64294 100644 --- a/primitives/src/constants/mock.rs +++ b/primitives/src/constants/mock.rs @@ -1,3 +1,21 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. +// Copyright 2022 Zeitgeist PM LLC. +// +// This file is part of Zeitgeist. +// +// Zeitgeist 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. +// +// Zeitgeist 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 Zeitgeist. If not, see . + #![cfg(feature = "mock")] pub use super::*; @@ -11,6 +29,7 @@ use orml_traits::parameter_type_with_key; // Authorized parameter_types! { pub const AuthorizedPalletId: PalletId = PalletId(*b"zge/atzd"); + pub const CorrectionPeriod: BlockNumber = 4; } // Court @@ -43,23 +62,24 @@ parameter_types! { pub const DisputeFactor: Balance = 2 * BASE; pub const GlobalDisputePeriod: BlockNumber = 7 * BLOCKS_PER_DAY; pub const MaxCategories: u16 = 10; + pub const MaxDisputeDuration: BlockNumber = 50; pub const MaxDisputes: u16 = 6; + pub const MaxEditReasonLen: u32 = 1024; + pub const MaxGracePeriod: BlockNumber = 20; + pub const MaxMarketLifetime: BlockNumber = 1_000_000; + pub const MaxOracleDuration: BlockNumber = 30; + pub const MaxRejectReasonLen: u32 = 1024; + // 2_678_400_000 = 31 days. + pub const MaxSubsidyPeriod: Moment = 2_678_400_000; pub const MinCategories: u16 = 2; + pub const MinDisputeDuration: BlockNumber = 2; + pub const MinOracleDuration: BlockNumber = 2; // 60_000 = 1 minute. Should be raised to something more reasonable in the future. pub const MinSubsidyPeriod: Moment = 60_000; - // 2_678_400_000 = 31 days. - pub const MaxSubsidyPeriod: Moment = 2_678_400_000; - pub const MaxMarketPeriod: Moment = u64::MAX / 2; pub const OracleBond: Balance = 50 * CENT; + pub const OutsiderBond: Balance = 2 * OracleBond::get(); pub const PmPalletId: PalletId = PalletId(*b"zge/pred"); pub const ValidityBond: Balance = 50 * CENT; - pub const MinDisputeDuration: BlockNumber = 2; - pub const MinOracleDuration: BlockNumber = 2; - pub const MaxDisputeDuration: BlockNumber = 50; - pub const MaxGracePeriod: BlockNumber = 20; - pub const MaxOracleDuration: BlockNumber = 30; - pub const MaxEditReasonLen: u32 = 1024; - pub const MaxRejectReasonLen: u32 = 1024; } // Simple disputes parameters @@ -77,8 +97,7 @@ parameter_types! { pub const MaxSwapFee: Balance = BASE / 10; // 10% pub const MaxTotalWeight: Balance = 50 * BASE; pub const MaxWeight: Balance = 50 * BASE; - pub const MinLiquidity: Balance = 100 * BASE; - pub const MinSubsidy: Balance = MinLiquidity::get(); + pub const MinSubsidy: Balance = 100 * BASE; pub const MinSubsidyPerAccount: Balance = MinSubsidy::get(); pub const MinWeight: Balance = BASE; pub const SwapsPalletId: PalletId = PalletId(*b"zge/swap"); diff --git a/primitives/src/constants/ztg.rs b/primitives/src/constants/ztg.rs index 849e07add..c46c63420 100644 --- a/primitives/src/constants/ztg.rs +++ b/primitives/src/constants/ztg.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -22,10 +23,10 @@ use sp_runtime::Perbill; /// Total ZTG amount for community incentives. pub const COMMUNITY_INCENTIVES: u128 = 2_000_000; -/// Total ZTG amount for collators +/// Total ZTG amount for collators. pub const COLLATORS: u128 = 0; -/// Total ZTG amount for liquidity mining +/// Total ZTG amount for liquidity mining. pub const LIQUIDITY_MINING: u128 = 0; /// Total ZTG amount for parachain lease. @@ -46,13 +47,19 @@ pub const TEAM_AND_ADVISORS: u128 = 15_000_000; /// Total ZTG amount for Zeitgesit foundation. pub const ZEITGEIST_FOUNDATION: u128 = 22_000_000; -// Inflation +/// Total ZTG amount at genesis. +pub const TOTAL_INITIAL_ZTG: u128 = COMMUNITY_INCENTIVES + + PARACHAIN_LEASE + + PUBLIC_SALE + + SEED_SALE + + STRATEGIC_SALE + + TEAM_AND_ADVISORS + + ZEITGEIST_FOUNDATION; -/// Perthousand crowdloan inflation. 1.5% -pub const CROWDLOAN_PTD: Perbill = Perbill::from_perthousand(15); +// Inflation -/// Perthousand liquidity mining inflation. 2% -pub const LIQUIDITY_MINING_PTD: Perbill = Perbill::from_perthousand(20); +/// Perthousand liquidity mining inflation. 0% +pub const LIQUIDITY_MINING_PTD: Perbill = Perbill::from_perthousand(0); -/// Perthousand collator staking inflation. 1.5% -pub const STAKING_PTD: Perbill = Perbill::from_perthousand(15); +/// Perthousand collator staking inflation. 5% +pub const STAKING_PTD: Perbill = Perbill::from_perthousand(50); diff --git a/primitives/src/market.rs b/primitives/src/market.rs index a2ccf417a..7a2cc3127 100644 --- a/primitives/src/market.rs +++ b/primitives/src/market.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -28,8 +29,11 @@ use sp_runtime::RuntimeDebug; /// * `BA`: Balance type for bonds /// * `BN`: Block number /// * `M`: Moment (time moment) +/// * `A`: Asset #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct Market { +pub struct Market { + /// Base asset of the market. + pub base_asset: A, /// Creator of this market. pub creator: AI, /// Creation type. @@ -83,6 +87,7 @@ impl Bond { pub struct MarketBonds { pub creation: Option>, pub oracle: Option>, + pub outsider: Option>, } impl MarketBonds { @@ -92,18 +97,20 @@ impl MarketBonds { Some(bond) if bond.who == *who => bond.value, _ => BA::zero(), }; - value_or_default(&self.creation).saturating_add(value_or_default(&self.oracle)) + value_or_default(&self.creation) + .saturating_add(value_or_default(&self.oracle)) + .saturating_add(value_or_default(&self.outsider)) } } // Used primarily for testing purposes. impl Default for MarketBonds { fn default() -> Self { - MarketBonds { creation: None, oracle: None } + MarketBonds { creation: None, oracle: None, outsider: None } } } -impl Market { +impl Market { // Returns the number of outcomes for a market. pub fn outcomes(&self) -> u16 { match self.market_type { @@ -129,15 +136,17 @@ impl Market { } } -impl MaxEncodedLen for Market +impl MaxEncodedLen for Market where AI: MaxEncodedLen, BA: MaxEncodedLen, BN: MaxEncodedLen, M: MaxEncodedLen, + A: MaxEncodedLen, { fn max_encoded_len() -> usize { AI::max_encoded_len() + .saturating_add(A::max_encoded_len()) .saturating_add(MarketCreation::max_encoded_len()) .saturating_add(u8::max_encoded_len()) .saturating_add(AI::max_encoded_len()) @@ -264,6 +273,12 @@ pub struct Report { pub outcome: OutcomeReport, } +#[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] +pub struct AuthorityReport { + pub resolve_at: BlockNumber, + pub outcome: OutcomeReport, +} + /// Contains a market id and the market period. /// /// * `BN`: Block Number @@ -279,9 +294,9 @@ pub struct SubsidyUntil { #[cfg(test)] mod tests { - use crate::market::*; + use crate::{market::*, types::Asset}; use test_case::test_case; - type Market = crate::market::Market; + type Market = crate::market::Market>; #[test_case( MarketType::Categorical(6), @@ -337,6 +352,7 @@ mod tests { expected: bool, ) { let market = Market { + base_asset: Asset::Ztg, creator: 1, creation: MarketCreation::Permissionless, creator_fee: 2, diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index ee21643ac..fe7ec219f 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -21,7 +22,7 @@ mod market_id; mod swaps; mod zeitgeist_multi_reservable_currency; -pub use dispute_api::DisputeApi; +pub use dispute_api::{DisputeApi, DisputeResolutionApi}; pub use market_commons_pallet_api::MarketCommonsPalletApi; pub use market_id::MarketId; pub use swaps::Swaps; diff --git a/primitives/src/traits/dispute_api.rs b/primitives/src/traits/dispute_api.rs index 41733edd8..caa7b94f3 100644 --- a/primitives/src/traits/dispute_api.rs +++ b/primitives/src/traits/dispute_api.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -15,8 +16,13 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{market::MarketDispute, outcome_report::OutcomeReport, types::Market}; -use frame_support::dispatch::DispatchResult; +use crate::{ + market::MarketDispute, + outcome_report::OutcomeReport, + types::{Asset, Market}, +}; +use frame_support::{dispatch::DispatchResult, pallet_prelude::Weight, BoundedVec}; +use parity_scale_codec::MaxEncodedLen; use sp_runtime::DispatchError; // Abstraction of the market type, which is not a part of `DisputeApi` because Rust doesn't support @@ -26,13 +32,14 @@ type MarketOfDisputeApi = Market< ::Balance, ::BlockNumber, ::Moment, + Asset<::MarketId>, >; pub trait DisputeApi { type AccountId; type Balance; type BlockNumber; - type MarketId; + type MarketId: MaxEncodedLen; type Moment; type Origin; @@ -60,4 +67,84 @@ pub trait DisputeApi { market_id: &Self::MarketId, market: &MarketOfDisputeApi, ) -> Result, DispatchError>; + + /// Query the future resolution block of a disputed market. + /// **May** assume that `market.dispute_mechanism` refers to the calling dispute API. + /// + /// # Returns + /// + /// Returns the future resolution block if available, otherwise `None`. + fn get_auto_resolve( + disputes: &[MarketDispute], + market_id: &Self::MarketId, + market: &MarketOfDisputeApi, + ) -> Result, DispatchError>; + + /// Returns `true` if the market dispute mechanism + /// was unable to come to a conclusion. + /// **May** assume that `market.dispute_mechanism` refers to the calling dispute API. + fn has_failed( + disputes: &[MarketDispute], + market_id: &Self::MarketId, + market: &MarketOfDisputeApi, + ) -> Result; +} + +type MarketOfDisputeResolutionApi = Market< + ::AccountId, + ::Balance, + ::BlockNumber, + ::Moment, + Asset<::MarketId>, +>; + +pub trait DisputeResolutionApi { + type AccountId; + type Balance; + type BlockNumber; + type MarketId: MaxEncodedLen; + type MaxDisputes; + type Moment; + + /// Resolve a market. + /// + /// **Should** only be called if the market dispute + /// mechanism is ready for the resolution ([`DisputeApi::on_resolution`]). + /// + /// # Returns + /// + /// Returns the consumed weight. + fn resolve( + market_id: &Self::MarketId, + market: &MarketOfDisputeResolutionApi, + ) -> Result; + + /// Add a future block resolution of a disputed market. + /// + /// # Returns + /// + /// Returns the number of elements in the storage structure. + fn add_auto_resolve( + market_id: &Self::MarketId, + resolve_at: Self::BlockNumber, + ) -> Result; + + /// Check if a future block resolution of a disputed market exists. + /// + /// # Returns + /// + /// Returns `true` if the future block resolution exists, otherwise `false`. + fn auto_resolve_exists(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> bool; + + /// Remove a future block resolution of a disputed market. + /// + /// # Returns + /// + /// Returns the number of elements in the storage structure. + fn remove_auto_resolve(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> u32; + + /// Get the disputes of a market. + fn get_disputes( + market_id: &Self::MarketId, + ) -> BoundedVec, Self::MaxDisputes>; } diff --git a/primitives/src/traits/market_commons_pallet_api.rs b/primitives/src/traits/market_commons_pallet_api.rs index d0e463a4d..280808028 100644 --- a/primitives/src/traits/market_commons_pallet_api.rs +++ b/primitives/src/traits/market_commons_pallet_api.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -16,7 +17,7 @@ // along with Zeitgeist. If not, see . #![allow(clippy::type_complexity)] -use crate::types::{Market, PoolId}; +use crate::types::{Asset, Market, PoolId}; use frame_support::{ dispatch::{DispatchError, DispatchResult}, pallet_prelude::{MaybeSerializeDeserialize, Member}, @@ -36,6 +37,7 @@ type MarketOf = Market< >>::Balance, ::BlockNumber, ::Moment, + Asset<::MarketId>, >; /// Abstraction over storage operations for markets diff --git a/primitives/src/traits/swaps.rs b/primitives/src/traits/swaps.rs index f8c5f6d2b..007808286 100644 --- a/primitives/src/traits/swaps.rs +++ b/primitives/src/traits/swaps.rs @@ -31,7 +31,7 @@ pub trait Swaps { /// # Arguments /// /// * `who`: The account that is the creator of the pool. Must have enough - /// funds for each of the assets to cover the `MinLiqudity`. + /// funds for each of the assets to cover the minimum balance. /// * `assets`: The assets that are used in the pool. /// * `base_asset`: The base asset in a prediction market swap pool (usually a currency). /// * `market_id`: The market id of the market the pool belongs to. diff --git a/primitives/src/traits/zeitgeist_multi_reservable_currency.rs b/primitives/src/traits/zeitgeist_multi_reservable_currency.rs index 71697493d..11db3909e 100644 --- a/primitives/src/traits/zeitgeist_multi_reservable_currency.rs +++ b/primitives/src/traits/zeitgeist_multi_reservable_currency.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,10 +18,9 @@ #![allow(clippy::type_complexity)] use alloc::vec::Vec; -use frame_support::traits::Get; use orml_tokens::{AccountData, Accounts, TotalIssuance}; use orml_traits::currency::NamedMultiReservableCurrency; -use sp_runtime::DispatchError; +use sp_runtime::{traits::Get, DispatchError}; /// Custom `NamedMultiReservableCurrency` trait. pub trait ZeitgeistAssetManager: NamedMultiReservableCurrency { @@ -48,7 +48,7 @@ where let mut total = 0; #[allow( // Iterator will never yield more than `usize::MAX` elements - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] let accounts = >::iter() .filter_map(|(k0, k1, v)| { diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 2d0a331d2..a380cf656 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -22,7 +23,7 @@ pub use crate::{ #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Result, Unstructured}; use frame_support::dispatch::Weight; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::{ generic, @@ -121,3 +122,49 @@ pub struct ResultWithWeightInfo { pub result: R, pub weight: Weight, } + +#[derive( + Clone, + Copy, + Debug, + Decode, + Default, + Encode, + Eq, + MaxEncodedLen, + Ord, + PartialEq, + PartialOrd, + TypeInfo, +)] +/// Custom XC asset metadata +pub struct CustomMetadata { + /// XCM-related metadata. + pub xcm: XcmMetadata, + + /// Whether an asset can be used as base_asset in pools. + pub allow_as_base_asset: bool, +} + +#[derive( + Clone, + Copy, + Debug, + Decode, + Default, + Encode, + Eq, + MaxEncodedLen, + Ord, + PartialEq, + PartialOrd, + TypeInfo, +)] +pub struct XcmMetadata { + /// The factor used to determine the fee. + /// It is multiplied by the fee that would have been paid in native currency, so it represents + /// the ratio `native_price / other_asset_price`. It is a fixed point decimal number containing + /// as many fractional decimals as the asset it is used for contains. + /// Should be updated regularly. + pub fee_factor: Option, +} diff --git a/runtime/battery-station/Cargo.toml b/runtime/battery-station/Cargo.toml index 6df889e83..eee248a39 100644 --- a/runtime/battery-station/Cargo.toml +++ b/runtime/battery-station/Cargo.toml @@ -1,102 +1,107 @@ [build-dependencies] -substrate-wasm-builder = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +substrate-wasm-builder = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } [dependencies] -frame-executive = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system-rpc-runtime-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-currencies = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -pallet-balances = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-bounties = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-collective = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-democracy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-identity = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-membership = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-multisig = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-preimage = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-proxy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-randomness-collective-flip = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-scheduler = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-sudo = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-treasury = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-utility = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-vesting = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-executive = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system-rpc-runtime-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-currencies = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +pallet-balances = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-bounties = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-collective = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts-primitives = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-democracy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-identity = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-membership = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-multisig = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-preimage = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-proxy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-randomness-collective-flip = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-scheduler = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-sudo = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-treasury = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-utility = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-vesting = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } +polkadot-primitives = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-block-builder = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-inherents = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-offchain = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-session = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-transaction-pool = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-version = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-block-builder = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-inherents = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-offchain = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-session = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-std = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-transaction-pool = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-version = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } substrate-fixed = { default-features = false, features = ["serde"], git = "https://github.com/encointer/substrate-fixed" } # Try-Runtime -frame-try-runtime = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-try-runtime = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } # Benchmark -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } -frame-system-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +frame-system-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } # Cumulus -cumulus-pallet-dmp-queue = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-parachain-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-xcm = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-utility = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -parachain-info = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-dmp-queue = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-parachain-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-xcm = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-utility = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +parachain-info = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } # Parachain +nimbus-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-inherent = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-mapping = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-slot-filter = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-parachain-staking = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +session-keys-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } -nimbus-primitives = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-inherent = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-mapping = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -pallet-author-slot-filter = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-crowdloan-rewards = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/crowdloan-rewards", optional = true } -pallet-parachain-staking = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -polkadot-parachain = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -session-keys-primitives = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } + +# Polkadot + +polkadot-parachain = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } # Standalone -pallet-aura = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-grandpa = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-consensus-aura = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-finality-grandpa = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-aura = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-grandpa = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-consensus-aura = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-finality-grandpa = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } # Utility cfg-if = { version = "1.0.0" } hex-literal = { default-features = false, optional = true, version = "0.3.4" } -log = { version = "0.4.17", default-features = false, optional = true } +log = { version = "0.4.18", default-features = false, optional = true } # XCM -kusama-runtime = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -orml-asset-registry = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-unknown-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-xcm-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-xtokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -pallet-xcm = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-primitives = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-runtime-parachains = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm-builder = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm-executor = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +orml-asset-registry = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-unknown-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-xcm-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-xtokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +pallet-xcm = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-runtime-parachains = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +rococo-runtime = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm-builder = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm-executor = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } # Zeitgeist @@ -115,12 +120,14 @@ zrml-swaps = { default-features = false, path = "../../zrml/swaps" } zrml-swaps-runtime-api = { default-features = false, path = "../../zrml/swaps/runtime-api" } [dev-dependencies] -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -xcm-emulator = { rev = "ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe", git = "https://github.com/shaunxw/xcm-simulator" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +test-case = "2.0.2" +xcm-emulator = { rev = "158a6bd2768c679563efa891aa17329635b2764b", git = "https://github.com/shaunxw/xcm-simulator" } [features] default = ["std"] parachain = [ + "zrml-prediction-markets/parachain", # Cumulus "cumulus-pallet-dmp-queue", @@ -138,21 +145,19 @@ parachain = [ "pallet-author-inherent", "pallet-author-mapping", "pallet-author-slot-filter", - "pallet-crowdloan-rewards", "pallet-parachain-staking", "polkadot-parachain", "session-keys-primitives", # XCM - "kusama-runtime", - "polkadot-primitives", - "polkadot-runtime-parachains", "orml-asset-registry", "orml-unknown-tokens", "orml-xcm-support", "orml-xtokens", "pallet-xcm", + "polkadot-runtime-parachains", + "rococo-runtime", "xcm-builder", "xcm-executor", "xcm", @@ -167,10 +172,9 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue?/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", - "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "hex-literal", - "kusama-runtime?/runtime-benchmarks", "orml-asset-registry?/runtime-benchmarks", "orml-tokens/runtime-benchmarks", "orml-benchmarking", @@ -181,7 +185,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", - "pallet-crowdloan-rewards?/runtime-benchmarks", + "pallet-contracts/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-identity/runtime-benchmarks", @@ -196,6 +200,7 @@ runtime-benchmarks = [ "pallet-vesting/runtime-benchmarks", "pallet-xcm?/runtime-benchmarks", "pallet-parachain-staking?/runtime-benchmarks", + "rococo-runtime?/runtime-benchmarks", "nimbus-primitives?/runtime-benchmarks", "session-keys-primitives?/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -223,6 +228,8 @@ std = [ "pallet-balances/std", "pallet-bounties/std", "pallet-collective/std", + "pallet-contracts/std", + "pallet-contracts-primitives/std", "pallet-democracy/std", "pallet-identity/std", "pallet-membership/std", @@ -239,6 +246,7 @@ std = [ "pallet-utility/std", "pallet-vesting/std", "parity-scale-codec/std", + "polkadot-primitives/std", "scale-info/std", "sp-api/std", "sp-block-builder/std", @@ -276,7 +284,6 @@ std = [ "pallet-author-inherent?/std", "pallet-author-mapping?/std", "pallet-author-slot-filter?/std", - "pallet-crowdloan-rewards?/std", "pallet-parachain-staking?/std", "session-keys-primitives?/std", @@ -294,14 +301,13 @@ std = [ # XCM - "kusama-runtime?/std", - "polkadot-primitives?/std", - "polkadot-runtime-parachains?/std", "orml-asset-registry?/std", "orml-unknown-tokens?/std", "orml-xcm-support?/std", "orml-xtokens?/std", "pallet-xcm?/std", + "polkadot-runtime-parachains?/std", + "rococo-runtime?/std", "xcm-builder?/std", "xcm-executor?/std", "xcm?/std", @@ -329,6 +335,7 @@ try-runtime = [ # System runtime pallets "frame-system/try-runtime", + "frame-support/try-runtime", "pallet-timestamp/try-runtime", "pallet-randomness-collective-flip/try-runtime", "pallet-scheduler/try-runtime", @@ -348,6 +355,7 @@ try-runtime = [ "pallet-membership/try-runtime", # Other Parity runtime pallets + "pallet-contracts/try-runtime", "pallet-identity/try-runtime", "pallet-utility/try-runtime", @@ -372,10 +380,23 @@ try-runtime = [ # Parachain "pallet-author-mapping?/try-runtime", + "pallet-author-inherent?/try-runtime", "pallet-author-slot-filter?/try-runtime", "pallet-parachain-staking?/try-runtime", # Required by pallet-parachain-staking@v0.26.1 "parity-scale-codec/full", + "pallet-proxy/try-runtime", + "pallet-grandpa/try-runtime", + "pallet-aura/try-runtime", + "pallet-sudo/try-runtime", + "pallet-xcm?/try-runtime", + + # Cumulus + "cumulus-pallet-parachain-system?/try-runtime", + "cumulus-pallet-xcm?/try-runtime", + "cumulus-pallet-dmp-queue?/try-runtime", + "cumulus-pallet-xcmp-queue?/try-runtime", + "parachain-info?/try-runtime", ] with-global-disputes = [ "zrml-global-disputes", @@ -387,7 +408,7 @@ with-global-disputes = [ authors = ["Zeitgeist PM "] edition = "2021" name = "battery-station-runtime" -version = "0.3.7" +version = "0.3.9" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/runtime/battery-station/src/integration_tests/mod.rs b/runtime/battery-station/src/integration_tests/mod.rs index 64f89683b..31216c4f4 100644 --- a/runtime/battery-station/src/integration_tests/mod.rs +++ b/runtime/battery-station/src/integration_tests/mod.rs @@ -1,4 +1,5 @@ // Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it diff --git a/runtime/battery-station/src/integration_tests/xcm/mod.rs b/runtime/battery-station/src/integration_tests/xcm/mod.rs index d2226363f..d37a62036 100644 --- a/runtime/battery-station/src/integration_tests/xcm/mod.rs +++ b/runtime/battery-station/src/integration_tests/xcm/mod.rs @@ -1,4 +1,5 @@ // Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it diff --git a/runtime/battery-station/src/integration_tests/xcm/setup.rs b/runtime/battery-station/src/integration_tests/xcm/setup.rs index 510c5b58d..83cae024f 100644 --- a/runtime/battery-station/src/integration_tests/xcm/setup.rs +++ b/runtime/battery-station/src/integration_tests/xcm/setup.rs @@ -1,5 +1,5 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021 Centrifuge Foundation (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -17,19 +17,18 @@ // along with Zeitgeist. If not, see . use crate::{ - xcm_config::{ - asset_registry::CustomMetadata, - config::{battery_station, general_key}, - }, - AccountId, AssetRegistry, Balance, CurrencyId, ExistentialDeposit, Origin, Runtime, System, + xcm_config::config::{battery_station, general_key}, + AccountId, AssetRegistry, Balance, CurrencyId, ExistentialDeposit, Runtime, RuntimeOrigin, + System, }; use frame_support::{assert_ok, traits::GenesisBuild}; use orml_traits::asset_registry::AssetMetadata; +use sp_runtime::AccountId32; use xcm::{ latest::{Junction::Parachain, Junctions::X2, MultiLocation}, VersionedMultiLocation, }; -use zeitgeist_primitives::types::Asset; +use zeitgeist_primitives::types::{Asset, CustomMetadata}; pub(super) struct ExtBuilder { balances: Vec<(AccountId, CurrencyId, Balance)>, @@ -97,8 +96,8 @@ impl ExtBuilder { } /// Accounts -pub const ALICE: [u8; 32] = [4u8; 32]; -pub const BOB: [u8; 32] = [5u8; 32]; +pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]); +pub const BOB: AccountId32 = AccountId32::new([1u8; 32]); /// A PARA ID used for a sibling parachain. /// It must be one that doesn't collide with any other in use. @@ -136,7 +135,7 @@ pub(super) fn register_foreign_ztg(additional_meta: Option) { additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_ZTG_ID))); + assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), meta, Some(FOREIGN_ZTG_ID))); } pub(super) fn register_foreign_sibling(additional_meta: Option) { @@ -150,21 +149,25 @@ pub(super) fn register_foreign_sibling(additional_meta: Option) additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_SIBLING_ID))); + assert_ok!(AssetRegistry::register_asset( + RuntimeOrigin::root(), + meta, + Some(FOREIGN_SIBLING_ID) + )); } pub(super) fn register_foreign_parent(additional_meta: Option) { - // Register KSM as foreign asset in the sibling parachain + // Register roc as foreign asset in the sibling parachain let meta: AssetMetadata = AssetMetadata { decimals: 12, - name: "Kusama".into(), - symbol: "KSM".into(), - existential_deposit: 10_000_000_000, // 0.01 + name: "Rococo".into(), + symbol: "ROC".into(), + existential_deposit: 33_333_333, // 0.0033333333 location: Some(VersionedMultiLocation::V1(foreign_parent_multilocation())), additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_PARENT_ID))); + assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), meta, Some(FOREIGN_PARENT_ID))); } #[inline] @@ -173,7 +176,7 @@ pub(super) fn ztg(amount: Balance) -> Balance { } #[inline] -pub(super) fn ksm(amount: Balance) -> Balance { +pub(super) fn roc(amount: Balance) -> Balance { foreign(amount, 12) } diff --git a/runtime/battery-station/src/integration_tests/xcm/test_net.rs b/runtime/battery-station/src/integration_tests/xcm/test_net.rs index 8d6d8351d..7e1becfd9 100644 --- a/runtime/battery-station/src/integration_tests/xcm/test_net.rs +++ b/runtime/battery-station/src/integration_tests/xcm/test_net.rs @@ -1,5 +1,6 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Centrifuge GmbH (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it @@ -16,20 +17,23 @@ // along with Zeitgeist. If not, see . use crate::{ - parameters::ZeitgeistTreasuryAccount, xcm_config::config::battery_station, AccountId, - CurrencyId, DmpQueue, Origin, Runtime, XcmpQueue, + parameters::ZeitgeistTreasuryAccount, xcm_config::config::battery_station, CurrencyId, + DmpQueue, Runtime, RuntimeOrigin, XcmpQueue, }; use frame_support::{traits::GenesisBuild, weights::Weight}; -use polkadot_primitives::v2::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; +use polkadot_primitives::{ + runtime_api::runtime_decl_for_ParachainHost::ParachainHostV3, + v2::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}, +}; use polkadot_runtime_parachains::configuration::HostConfiguration; use xcm_emulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain}; -use super::setup::{ksm, ztg, ExtBuilder, ALICE, FOREIGN_PARENT_ID, PARA_ID_SIBLING}; +use super::setup::{roc, ztg, ExtBuilder, ALICE, FOREIGN_PARENT_ID, PARA_ID_SIBLING}; decl_test_relay_chain! { - pub struct KusamaNet { - Runtime = kusama_runtime::Runtime, - XcmConfig = kusama_runtime::xcm_config::XcmConfig, + pub struct RococoNet { + Runtime = rococo_runtime::Runtime, + XcmConfig = rococo_runtime::xcm_config::XcmConfig, new_ext = relay_ext(), } } @@ -37,7 +41,7 @@ decl_test_relay_chain! { decl_test_parachain! { pub struct Zeitgeist { Runtime = Runtime, - Origin = Origin, + RuntimeOrigin = RuntimeOrigin, XcmpMessageHandler = XcmpQueue, DmpMessageHandler = DmpQueue, new_ext = para_ext(battery_station::ID), @@ -47,7 +51,7 @@ decl_test_parachain! { decl_test_parachain! { pub struct Sibling { Runtime = Runtime, - Origin = Origin, + RuntimeOrigin = RuntimeOrigin, XcmpMessageHandler = XcmpQueue, DmpMessageHandler = DmpQueue, new_ext = para_ext(PARA_ID_SIBLING), @@ -56,13 +60,13 @@ decl_test_parachain! { decl_test_network! { pub struct TestNet { - relay_chain = KusamaNet, + relay_chain = RococoNet, parachains = vec![ // N.B: Ideally, we could use the defined para id constants but doing so // fails with: "error: arbitrary expressions aren't allowed in patterns" // Be sure to use `xcm_config::config::battery_station::ID` - (2050, Zeitgeist), + (2101, Zeitgeist), // Be sure to use `PARA_ID_SIBLING` (3000, Sibling), ], @@ -70,15 +74,13 @@ decl_test_network! { } pub(super) fn relay_ext() -> sp_io::TestExternalities { - use kusama_runtime::{Runtime, System}; + use rococo_runtime::{Runtime, System}; let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { - balances: vec![(AccountId::from(ALICE), ksm(2002))], - } - .assimilate_storage(&mut t) - .unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(ALICE, roc(2002))] } + .assimilate_storage(&mut t) + .unwrap(); polkadot_runtime_parachains::configuration::GenesisConfig:: { config: default_parachains_host_configuration(), @@ -100,9 +102,9 @@ pub(super) fn relay_ext() -> sp_io::TestExternalities { pub(super) fn para_ext(parachain_id: u32) -> sp_io::TestExternalities { ExtBuilder::default() .set_balances(vec![ - (AccountId::from(ALICE), CurrencyId::Ztg, ztg(10)), - (AccountId::from(ALICE), FOREIGN_PARENT_ID, ksm(10)), - (ZeitgeistTreasuryAccount::get(), FOREIGN_PARENT_ID, ksm(1)), + (ALICE, CurrencyId::Ztg, ztg(10)), + (ALICE, FOREIGN_PARENT_ID, roc(10)), + (ZeitgeistTreasuryAccount::get(), FOREIGN_PARENT_ID, roc(1)), ]) .set_parachain_id(parachain_id) .build() @@ -123,7 +125,7 @@ fn default_parachains_host_configuration() -> HostConfiguration { max_upward_queue_count: 8, max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024, - ump_service_total_weight: Weight::from(4 * 1_000_000_000u32), + ump_service_total_weight: Weight::from_ref_time(4_u64 * 1_000_000_000_u64), max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, diff --git a/runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs b/runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs index a2d744b5a..cda575235 100644 --- a/runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs +++ b/runtime/battery-station/src/integration_tests/xcm/tests/currency_id_convert.rs @@ -1,5 +1,5 @@ -// Copyright 2021 Centrifuge Foundation (centrifuge.io). // Copyright 2022 Forecasting Technologies LTD. +// Copyright 2021 Centrifuge Foundation (centrifuge.io). // // This file is part of Zeitgeist. // diff --git a/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs b/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs index ffa956c08..65514f572 100644 --- a/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs +++ b/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs @@ -1,5 +1,5 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021 Centrifuge Foundation (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -19,18 +19,14 @@ use crate::{ integration_tests::xcm::{ setup::{ - ksm, register_foreign_parent, register_foreign_ztg, sibling_parachain_account, + register_foreign_parent, register_foreign_ztg, roc, sibling_parachain_account, zeitgeist_parachain_account, ztg, ALICE, BOB, FOREIGN_PARENT_ID, FOREIGN_ZTG_ID, PARA_ID_SIBLING, }, - test_net::{KusamaNet, Sibling, TestNet, Zeitgeist}, + test_net::{RococoNet, Sibling, TestNet, Zeitgeist}, }, - xcm_config::{ - asset_registry::{CustomMetadata, XcmMetadata}, - config::battery_station, - fees::default_per_second, - }, - AssetRegistry, Balance, Balances, CurrencyId, Origin, Tokens, XTokens, + xcm_config::{config::battery_station, fees::default_per_second}, + AssetRegistry, Balance, Balances, CurrencyId, RuntimeOrigin, Tokens, XTokens, ZeitgeistTreasuryAccount, }; @@ -38,7 +34,10 @@ use frame_support::assert_ok; use orml_traits::MultiCurrency; use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, NetworkId}; use xcm_emulator::TestExt; -use zeitgeist_primitives::constants::BalanceFractionalDecimals; +use zeitgeist_primitives::{ + constants::BalanceFractionalDecimals, + types::{CustomMetadata, XcmMetadata}, +}; #[test] fn transfer_ztg_to_sibling() { @@ -51,15 +50,15 @@ fn transfer_ztg_to_sibling() { Sibling::execute_with(|| { treasury_initial_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), 0); register_foreign_ztg(None); }); Zeitgeist::execute_with(|| { - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); - assert_eq!(Balances::free_balance(&sibling_parachain_account()), 0); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); + assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), CurrencyId::Ztg, transfer_amount, Box::new( @@ -67,23 +66,23 @@ fn transfer_ztg_to_sibling() { 1, X2( Parachain(PARA_ID_SIBLING), - Junction::AccountId32 { network: NetworkId::Any, id: BOB } + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Alice's balance is initial_balance - amount_transferred - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance - transfer_amount); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance - transfer_amount); // Verify that the amount transferred is now part of the sibling account here - assert_eq!(Balances::free_balance(&sibling_parachain_account()), transfer_amount); + assert_eq!(Balances::free_balance(sibling_parachain_account()), transfer_amount); }); Sibling::execute_with(|| { - let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()); + let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB); // Verify that BOB now has (amount transferred - fee) assert_eq!(current_balance, transfer_amount - ztg_fee()); @@ -118,18 +117,18 @@ fn transfer_ztg_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { treasury_initial_balance = Balances::free_balance(ZeitgeistTreasuryAccount::get()); - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); assert_eq!( - Balances::free_balance(&sibling_parachain_account()), + Balances::free_balance(sibling_parachain_account()), sibling_sovereign_initial_balance ); }); Sibling::execute_with(|| { - assert_eq!(Balances::free_balance(&zeitgeist_parachain_account()), 0); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), bob_initial_balance); + assert_eq!(Balances::free_balance(zeitgeist_parachain_account()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), bob_initial_balance); assert_ok!(XTokens::transfer( - Origin::signed(BOB.into()), + RuntimeOrigin::signed(BOB), FOREIGN_ZTG_ID, transfer_amount, Box::new( @@ -137,17 +136,17 @@ fn transfer_ztg_sibling_to_zeitgeist() { 1, X2( Parachain(battery_station::ID), - Junction::AccountId32 { network: NetworkId::Any, id: ALICE } + Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Bobs's balance is initial balance - amount transferred assert_eq!( - Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), + Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), bob_initial_balance - transfer_amount ); }); @@ -155,13 +154,13 @@ fn transfer_ztg_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { // Verify that ALICE now has initial balance + amount transferred - fee assert_eq!( - Balances::free_balance(&ALICE.into()), + Balances::free_balance(&ALICE), alice_initial_balance + transfer_amount - ztg_fee(), ); // Verify that the reserve has been adjusted properly assert_eq!( - Balances::free_balance(&sibling_parachain_account()), + Balances::free_balance(sibling_parachain_account()), sibling_sovereign_initial_balance - transfer_amount ); @@ -174,69 +173,68 @@ fn transfer_ztg_sibling_to_zeitgeist() { } #[test] -fn transfer_ksm_from_relay_chain() { +fn transfer_roc_from_relay_chain() { TestNet::reset(); - let transfer_amount: Balance = ksm(1); + let transfer_amount: Balance = roc(1); Zeitgeist::execute_with(|| { register_foreign_parent(None); }); - KusamaNet::execute_with(|| { - let initial_balance = kusama_runtime::Balances::free_balance(&ALICE.into()); + RococoNet::execute_with(|| { + let initial_balance = rococo_runtime::Balances::free_balance(&ALICE); assert!(initial_balance >= transfer_amount); - assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets( - kusama_runtime::Origin::signed(ALICE.into()), + assert_ok!(rococo_runtime::XcmPallet::reserve_transfer_assets( + rococo_runtime::RuntimeOrigin::signed(ALICE), Box::new(Parachain(battery_station::ID).into().into()), - Box::new(Junction::AccountId32 { network: NetworkId::Any, id: BOB }.into().into()), + Box::new( + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into().into() + ), Box::new((Here, transfer_amount).into()), 0 )); }); Zeitgeist::execute_with(|| { - assert_eq!( - Tokens::free_balance(FOREIGN_PARENT_ID, &BOB.into()), - transfer_amount - ksm_fee() - ); + assert_eq!(Tokens::free_balance(FOREIGN_PARENT_ID, &BOB), transfer_amount - roc_fee()); }); } #[test] -fn transfer_ksm_to_relay_chain() { +fn transfer_roc_to_relay_chain() { TestNet::reset(); - let transfer_amount: Balance = ksm(1); - transfer_ksm_from_relay_chain(); + let transfer_amount: Balance = roc(1); + transfer_roc_from_relay_chain(); Zeitgeist::execute_with(|| { - let initial_balance = Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE.into()); + let initial_balance = Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE); assert!(initial_balance >= transfer_amount); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), FOREIGN_PARENT_ID, transfer_amount, Box::new( MultiLocation::new( 1, - X1(Junction::AccountId32 { id: BOB, network: NetworkId::Any }) + X1(Junction::AccountId32 { id: BOB.into(), network: NetworkId::Any }) ) .into() ), - 4_000_000_000 + xcm_emulator::Limited(4_000_000_000) )); assert_eq!( - Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE.into()), + Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE), initial_balance - transfer_amount ) }); - KusamaNet::execute_with(|| { - assert_eq!(kusama_runtime::Balances::free_balance(&BOB.into()), 999_988_476_752); + RococoNet::execute_with(|| { + assert_eq!(rococo_runtime::Balances::free_balance(&BOB), 999_988_806_429); }); } @@ -253,7 +251,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { Sibling::execute_with(|| { treasury_initial_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), 0); register_foreign_ztg(None); let custom_metadata = CustomMetadata { @@ -272,10 +270,10 @@ fn transfer_ztg_to_sibling_with_custom_fee() { }); Zeitgeist::execute_with(|| { - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); - assert_eq!(Balances::free_balance(&sibling_parachain_account()), 0); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); + assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), CurrencyId::Ztg, transfer_amount, Box::new( @@ -283,23 +281,23 @@ fn transfer_ztg_to_sibling_with_custom_fee() { 1, X2( Parachain(PARA_ID_SIBLING), - Junction::AccountId32 { network: NetworkId::Any, id: BOB } + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Alice's balance is initial_balance - amount_transferred - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance - transfer_amount); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance - transfer_amount); // Verify that the amount transferred is now part of the sibling account here - assert_eq!(Balances::free_balance(&sibling_parachain_account()), transfer_amount); + assert_eq!(Balances::free_balance(sibling_parachain_account()), transfer_amount); }); Sibling::execute_with(|| { - let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()); + let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB); let custom_fee = calc_fee(default_per_second(10) * 10); // Verify that BOB now has (amount transferred - fee) @@ -319,7 +317,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { #[test] fn test_total_fee() { assert_eq!(ztg_fee(), 92_696_000); - assert_eq!(ksm_fee(), 9_269_600_000); + assert_eq!(roc_fee(), 9_269_600_000); } #[inline] @@ -332,9 +330,9 @@ fn fee(decimals: u32) -> Balance { calc_fee(default_per_second(decimals)) } -// The fee associated with transferring KSM tokens +// The fee associated with transferring roc tokens #[inline] -fn ksm_fee() -> Balance { +fn roc_fee() -> Balance { fee(12) } diff --git a/runtime/battery-station/src/lib.rs b/runtime/battery-station/src/lib.rs index b24f04a30..972a6f08e 100644 --- a/runtime/battery-station/src/lib.rs +++ b/runtime/battery-station/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -33,6 +34,8 @@ pub use frame_system::{ }; #[cfg(feature = "parachain")] pub use pallet_author_slot_filter::EligibilityValue; +pub use pallet_balances::Call as BalancesCall; +use pallet_collective::EnsureProportionMoreThan; #[cfg(feature = "parachain")] pub use crate::parachain_params::*; @@ -40,12 +43,15 @@ pub use crate::parameters::*; use alloc::vec; use frame_support::{ traits::{ConstU16, ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter}, - weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee}, + weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight}, }; use frame_system::EnsureRoot; use pallet_collective::{EnsureProportionAtLeast, PrimeDefaultVote}; use pallet_transaction_payment::ChargeTransactionPayment; -use sp_runtime::traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}; +use sp_runtime::{ + traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}, + DispatchError, +}; #[cfg(feature = "std")] use sp_version::NativeVersion; use substrate_fixed::{types::extra::U33, FixedI128, FixedU128}; @@ -54,10 +60,9 @@ use zrml_rikiddo::types::{EmaMarketVolume, FeeSigmoid, RikiddoSigmoidMV}; #[cfg(feature = "parachain")] use { frame_support::traits::{AsEnsureOriginWithArg, Everything, Nothing}, - frame_system::EnsureSigned, xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, LocationInverter}, xcm_config::{ - asset_registry::{CustomAssetProcessor, CustomMetadata}, + asset_registry::CustomAssetProcessor, config::{LocalOriginToLocation, XcmConfig, XcmOriginToTransactDispatchOrigin, XcmRouter}, }, }; @@ -74,10 +79,9 @@ use sp_runtime::{ }; #[cfg(feature = "parachain")] -use nimbus_primitives::{CanAuthor, NimbusId}; +use nimbus_primitives::CanAuthor; use sp_version::RuntimeVersion; -#[cfg(feature = "parachain")] #[cfg(test)] pub mod integration_tests; #[cfg(feature = "parachain")] @@ -90,10 +94,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("zeitgeist"), impl_name: create_runtime_str!("zeitgeist"), authoring_version: 1, - spec_version: 41, + spec_version: 46, impl_version: 1, apis: RUNTIME_API_VERSIONS, - transaction_version: 18, + transaction_version: 21, state_version: 1, }; @@ -101,8 +105,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { pub struct IsCallable; // Currently disables Court, Rikiddo and creation of markets using Court. -impl Contains for IsCallable { - fn contains(call: &Call) -> bool { +impl Contains for IsCallable { + fn contains(call: &RuntimeCall) -> bool { use zeitgeist_primitives::types::{ MarketDisputeMechanism::Court, ScoringRule::RikiddoSigmoidFeeMarketEma, }; @@ -112,9 +116,9 @@ impl Contains for IsCallable { #[allow(clippy::match_like_matches_macro)] match call { - Call::Court(_) => false, - Call::LiquidityMining(_) => false, - Call::PredictionMarkets(inner_call) => { + RuntimeCall::Court(_) => false, + RuntimeCall::LiquidityMining(_) => false, + RuntimeCall::PredictionMarkets(inner_call) => { match inner_call { // Disable Rikiddo markets create_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false, @@ -145,8 +149,8 @@ create_runtime_with_additional_pallets!( ); impl pallet_sudo::Config for Runtime { - type Call = Call; - type Event = Event; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; } impl_config_traits!(); diff --git a/runtime/battery-station/src/parachain_params.rs b/runtime/battery-station/src/parachain_params.rs index 1d5092151..c906fcfe7 100644 --- a/runtime/battery-station/src/parachain_params.rs +++ b/runtime/battery-station/src/parachain_params.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,11 +19,11 @@ #![allow( // Constants parameters inside `parameter_types!` already check // arithmetic operations at compile time - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "parachain")] -use super::{parameters::MAXIMUM_BLOCK_WEIGHT, Origin, ParachainInfo}; +use super::{parameters::MAXIMUM_BLOCK_WEIGHT, ParachainInfo, RuntimeOrigin}; use frame_support::{parameter_types, weights::Weight}; use orml_traits::parameter_type_with_key; use sp_runtime::{Perbill, Percent}; @@ -37,22 +38,14 @@ parameter_types! { /// The amount that should be taken as a security deposit when registering a NimbusId. pub const CollatorDeposit: Balance = 2 * BASE; - // Crowdloan - pub const InitializationPayment: Perbill = Perbill::from_percent(30); - pub const Initialized: bool = false; - pub const MaxInitContributorsBatchSizes: u32 = 500; - pub const MinimumReward: Balance = 0; - pub const RelaySignaturesThreshold: Perbill = Perbill::from_percent(100); - pub const SignatureNetworkIdentifier: &'static [u8] = b"zeitgeist-"; - // Cumulus and Polkadot pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: NetworkId = NetworkId::Any; - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; - pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UnitWeightCost: Weight = 200_000_000; + pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); + pub UnitWeightCost: u64 = 200_000_000; // Staking /// Rounds before the candidate bond increase/decrease can be executed @@ -90,7 +83,7 @@ parameter_types! { // XCM /// Base weight for XCM execution - pub const BaseXcmWeight: Weight = 200_000_000; + pub const BaseXcmWeight: u64 = 200_000_000; /// The maximum number of distinct assets allowed to be transferred in a /// single helper extrinsic. pub const MaxAssetsForTransfer: usize = 2; diff --git a/runtime/battery-station/src/parameters.rs b/runtime/battery-station/src/parameters.rs index 68bf1c76d..67b791636 100644 --- a/runtime/battery-station/src/parameters.rs +++ b/runtime/battery-station/src/parameters.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,15 +19,17 @@ #![allow( // Constants parameters inside `parameter_types!` already check // arithmetic operations at compile time - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] -use super::VERSION; +use super::{Runtime, VERSION}; use frame_support::{ + dispatch::DispatchClass, parameter_types, + traits::WithdrawReasons, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, - DispatchClass, Weight, + Weight, }, PalletId, }; @@ -34,7 +37,8 @@ use frame_system::limits::{BlockLength, BlockWeights}; use orml_traits::parameter_type_with_key; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ - traits::AccountIdConversion, FixedPointNumber, Perbill, Percent, Permill, Perquintill, + traits::{AccountIdConversion, Bounded}, + FixedPointNumber, Perbill, Percent, Permill, Perquintill, }; use sp_version::RuntimeVersion; use zeitgeist_primitives::{constants::*, types::*}; @@ -43,7 +47,9 @@ use zeitgeist_primitives::{constants::*, types::*}; use frame_support::traits::LockIdentifier; pub(crate) const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); -pub(crate) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; +pub(crate) const MAXIMUM_BLOCK_WEIGHT: Weight = + Weight::from_ref_time(WEIGHT_PER_SECOND.ref_time() / 2) + .set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64); pub(crate) const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); pub(crate) const FEES_AND_TIPS_TREASURY_PERCENTAGE: u32 = 100; pub(crate) const FEES_AND_TIPS_BURN_PERCENTAGE: u32 = 0; @@ -51,6 +57,7 @@ pub(crate) const FEES_AND_TIPS_BURN_PERCENTAGE: u32 = 0; parameter_types! { // Authorized pub const AuthorizedPalletId: PalletId = AUTHORIZED_PALLET_ID; + pub const CorrectionPeriod: BlockNumber = BLOCKS_PER_DAY; // Authority pub const MaxAuthorities: u32 = 32; @@ -73,6 +80,20 @@ parameter_types! { pub const TechnicalCommitteeMaxProposals: u32 = 64; pub const TechnicalCommitteeMotionDuration: BlockNumber = 7 * BLOCKS_PER_DAY; + // Contracts + pub const ContractsDeletionQueueDepth: u32 = 128; + pub ContractsDeletionWeightLimit: Weight = Perbill::from_percent(10) + * RuntimeBlockWeights::get() + .per_class + .get(DispatchClass::Normal) + .max_total + .unwrap_or(RuntimeBlockWeights::get().max_block); + pub const ContractsDepositPerByte: Balance = deposit(0,1); + pub const ContractsDepositPerItem: Balance = deposit(1,0); + pub const ContractsMaxCodeLen: u32 = 246 * 1024; + pub const ContractsMaxStorageKeyLen: u32 = 128; + pub ContractsSchedule: pallet_contracts::Schedule = Default::default(); + // Court /// Duration of a single court case. pub const CourtCaseDuration: u64 = BLOCKS_PER_DAY; @@ -112,9 +133,9 @@ parameter_types! { // Identity /// The amount held on deposit for a registered identity - pub const BasicDeposit: Balance = 8 * BASE; + pub const BasicDeposit: Balance = deposit(1, 258); /// The amount held on deposit per additional field for a registered identity. - pub const FieldDeposit: Balance = 256 * CENT; + pub const FieldDeposit: Balance = deposit(0, 66); /// Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O /// required to access an identity, but can be pretty high. pub const MaxAdditionalFields: u32 = 64; @@ -126,7 +147,7 @@ parameter_types! { /// The amount held on deposit for a registered subaccount. This should account for the fact /// that one storage item's value will increase by the size of an account ID, and there will /// be another trie item whose value is the size of an account ID plus 32 bytes. - pub const SubAccountDeposit: Balance = 2 * BASE; + pub const SubAccountDeposit: Balance = deposit(1, 53); // Liquidity Mining parameters /// Pallet identifier, mainly used for named balance reserves. @@ -140,12 +161,12 @@ parameter_types! { // ORML pub const GetNativeCurrencyId: CurrencyId = Asset::Ztg; - pub DustAccount: AccountId = PalletId(*b"orml/dst").into_account_truncating(); // Prediction Market parameters /// (Slashable) Bond that is provided for creating an advised market that needs approval. /// Slashed in case the market is rejected. pub const AdvisoryBond: Balance = 25 * CENT; + /// The percentage of the advisory bond that gets slashed when a market is rejected. pub const AdvisoryBondSlashPercentage: Percent = Percent::from_percent(0); /// (Slashable) Bond that is provided for disputing the outcome. /// Slashed in case the final outcome does not match the dispute for which the `DisputeBond` @@ -155,43 +176,46 @@ parameter_types! { pub const DisputeFactor: Balance = 2 * BASE; /// Maximum Categories a prediciton market can have (excluding base asset). pub const MaxCategories: u16 = MAX_CATEGORIES; + /// Maximum block period for a dispute. + pub const MaxDisputeDuration: BlockNumber = MAX_DISPUTE_DURATION; /// Maximum number of disputes. pub const MaxDisputes: u16 = 6; - /// Minimum number of categories. The trivial minimum is 2, which represents a binary market. - pub const MinCategories: u16 = 2; - // 60_000 = 1 minute. Should be raised to something more reasonable in the future. - /// Minimum number of milliseconds a Rikiddo market must be in subsidy gathering phase. - pub const MinSubsidyPeriod: Moment = 60_000; + /// Maximum string length for edit reason. + pub const MaxEditReasonLen: u32 = 1024; + /// Maximum block period for a grace_period. + /// The grace_period is a delay between the point where the market closes and the point where the oracle may report. + pub const MaxGracePeriod: BlockNumber = MAX_GRACE_PERIOD; + /// The maximum allowed duration of a market from creation to market close in blocks. + pub const MaxMarketLifetime: BlockNumber = MAX_MARKET_LIFETIME; + /// Maximum block period for a oracle_duration. + /// The oracle_duration is a duration where the oracle has to submit its report. + pub const MaxOracleDuration: BlockNumber = MAX_ORACLE_DURATION; + /// Maximum string length allowed for reject reason. + pub const MaxRejectReasonLen: u32 = 1024; // 2_678_400_000 = 31 days. /// Maximum number of milliseconds a Rikiddo market can be in subsidy gathering phase. pub const MaxSubsidyPeriod: Moment = 2_678_400_000; + /// Minimum number of categories. The trivial minimum is 2, which represents a binary market. + pub const MinCategories: u16 = 2; /// The dispute_duration is time where users can dispute the outcome. /// Minimum block period for a dispute. pub const MinDisputeDuration: BlockNumber = MIN_DISPUTE_DURATION; - /// Maximum block period for a dispute. - pub const MaxDisputeDuration: BlockNumber = MAX_DISPUTE_DURATION; - /// Maximum block period for a grace_period. - /// The grace_period is a delay between the point where the market closes and the point where the oracle may report. - pub const MaxGracePeriod: BlockNumber = MAX_GRACE_PERIOD; /// Minimum block period for a oracle_duration. pub const MinOracleDuration: BlockNumber = MIN_ORACLE_DURATION; - /// Maximum block period for a oracle_duration. - /// The oracle_duration is a duration where the oracle has to submit its report. - pub const MaxOracleDuration: BlockNumber = MAX_ORACLE_DURATION; - /// The maximum market period. - pub const MaxMarketPeriod: Moment = u64::MAX / 2; + // 60_000 = 1 minute. Should be raised to something more reasonable in the future. + /// Minimum number of milliseconds a Rikiddo market must be in subsidy gathering phase. + pub const MinSubsidyPeriod: Moment = 60_000; /// (Slashable) The orcale bond. Slashed in case the final outcome does not match the /// outcome the oracle reported. pub const OracleBond: Balance = 50 * CENT; + /// (Slashable) A bond for an outcome reporter, who is not the oracle. + /// Slashed in case the final outcome does not match the outcome by the outsider. + pub const OutsiderBond: Balance = 2 * OracleBond::get(); /// Pallet identifier, mainly used for named balance reserves. pub const PmPalletId: PalletId = PM_PALLET_ID; /// (Slashable) A bond for creation markets that do not require approval. Slashed in case /// the market is forcefully destroyed. pub const ValidityBond: Balance = 50 * CENT; - /// Maximum string length for edit reason. - pub const MaxEditReasonLen: u32 = 1024; - /// Maximum string length allowed for reject reason. - pub const MaxRejectReasonLen: u32 = 1024; // Preimage pub const PreimageMaxSize: u32 = 4096 * 1024; @@ -235,10 +259,8 @@ parameter_types! { pub const MaxTotalWeight: Balance = MaxWeight::get() * 2; /// The maximum weight a single asset can have. pub const MaxWeight: Balance = 64 * BASE; - /// Minimum amount of liquidity required to launch a CPMM pool. - pub const MinLiquidity: Balance = 100 * BASE; /// Minimum subsidy required to launch a Rikiddo pool. - pub const MinSubsidy: Balance = MinLiquidity::get(); + pub const MinSubsidy: Balance = 100 * BASE; /// Minimum subsidy a single account can provide. pub const MinSubsidyPerAccount: Balance = MinSubsidy::get(); /// Minimum weight a single asset can have. @@ -271,9 +293,6 @@ parameter_types! { .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - // Timestamp - pub const MinimumPeriod: u64 = MILLISECS_PER_BLOCK as u64 / 2; - // Transaction payment /// A fee mulitplier for Operational extrinsics to compute “virtual tip” /// to boost their priority. @@ -290,6 +309,8 @@ parameter_types! { /// Minimum amount of the multiplier. The test `multiplier_can_grow_from_zero` ensures /// that this value is not too low. pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); + /// Maximum amount of the multiplier. + pub MaximumMultiplier: Multiplier = Bounded::max_value(); // Treasury /// Percentage of spare funds (if any) that are burnt per spend period. @@ -310,6 +331,10 @@ parameter_types! { /// Treasury account. pub ZeitgeistTreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating(); + // Timestamp + /// MinimumPeriod for Timestamp + pub const MinimumPeriodValue: u64 = MILLISECS_PER_BLOCK as u64 / 2; + // Bounties /// The amount held on deposit for placing a bounty proposal. pub const BountyDepositBase: Balance = 100 * BASE; @@ -341,6 +366,8 @@ parameter_types! { // Vesting pub const MinVestedTransfer: Balance = ExistentialDeposit::get(); + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } #[cfg(feature = "with-global-disputes")] @@ -365,16 +392,43 @@ parameter_types! { } parameter_type_with_key! { - // Well, not every asset is a currency ¯\_(ツ)_/¯ + // Existential deposits used by orml-tokens. + // Only native ZTG and foreign assets should have an existential deposit. + // Winning outcome tokens are redeemed completely by the user, losing outcome tokens + // are cleaned up automatically. In case of scalar outcomes, the market account can have dust. + // Unless LPs use `pool_exit_with_exact_asset_amount`, there can be some dust pool shares remaining. + // Explicit match arms are used to ensure new asset types are respected. pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { + Asset::CategoricalOutcome(_,_) => ExistentialDeposit::get(), + Asset::CombinatorialOutcome => ExistentialDeposit::get(), + Asset::PoolShare(_) => ExistentialDeposit::get(), + Asset::ScalarOutcome(_,_) => ExistentialDeposit::get(), + #[cfg(feature = "parachain")] + Asset::ForeignAsset(id) => { + let maybe_metadata = < + orml_asset_registry::Pallet as orml_traits::asset_registry::Inspect + >::metadata(&Asset::ForeignAsset(*id)); + + if let Some(metadata) = maybe_metadata { + return metadata.existential_deposit; + } + + 1 + } + #[cfg(not(feature = "parachain"))] + Asset::ForeignAsset(_) => ExistentialDeposit::get(), Asset::Ztg => ExistentialDeposit::get(), - _ => 0 } }; } // Parameterized slow adjusting fee updated based on // https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; +pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment< + R, + TargetBlockFullness, + AdjustmentVariable, + MinimumMultiplier, + MaximumMultiplier, +>; diff --git a/runtime/battery-station/src/xcm_config/asset_registry.rs b/runtime/battery-station/src/xcm_config/asset_registry.rs index ba7807a8c..1b2f16f11 100644 --- a/runtime/battery-station/src/xcm_config/asset_registry.rs +++ b/runtime/battery-station/src/xcm_config/asset_registry.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -20,6 +20,7 @@ use orml_traits::asset_registry::{AssetMetadata, AssetProcessor}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::DispatchError; +use zeitgeist_primitives::types::CustomMetadata; #[derive( Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, @@ -46,49 +47,3 @@ impl AssetProcessor> for Cust Ok(()) } } - -#[derive( - Clone, - Copy, - Default, - PartialOrd, - Ord, - PartialEq, - Eq, - Debug, - Encode, - Decode, - TypeInfo, - MaxEncodedLen, -)] -/// Custom XC asset metadata -pub struct CustomMetadata { - /// XCM-related metadata. - pub xcm: XcmMetadata, - - /// Whether an asset can be used in pools. - pub allow_in_pool: bool, -} - -#[derive( - Clone, - Copy, - Default, - PartialOrd, - Ord, - PartialEq, - Eq, - Debug, - Encode, - Decode, - TypeInfo, - MaxEncodedLen, -)] -pub struct XcmMetadata { - /// The factor used to determine the fee. - /// It is multiplied by the fee that would have been paid in native currency, so it represents - /// the ratio `native_price / other_asset_price`. It is a fixed point decimal number containing - /// as many fractional decimals as the asset it is used for contains. - /// Should be updated regularly. - pub fee_factor: Option, -} diff --git a/runtime/battery-station/src/xcm_config/config.rs b/runtime/battery-station/src/xcm_config/config.rs index 4e09b741c..003801fda 100644 --- a/runtime/battery-station/src/xcm_config/config.rs +++ b/runtime/battery-station/src/xcm_config/config.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -17,9 +17,9 @@ use super::fees::{native_per_second, FixedConversionRateProvider}; use crate::{ - AccountId, Ancestry, AssetManager, AssetRegistry, Balance, Call, CurrencyId, MaxInstructions, - Origin, ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, - UnitWeightCost, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, + AccountId, Ancestry, AssetManager, AssetRegistry, Balance, CurrencyId, MaxInstructions, + ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, RuntimeCall, + RuntimeOrigin, UnitWeightCost, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, }; use frame_support::{parameter_types, traits::Everything, WeakBoundedVec}; @@ -50,7 +50,7 @@ use zeitgeist_primitives::types::Asset; pub mod battery_station { #[cfg(test)] - pub const ID: u32 = 2050; + pub const ID: u32 = 2101; pub const KEY: &[u8] = &[0, 1]; } @@ -70,7 +70,7 @@ impl Config for XcmConfig { /// Additional filters that specify whether the XCM instruction should be executed at all. type Barrier = Barrier; /// The outer call dispatch type. - type Call = Call; + type RuntimeCall = RuntimeCall; /// Combinations of (Location, Asset) pairs which are trusted as reserves. // Trust the parent chain, sibling parachains and children chains of this chain. type IsReserve = MultiNativeAsset; @@ -89,7 +89,7 @@ impl Config for XcmConfig { /// The means of determining an XCM message's weight. // Adds UnitWeightCost per instruction plus the weight of each instruction. // The total number of instructions are bounded by MaxInstructions - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; /// How to send an onward XCM message. type XcmSender = XcmRouter; } @@ -261,7 +261,7 @@ impl Convert for AccountIdToMultiLocation { } /// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM @@ -282,18 +282,18 @@ pub type XcmOriginToTransactDispatchOrigin = ( // Sovereign account converter; this attempts to derive an `AccountId` from the origin location // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, + SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognized. - RelayChainAsNative, + RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // recognized. - SiblingParachainAsNative, + SiblingParachainAsNative, // Native signed account converter; this just converts an `AccountId32` origin into a normal // `Origin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, + SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, + XcmPassthrough, ); /// The means for routing XCM messages which are not for local execution into the right message diff --git a/runtime/battery-station/src/xcm_config/fees.rs b/runtime/battery-station/src/xcm_config/fees.rs index b70484d97..53a036e53 100644 --- a/runtime/battery-station/src/xcm_config/fees.rs +++ b/runtime/battery-station/src/xcm_config/fees.rs @@ -1,4 +1,5 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. +// Copyright 2021 Centrifuge Foundation (centrifuge.io). // // This file is part of Zeitgeist. // @@ -15,11 +16,11 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{xcm_config::asset_registry::CustomMetadata, Balance, CurrencyId}; +use crate::{Balance, CurrencyId}; use core::marker::PhantomData; use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_PER_SECOND}; use xcm::latest::MultiLocation; -use zeitgeist_primitives::constants::BalanceFractionalDecimals; +use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::CustomMetadata}; use zrml_swaps::check_arithm_rslt::CheckArithmRslt; /// The fee cost per second for transferring the native token in cents. @@ -28,8 +29,8 @@ pub fn native_per_second() -> Balance { } pub fn default_per_second(decimals: u32) -> Balance { - let base_weight = Balance::from(ExtrinsicBaseWeight::get()); - let default_per_second = (WEIGHT_PER_SECOND as u128) / base_weight; + let base_weight = ExtrinsicBaseWeight::get().ref_time() as u128; + let default_per_second = (WEIGHT_PER_SECOND.ref_time() as u128) / base_weight; default_per_second * base_fee(decimals) } @@ -59,10 +60,10 @@ pub struct FixedConversionRateProvider(PhantomData impl< AssetRegistry: orml_traits::asset_registry::Inspect< - AssetId = CurrencyId, - Balance = Balance, - CustomMetadata = CustomMetadata, - >, + AssetId = CurrencyId, + Balance = Balance, + CustomMetadata = CustomMetadata, + >, > orml_traits::FixedConversionRateProvider for FixedConversionRateProvider { fn get_fee_per_second(location: &MultiLocation) -> Option { diff --git a/runtime/battery-station/src/xcm_config/mod.rs b/runtime/battery-station/src/xcm_config/mod.rs index 363ac87b1..448000ebe 100644 --- a/runtime/battery-station/src/xcm_config/mod.rs +++ b/runtime/battery-station/src/xcm_config/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index d83c20cb1..c4cf9f3ca 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -1,31 +1,33 @@ [dependencies] # Pallets -cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-currencies = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -pallet-author-inherent = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-mapping = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -pallet-author-slot-filter = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-balances = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-bounties = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-collective = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-democracy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-identity = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-membership = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-multisig = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-parachain-staking = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -pallet-preimage = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-proxy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-randomness-collective-flip = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-scheduler = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-treasury = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-utility = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-vesting = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-currencies = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +pallet-author-inherent = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-mapping = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-slot-filter = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-balances = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-bounties = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-collective = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts-primitives = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-democracy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-identity = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-membership = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-multisig = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-parachain-staking = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-preimage = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-proxy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-randomness-collective-flip = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-scheduler = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-treasury = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-utility = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-vesting = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } # Utility cfg-if = { version = "1.0.0" } @@ -51,6 +53,8 @@ std = [ "pallet-balances/std", "pallet-bounties/std", "pallet-collective/std", + "pallet-contracts/std", + "pallet-contracts-primitives/std", "pallet-democracy/std", "pallet-identity/std", "pallet-membership/std", @@ -73,7 +77,7 @@ with-global-disputes = [] authors = ["Zeitgeist PM "] edition = "2021" name = "common-runtime" -version = "0.3.7" +version = "0.3.9" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 09466e035..051cdba12 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // Copyright 2019-2020 Parity Technologies (UK) Ltd. // @@ -45,30 +46,26 @@ pub mod weights; macro_rules! decl_common_types { {} => { use sp_runtime::generic; - use frame_support::traits::{Currency, Imbalance, OnUnbalanced, NeverEnsureOrigin}; + use frame_support::traits::{Currency, Imbalance, OnRuntimeUpgrade, OnUnbalanced, NeverEnsureOrigin, TryStateSelect}; pub type Block = generic::Block; type Address = sp_runtime::MultiAddress; - #[cfg(feature = "parachain")] - pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, - zrml_prediction_markets::migrations::RecordBonds, - >; + // Migration for scheduler pallet to move from a plain RuntimeCall to a CallOrHash. + pub struct SchedulerMigrationV1toV4; + impl OnRuntimeUpgrade for SchedulerMigrationV1toV4 { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + Scheduler::migrate_v1_to_v4() + } + } - #[cfg(not(feature = "parachain"))] pub type Executive = frame_executive::Executive< Runtime, Block, frame_system::ChainContext, Runtime, AllPalletsWithSystem, - zrml_prediction_markets::migrations::RecordBonds, >; pub type Header = generic::Header; @@ -84,8 +81,8 @@ macro_rules! decl_common_types { CheckWeight, ChargeTransactionPayment, ); - pub type SignedPayload = generic::SignedPayload; - pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + pub type SignedPayload = generic::SignedPayload; + pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; // Governance type AdvisoryCommitteeInstance = pallet_collective::Instance1; @@ -132,14 +129,25 @@ macro_rules! decl_common_types { EnsureProportionAtLeast, >; - // Advisory committee vote proportions - // At least 50% - type EnsureRootOrHalfAdvisoryCommittee = EitherOfDiverse< + // Advisory Committee vote proportions + // More than 33% + type EnsureRootOrMoreThanOneThirdAdvisoryCommittee = EitherOfDiverse< EnsureRoot, - EnsureProportionAtLeast, + EnsureProportionMoreThan, + >; + + // More than 50% + type EnsureRootOrMoreThanHalfAdvisoryCommittee = EitherOfDiverse< + EnsureRoot, + EnsureProportionMoreThan, + >; + + // More than 66% + type EnsureRootOrMoreThanTwoThirdsAdvisoryCommittee = EitherOfDiverse< + EnsureRoot, + EnsureProportionMoreThan, >; - // Technical committee vote proportions // At least 66% type EnsureRootOrTwoThirdsAdvisoryCommittee = EitherOfDiverse< EnsureRoot, @@ -272,7 +280,7 @@ macro_rules! create_runtime { TransactionPayment: pallet_transaction_payment::{Config, Event, Pallet, Storage} = 11, Treasury: pallet_treasury::{Call, Config, Event, Pallet, Storage} = 12, Vesting: pallet_vesting::{Call, Config, Event, Pallet, Storage} = 13, - MultiSig: pallet_multisig::{Call, Event, Pallet, Storage} = 14, + Multisig: pallet_multisig::{Call, Event, Pallet, Storage} = 14, Bounties: pallet_bounties::{Call, Event, Pallet, Storage} = 15, // Governance @@ -288,6 +296,7 @@ macro_rules! create_runtime { Identity: pallet_identity::{Call, Event, Pallet, Storage} = 30, Utility: pallet_utility::{Call, Event, Pallet, Storage} = 31, Proxy: pallet_proxy::{Call, Event, Pallet, Storage} = 32, + Contracts: pallet_contracts = 33, // Third-party AssetManager: orml_currencies::{Call, Pallet, Storage} = 40, @@ -334,9 +343,6 @@ macro_rules! create_runtime_with_additional_pallets { UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 125, XTokens: orml_xtokens::{Pallet, Storage, Call, Event} = 126, - // Third-party - Crowdloan: pallet_crowdloan_rewards::{Call, Config, Event, Pallet, Storage} = 130, - // Others $($additional_pallets)* ); @@ -363,7 +369,7 @@ macro_rules! impl_config_traits { // Configure Pallets #[cfg(feature = "parachain")] impl cumulus_pallet_dmp_queue::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExecuteOverweightOrigin = EnsureRootOrHalfTechnicalCommittee; type XcmExecutor = xcm_executor::XcmExecutor; } @@ -372,7 +378,7 @@ macro_rules! impl_config_traits { impl cumulus_pallet_parachain_system::Config for Runtime { type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; type DmpMessageHandler = DmpQueue; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnSystemEvent = (); type OutboundXcmpMessageSource = XcmpQueue; type ReservedDmpWeight = crate::parachain_params::ReservedDmpWeight; @@ -383,7 +389,7 @@ macro_rules! impl_config_traits { #[cfg(feature = "parachain")] impl cumulus_pallet_xcm::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type XcmExecutor = xcm_executor::XcmExecutor; } @@ -392,7 +398,7 @@ macro_rules! impl_config_traits { type ChannelInfo = ParachainSystem; type ControllerOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExecuteOverweightOrigin = EnsureRootOrHalfTechnicalCommittee; type VersionWrapper = (); type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; @@ -407,9 +413,9 @@ macro_rules! impl_config_traits { type BlockLength = RuntimeBlockLength; type BlockNumber = BlockNumber; type BlockWeights = RuntimeBlockWeights; - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = RocksDbWeight; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = generic::Header; @@ -422,7 +428,7 @@ macro_rules! impl_config_traits { type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; #[cfg(not(feature = "parachain"))] type OnSetCode = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = SS58Prefix; type SystemWeightInfo = weights::frame_system::WeightInfo; @@ -448,14 +454,14 @@ macro_rules! impl_config_traits { impl pallet_author_mapping::Config for Runtime { type DepositAmount = CollatorDeposit; type DepositCurrency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Keys = session_keys_primitives::VrfId; type WeightInfo = weights::pallet_author_mapping::WeightInfo; } #[cfg(feature = "parachain")] impl pallet_author_slot_filter::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type RandomnessSource = RandomnessCollectiveFlip; type PotentialAuthors = ParachainStaking; type WeightInfo = weights::pallet_author_slot_filter::WeightInfo; @@ -463,8 +469,7 @@ macro_rules! impl_config_traits { #[cfg(not(feature = "parachain"))] impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; type KeyOwnerProofSystem = (); type KeyOwnerProof = ; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; + type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Nothing; // ^ Disable dispatchable execute on the XCM pallet. // Needs to be `Everything` for local testing. type XcmExecutor = xcm_executor::XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Nothing; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; // ^ Override for AdvertisedXcmVersion default @@ -510,11 +515,8 @@ macro_rules! impl_config_traits { type BlockAuthor = AuthorInherent; type CandidateBondLessDelay = CandidateBondLessDelay; type Currency = Balances; - type DefaultBlocksPerRound = DefaultBlocksPerRound; - type DefaultCollatorCommission = DefaultCollatorCommission; - type DefaultParachainBondReservePercent = DefaultParachainBondReservePercent; type DelegationBondLessDelay = DelegationBondLessDelay; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type LeaveCandidatesDelay = LeaveCandidatesDelay; type LeaveDelegatorsDelay = LeaveDelegatorsDelay; type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate; @@ -528,6 +530,7 @@ macro_rules! impl_config_traits { type MinSelectedCandidates = MinSelectedCandidates; type MonetaryGovernanceOrigin = EnsureRoot; type OnCollatorPayout = (); + type PayoutCollatorReward = (); type OnNewRound = (); type RevokeDelegationDelay = RevokeDelegationDelay; type RewardPaymentDelay = RewardPaymentDelay; @@ -541,7 +544,7 @@ macro_rules! impl_config_traits { type AuthorityOrigin = AsEnsureOriginWithArg; type Balance = Balance; type CustomMetadata = CustomMetadata; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } @@ -552,25 +555,35 @@ macro_rules! impl_config_traits { type WeightInfo = weights::orml_currencies::WeightInfo; } + pub struct CurrencyHooks(sp_std::marker::PhantomData); + impl orml_traits::currency::MutationHooks for CurrencyHooks { + type OnDust = orml_tokens::TransferDust; + type OnKilledTokenAccount = (); + type OnNewTokenAccount = (); + type OnSlash = (); + type PostDeposit = (); + type PostTransfer = (); + type PreDeposit = (); + type PreTransfer = (); + } + impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; + type CurrencyHooks = CurrencyHooks; type CurrencyId = CurrencyId; type DustRemovalWhitelist = DustRemovalWhitelist; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; - type OnDust = orml_tokens::TransferDust; - type OnKilledTokenAccount = (); - type OnNewTokenAccount = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = weights::orml_tokens::WeightInfo; } #[cfg(feature = "parachain")] impl orml_unknown_tokens::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; } #[cfg(feature = "parachain")] @@ -580,84 +593,85 @@ macro_rules! impl_config_traits { type BaseXcmWeight = BaseXcmWeight; type CurrencyId = CurrencyId; type CurrencyIdConvert = AssetConvert; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type LocationInverter = LocationInverter; type MaxAssetsForTransfer = MaxAssetsForTransfer; type MinXcmFee = ParachainMinFee; type MultiLocationsFilter = Everything; type ReserveProvider = orml_traits::location::AbsoluteReserveProvider; type SelfLocation = SelfLocation; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type XcmExecutor = xcm_executor::XcmExecutor; } - #[cfg(feature = "parachain")] - impl pallet_crowdloan_rewards::Config for Runtime { - type Event = Event; - type InitializationPayment = InitializationPayment; - type Initialized = Initialized; - type MaxInitContributors = MaxInitContributorsBatchSizes; - type MinimumReward = MinimumReward; - type RelayChainAccountId = AccountId; - type RewardCurrency = Balances; - type RewardAddressAssociateOrigin = EnsureSigned; - type RewardAddressChangeOrigin = frame_system::EnsureSigned; - type RewardAddressRelayVoteThreshold = RelaySignaturesThreshold; - type SignatureNetworkIdentifier = SignatureNetworkIdentifier; - type VestingBlockNumber = cumulus_primitives_core::relay_chain::BlockNumber; - type VestingBlockProvider = - cumulus_pallet_parachain_system::RelaychainBlockNumberProvider; - type WeightInfo = pallet_crowdloan_rewards::weights::SubstrateWeight; - } - impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; - type DustRemoval = (); - type Event = Event; + type DustRemoval = Treasury; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; - type WeightInfo = pallet_balances::weights::SubstrateWeight; // weights::pallet_balances::WeightInfo; + type WeightInfo = weights::pallet_balances::WeightInfo; } impl pallet_collective::Config for Runtime { type DefaultVote = PrimeDefaultVote; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = AdvisoryCommitteeMaxMembers; type MaxProposals = AdvisoryCommitteeMaxProposals; type MotionDuration = AdvisoryCommitteeMotionDuration; - type Origin = Origin; - type Proposal = Call; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; type WeightInfo = weights::pallet_collective::WeightInfo; } impl pallet_collective::Config for Runtime { type DefaultVote = PrimeDefaultVote; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = CouncilMaxMembers; type MaxProposals = CouncilMaxProposals; type MotionDuration = CouncilMotionDuration; - type Origin = Origin; - type Proposal = Call; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; type WeightInfo = weights::pallet_collective::WeightInfo; } impl pallet_collective::Config for Runtime { type DefaultVote = PrimeDefaultVote; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = TechnicalCommitteeMaxMembers; type MaxProposals = TechnicalCommitteeMaxProposals; type MotionDuration = TechnicalCommitteeMotionDuration; - type Origin = Origin; - type Proposal = Call; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; type WeightInfo = weights::pallet_collective::WeightInfo; } + impl pallet_contracts::Config for Runtime { + type AddressGenerator = pallet_contracts::DefaultAddressGenerator; + type CallFilter = frame_support::traits::Nothing; + type CallStack = [pallet_contracts::Frame::; 5]; + type ChainExtension = (); + type Currency = Balances; + type DeletionQueueDepth = ContractsDeletionQueueDepth; + type DeletionWeightLimit = ContractsDeletionWeightLimit; + type DepositPerItem = ContractsDepositPerItem; + type DepositPerByte = ContractsDepositPerByte; + type MaxCodeLen = ContractsMaxCodeLen; + type MaxStorageKeyLen = ContractsMaxStorageKeyLen; + type Randomness = RandomnessCollectiveFlip; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Schedule = ContractsSchedule; + type Time = Timestamp; + type WeightPrice = pallet_transaction_payment::Pallet; + type WeightInfo = weights::pallet_contracts::WeightInfo; + } + impl pallet_democracy::Config for Runtime { - type Proposal = Call; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; @@ -688,20 +702,21 @@ macro_rules! impl_config_traits { /// Origin for anyone able to veto proposals. type VetoOrigin = pallet_collective::EnsureMember; type CooloffPeriod = CooloffPeriod; - type PreimageByteDeposit = PreimageByteDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; type Slash = Treasury; type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; type MaxVotes = MaxVotes; type WeightInfo = weights::pallet_democracy::WeightInfo; type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxBlacklisted = ConstU32<100>; + type MaxDeposits = ConstU32<100>; } impl pallet_identity::Config for Runtime { type BasicDeposit = BasicDeposit; type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type FieldDeposit = FieldDeposit; type ForceOrigin = EnsureRootOrTwoThirdsAdvisoryCommittee; type MaxAdditionalFields = MaxAdditionalFields; @@ -715,7 +730,7 @@ macro_rules! impl_config_traits { impl pallet_membership::Config for Runtime { type AddOrigin = EnsureRootOrTwoThirdsCouncil; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = AdvisoryCommitteeMaxMembers; type MembershipChanged = AdvisoryCommittee; type MembershipInitialized = AdvisoryCommittee; @@ -728,7 +743,7 @@ macro_rules! impl_config_traits { impl pallet_membership::Config for Runtime { type AddOrigin = EnsureRootOrThreeFourthsCouncil; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = CouncilMaxMembers; type MembershipChanged = Council; type MembershipInitialized = Council; @@ -741,7 +756,7 @@ macro_rules! impl_config_traits { impl pallet_membership::Config for Runtime { type AddOrigin = EnsureRootOrTwoThirdsCouncil; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxMembers = TechnicalCommitteeMaxMembers; type MembershipChanged = TechnicalCommittee; type MembershipInitialized = TechnicalCommittee; @@ -753,8 +768,8 @@ macro_rules! impl_config_traits { } impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -764,31 +779,30 @@ macro_rules! impl_config_traits { impl pallet_preimage::Config for Runtime { type WeightInfo = weights::pallet_preimage::WeightInfo; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } - impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { + impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::CancelProxy => { - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) } ProxyType::Governance => matches!( c, - Call::Democracy(..) - | Call::Council(..) - | Call::TechnicalCommittee(..) - | Call::AdvisoryCommittee(..) - | Call::Treasury(..) + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::AdvisoryCommittee(..) + | RuntimeCall::Treasury(..) ), #[cfg(feature = "parachain")] - ProxyType::Staking => matches!(c, Call::ParachainStaking(..)), + ProxyType::Staking => matches!(c, RuntimeCall::ParachainStaking(..)), #[cfg(not(feature = "parachain"))] ProxyType::Staking => false, } @@ -805,8 +819,8 @@ macro_rules! impl_config_traits { } impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -822,17 +836,48 @@ macro_rules! impl_config_traits { impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; - type Call = Call; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; type OriginPrivilegeCmp = EqualPrivilegeOnly; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Preimages = Preimage; + } + + // Timestamp + /// Custom getter for minimum timestamp delta. + /// This ensures that consensus systems like Aura don't break assertions + /// in a benchmark environment + pub struct MinimumPeriod; + impl MinimumPeriod { + /// Returns the value of this parameter type. + pub fn get() -> u64 { + #[cfg(feature = "runtime-benchmarks")] + { + use frame_benchmarking::benchmarking::get_whitelist; + // Should that condition be true, we can assume that we are in a benchmark environment. + if !get_whitelist().is_empty() { + return u64::MAX; + } + } + + MinimumPeriodValue::get() + } + } + impl> frame_support::traits::Get for MinimumPeriod { + fn get() -> I { + I::from(Self::get()) + } + } + impl frame_support::traits::TypedGet for MinimumPeriod { + type Type = u64; + fn get() -> u64 { + Self::get() + } } impl pallet_timestamp::Config for Runtime { @@ -846,7 +891,7 @@ macro_rules! impl_config_traits { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; type LengthToFee = ConstantMultiplier; type OnChargeTransaction = @@ -860,9 +905,9 @@ macro_rules! impl_config_traits { type Burn = Burn; type BurnDestination = (); type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxApprovals = MaxApprovals; - type OnSlash = (); + type OnSlash = Treasury; type PalletId = TreasuryPalletId; type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; @@ -884,24 +929,25 @@ macro_rules! impl_config_traits { type CuratorDepositMin = CuratorDepositMin; type CuratorDepositMultiplier = CuratorDepositMultiplier; type DataDepositPerByte = DataDepositPerByte; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaximumReasonLength = MaximumReasonLength; type WeightInfo = weights::pallet_bounties::WeightInfo; } impl pallet_utility::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = weights::pallet_utility::WeightInfo; } impl pallet_vesting::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = sp_runtime::traits::ConvertInto; type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = pallet_vesting::weights::SubstrateWeight; // weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + type WeightInfo = weights::pallet_vesting::WeightInfo; // `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. @@ -912,16 +958,19 @@ macro_rules! impl_config_traits { impl parachain_info::Config for Runtime {} impl zrml_authorized::Config for Runtime { - type Event = Event; + type AuthorizedDisputeResolutionOrigin = EnsureRootOrMoreThanHalfAdvisoryCommittee; + type CorrectionPeriod = CorrectionPeriod; + type DisputeResolution = zrml_prediction_markets::Pallet; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; - type AuthorizedDisputeResolutionOrigin = EnsureRootOrHalfAdvisoryCommittee; type PalletId = AuthorizedPalletId; type WeightInfo = zrml_authorized::weights::WeightInfo; } impl zrml_court::Config for Runtime { type CourtCaseDuration = CourtCaseDuration; - type Event = Event; + type DisputeResolution = zrml_prediction_markets::Pallet; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type PalletId = CourtPalletId; type Random = RandomnessCollectiveFlip; @@ -931,7 +980,7 @@ macro_rules! impl_config_traits { } impl zrml_liquidity_mining::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type MarketId = MarketId; type PalletId = LiquidityMiningPalletId; @@ -969,17 +1018,14 @@ macro_rules! impl_config_traits { impl zrml_prediction_markets::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; - type ApproveOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureMember - >; + type ApproveOrigin = EnsureRootOrMoreThanOneThirdAdvisoryCommittee; type Authorized = Authorized; type Court = Court; - type CloseOrigin = EnsureRootOrTwoThirdsAdvisoryCommittee; + type CloseOrigin = EnsureRoot; type DestroyOrigin = EnsureRootOrAllAdvisoryCommittee; type DisputeBond = DisputeBond; type DisputeFactor = DisputeFactor; - type Event = Event; + type RuntimeEvent = RuntimeEvent; #[cfg(feature = "with-global-disputes")] type GlobalDisputes = GlobalDisputes; #[cfg(feature = "with-global-disputes")] @@ -990,26 +1036,26 @@ macro_rules! impl_config_traits { // type LiquidityMining = LiquidityMining; type MaxCategories = MaxCategories; type MaxDisputes = MaxDisputes; + type MaxMarketLifetime = MaxMarketLifetime; type MinDisputeDuration = MinDisputeDuration; type MaxDisputeDuration = MaxDisputeDuration; type MaxGracePeriod = MaxGracePeriod; type MaxOracleDuration = MaxOracleDuration; type MinOracleDuration = MinOracleDuration; type MaxSubsidyPeriod = MaxSubsidyPeriod; - type MaxMarketPeriod = MaxMarketPeriod; type MinCategories = MinCategories; type MinSubsidyPeriod = MinSubsidyPeriod; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; type OracleBond = OracleBond; + type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; - type RejectOrigin = EnsureRootOrHalfAdvisoryCommittee; - type RequestEditOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureMember, - >; + type RejectOrigin = EnsureRootOrMoreThanTwoThirdsAdvisoryCommittee; + type RequestEditOrigin = EnsureRootOrMoreThanOneThirdAdvisoryCommittee; type ResolveOrigin = EnsureRoot; type AssetManager = AssetManager; + #[cfg(feature = "parachain")] + type AssetRegistry = AssetRegistry; type SimpleDisputes = SimpleDisputes; type Slash = Treasury; type Swaps = Swaps; @@ -1033,7 +1079,8 @@ macro_rules! impl_config_traits { } impl zrml_simple_disputes::Config for Runtime { - type Event = Event; + type DisputeResolution = zrml_prediction_markets::Pallet; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type PalletId = SimpleDisputesPalletId; } @@ -1041,7 +1088,7 @@ macro_rules! impl_config_traits { #[cfg(feature = "with-global-disputes")] impl zrml_global_disputes::Config for Runtime { type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type GlobalDisputeLockId = GlobalDisputeLockId; type GlobalDisputesPalletId = GlobalDisputesPalletId; type MarketCommons = MarketCommons; @@ -1054,7 +1101,7 @@ macro_rules! impl_config_traits { } impl zrml_swaps::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExitFee = ExitFee; type FixedTypeU = FixedU128; type FixedTypeS = FixedI128; @@ -1070,7 +1117,6 @@ macro_rules! impl_config_traits { type MaxSwapFee = MaxSwapFee; type MaxTotalWeight = MaxTotalWeight; type MaxWeight = MaxWeight; - type MinLiquidity = MinLiquidity; type MinSubsidy = MinSubsidy; type MinSubsidyPerAccount = MinSubsidyPerAccount; type MinWeight = MinWeight; @@ -1081,7 +1127,7 @@ macro_rules! impl_config_traits { } impl zrml_styx::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type SetBurnAmountOrigin = EnsureRootOrHalfCouncil; type Currency = Balances; type WeightInfo = zrml_styx::weights::WeightInfo; @@ -1093,6 +1139,10 @@ macro_rules! impl_config_traits { #[macro_export] macro_rules! create_runtime_api { ($($additional_apis:tt)*) => { + // Prints debug output of the `contracts` pallet to stdout if the node is + // started with `-lruntime::contracts=debug`. + const CONTRACTS_DEBUG_OUTPUT: bool = true; + impl_runtime_apis! { #[cfg(feature = "parachain")] impl cumulus_primitives_core::CollectCollationInfo for Runtime { @@ -1103,14 +1153,6 @@ macro_rules! create_runtime_api { } } - #[cfg(feature = "parachain")] - // Required to satisify trait bounds at the client implementation. - impl nimbus_primitives::AuthorFilterAPI for Runtime { - fn can_author(_: NimbusId, _: u32, _: &::Header) -> bool { - panic!("AuthorFilterAPI is no longer supported. Please update your client.") - } - } - #[cfg(feature = "parachain")] impl nimbus_primitives::NimbusApi for Runtime { fn can_author( @@ -1181,10 +1223,11 @@ macro_rules! create_runtime_api { list_benchmark!(list, extra, pallet_balances, Balances); list_benchmark!(list, extra, pallet_bounties, Bounties); list_benchmark!(list, extra, pallet_collective, AdvisoryCommittee); + list_benchmark!(list, extra, pallet_contracts, Contracts); list_benchmark!(list, extra, pallet_democracy, Democracy); list_benchmark!(list, extra, pallet_identity, Identity); list_benchmark!(list, extra, pallet_membership, AdvisoryCommitteeMembership); - list_benchmark!(list, extra, pallet_multisig, MultiSig); + list_benchmark!(list, extra, pallet_multisig, Multisig); list_benchmark!(list, extra, pallet_preimage, Preimage); list_benchmark!(list, extra, pallet_proxy, Proxy); list_benchmark!(list, extra, pallet_scheduler, Scheduler); @@ -1197,6 +1240,7 @@ macro_rules! create_runtime_api { list_benchmark!(list, extra, zrml_court, Court); #[cfg(feature = "with-global-disputes")] list_benchmark!(list, extra, zrml_global_disputes, GlobalDisputes); + #[cfg(not(feature = "parachain"))] list_benchmark!(list, extra, zrml_prediction_markets, PredictionMarkets); list_benchmark!(list, extra, zrml_liquidity_mining, LiquidityMining); list_benchmark!(list, extra, zrml_styx, Styx); @@ -1208,7 +1252,6 @@ macro_rules! create_runtime_api { list_benchmark!(list, extra, pallet_author_mapping, AuthorMapping); list_benchmark!(list, extra, pallet_author_slot_filter, AuthorFilter); list_benchmark!(list, extra, pallet_parachain_staking, ParachainStaking); - list_benchmark!(list, extra, pallet_crowdloan_rewards, Crowdloan); } else { list_benchmark!(list, extra, pallet_grandpa, Grandpa); } @@ -1259,10 +1302,11 @@ macro_rules! create_runtime_api { add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_bounties, Bounties); add_benchmark!(params, batches, pallet_collective, AdvisoryCommittee); + add_benchmark!(params, batches, pallet_contracts, Contracts); add_benchmark!(params, batches, pallet_democracy, Democracy); add_benchmark!(params, batches, pallet_identity, Identity); add_benchmark!(params, batches, pallet_membership, AdvisoryCommitteeMembership); - add_benchmark!(params, batches, pallet_multisig, MultiSig); + add_benchmark!(params, batches, pallet_multisig, Multisig); add_benchmark!(params, batches, pallet_preimage, Preimage); add_benchmark!(params, batches, pallet_proxy, Proxy); add_benchmark!(params, batches, pallet_scheduler, Scheduler); @@ -1275,6 +1319,7 @@ macro_rules! create_runtime_api { add_benchmark!(params, batches, zrml_court, Court); #[cfg(feature = "with-global-disputes")] add_benchmark!(params, batches, zrml_global_disputes, GlobalDisputes); + #[cfg(not(feature = "parachain"))] add_benchmark!(params, batches, zrml_prediction_markets, PredictionMarkets); add_benchmark!(params, batches, zrml_liquidity_mining, LiquidityMining); add_benchmark!(params, batches, zrml_styx, Styx); @@ -1287,7 +1332,6 @@ macro_rules! create_runtime_api { add_benchmark!(params, batches, pallet_author_mapping, AuthorMapping); add_benchmark!(params, batches, pallet_author_slot_filter, AuthorFilter); add_benchmark!(params, batches, pallet_parachain_staking, ParachainStaking); - add_benchmark!(params, batches, pallet_crowdloan_rewards, Crowdloan); } else { add_benchmark!(params, batches, pallet_grandpa, Grandpa); @@ -1307,6 +1351,69 @@ macro_rules! create_runtime_api { } } + impl pallet_contracts::ContractsApi + for Runtime + { + fn call( + origin: AccountId, + dest: AccountId, + value: Balance, + gas_limit: Option, + storage_deposit_limit: Option, + input_data: Vec, + ) -> pallet_contracts_primitives::ContractExecResult { + let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); + Contracts::bare_call( + origin, + dest, + value, + gas_limit, + storage_deposit_limit, + input_data, + CONTRACTS_DEBUG_OUTPUT, + ) + } + + fn instantiate( + origin: AccountId, + value: Balance, + gas_limit: Option, + storage_deposit_limit: Option, + code: pallet_contracts_primitives::Code, + data: Vec, + salt: Vec, + ) -> pallet_contracts_primitives::ContractInstantiateResult + { + let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); + Contracts::bare_instantiate( + origin, + value, + gas_limit, + storage_deposit_limit, + code, + data, + salt, + CONTRACTS_DEBUG_OUTPUT, + ) + } + + fn upload_code( + origin: AccountId, + code: Vec, + storage_deposit_limit: Option, + ) -> pallet_contracts_primitives::CodeUploadResult + { + Contracts::bare_upload_code(origin, code, storage_deposit_limit) + } + + fn get_storage( + address: AccountId, + key: Vec, + ) -> pallet_contracts_primitives::GetStorageResult { + Contracts::get_storage(address, key) + } + } + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { fn query_fee_details( uxt: ::Extrinsic, @@ -1323,6 +1430,23 @@ macro_rules! create_runtime_api { } } + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + for Runtime + { + fn query_call_info( + call: RuntimeCall, + len: u32, + ) -> pallet_transaction_payment::RuntimeDispatchInfo { + TransactionPayment::query_call_info(call, len) + } + fn query_call_fee_details( + call: RuntimeCall, + len: u32, + ) -> pallet_transaction_payment::FeeDetails { + TransactionPayment::query_call_fee_details(call, len) + } + } + #[cfg(feature = "parachain")] impl session_keys_primitives::VrfApi for Runtime { fn get_last_vrf_output() -> Option<::Hash> { @@ -1467,6 +1591,13 @@ macro_rules! create_runtime_api { fn pool_shares_id(pool_id: PoolId) -> Asset> { Asset::PoolShare(SerdeWrapper(pool_id)) } + + fn get_all_spot_prices( + pool_id: &PoolId, + with_fees: bool, + ) -> Result, Balance)>, DispatchError> { + Swaps::get_all_spot_prices(pool_id, with_fees) + } } #[cfg(feature = "try-runtime")] @@ -1477,8 +1608,17 @@ macro_rules! create_runtime_api { (weight, RuntimeBlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> frame_support::weights::Weight { - Executive::execute_block_no_check(block) + fn execute_block(block: Block, state_root_check: bool, try_state: frame_try_runtime::TryStateSelect) -> frame_support::weights::Weight { + log::info!( + "try-runtime: executing block #{} {:?} / root checks: {:?} / try-state-select: {:?}", + block.header.number, + block.header.hash(), + state_root_check, + try_state, + ); + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. + Executive::try_execute_block(block, state_root_check, try_state).expect("execute-block failed") } } @@ -1766,67 +1906,11 @@ macro_rules! create_common_tests { {} => { #[cfg(test)] mod common_tests { - mod fee_multiplier { - use crate::parameters::{MinimumMultiplier, SlowAdjustingFeeUpdate, TargetBlockFullness}; - use frame_support::{ - parameter_types, - weights::{DispatchClass, Weight}, - }; + mod fees { + use crate::*; + use frame_support::{dispatch::DispatchClass, weights::Weight}; use sp_core::H256; - use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, Convert, IdentityLookup}, - Perbill, - }; - - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; - - frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event} - } - ); - - parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const AvailableBlockRatio: Perbill = Perbill::one(); - pub BlockLength: frame_system::limits::BlockLength = - frame_system::limits::BlockLength::max(2 * 1024); - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); - } - - impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type Origin = Origin; - type Index = u64; - type BlockNumber = u64; - type Call = Call; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } + use sp_runtime::traits::Convert; fn run_with_system_weight(w: Weight, mut assertions: F) where @@ -1841,10 +1925,28 @@ macro_rules! create_common_tests { } #[test] - fn multiplier_can_grow_from_zero() { + fn treasury_receives_correct_amount_of_fees_and_tips() { + let mut t: sp_io::TestExternalities = + frame_system::GenesisConfig::default().build_storage::().unwrap().into(); + t.execute_with(|| { + let fee_balance = 3 * ExistentialDeposit::get(); + let fee_imbalance = Balances::issue(fee_balance); + let tip_balance = 7 * ExistentialDeposit::get(); + let tip_imbalance = Balances::issue(tip_balance); + assert_eq!(Balances::free_balance(Treasury::account_id()), 0); + DealWithFees::on_unbalanceds(vec![fee_imbalance, tip_imbalance].into_iter()); + assert_eq!( + Balances::free_balance(Treasury::account_id()), + fee_balance + tip_balance, + ); + }); + } + + #[test] + fn fee_multiplier_can_grow_from_zero() { let minimum_multiplier = MinimumMultiplier::get(); let target = TargetBlockFullness::get() - * BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(); + * RuntimeBlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(); // if the min is too small, then this will not change, and we are doomed forever. // the weight is 1/100th bigger than target. run_with_system_weight(target * 101 / 100, || { @@ -1854,28 +1956,39 @@ macro_rules! create_common_tests { } } - mod deal_with_fees { + mod dust_removal { use crate::*; + use frame_support::PalletId; + use test_case::test_case; + + #[test_case(AuthorizedPalletId::get(); "authorized")] + #[test_case(CourtPalletId::get(); "court")] + #[test_case(LiquidityMiningPalletId::get(); "liquidity_mining")] + #[test_case(PmPalletId::get(); "prediction_markets")] + #[test_case(SimpleDisputesPalletId::get(); "simple_disputes")] + #[test_case(SwapsPalletId::get(); "swaps")] + #[test_case(TreasuryPalletId::get(); "treasury")] + fn whitelisted_pallet_accounts_dont_get_reaped(pallet_id: PalletId) { + let mut t: sp_io::TestExternalities = + frame_system::GenesisConfig::default().build_storage::().unwrap().into(); + t.execute_with(|| { + let pallet_main_account: AccountId = pallet_id.into_account_truncating(); + let pallet_sub_account: AccountId = pallet_id.into_sub_account_truncating(42); + assert!(DustRemovalWhitelist::contains(&pallet_main_account)); + assert!(DustRemovalWhitelist::contains(&pallet_sub_account)); + }); + } #[test] - fn treasury_receives_correct_amount_of_fees_and_tips() { + fn non_whitelisted_accounts_get_reaped() { let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default().build_storage::().unwrap().into(); t.execute_with(|| { - let fee_balance = 3 * ExistentialDeposit::get(); - let fee_imbalance = Balances::issue(fee_balance); - let tip_balance = 7 * ExistentialDeposit::get(); - let tip_imbalance = Balances::issue(tip_balance); - assert_eq!(Balances::free_balance(Treasury::account_id()), 0); - DealWithFees::on_unbalanceds(vec![fee_imbalance, tip_imbalance].into_iter()); - assert_eq!( - Balances::free_balance(Treasury::account_id()), - fee_balance + tip_balance, - ); + let not_whitelisted = AccountId::from([0u8; 32]); + assert!(!DustRemovalWhitelist::contains(¬_whitelisted)) }); } } } - } } diff --git a/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs b/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs index 1ac2e70c4..de959448c 100644 --- a/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for cumulus_pallet_xcmp_queue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,14 +51,14 @@ pub struct WeightInfo(PhantomData); impl cumulus_pallet_xcmp_queue::weights::WeightInfo for WeightInfo { // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_u32() -> Weight { - (12_060_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(14_130_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: XcmpQueue QueueConfig (r:1 w:1) fn set_config_with_weight() -> Weight { - (11_590_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(14_070_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/frame_system.rs b/runtime/common/src/weights/frame_system.rs index 718ed212f..97093daa1 100644 --- a/runtime/common/src/weights/frame_system.rs +++ b/runtime/common/src/weights/frame_system.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -49,41 +50,41 @@ use frame_support::{ pub struct WeightInfo(PhantomData); impl frame_system::weights::WeightInfo for WeightInfo { fn remark(b: u32) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + Weight::from_ref_time(7_750_000) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(692).saturating_mul(b.into())) } fn remark_with_event(b: u32) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) + Weight::from_ref_time(23_520_000) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(2_341).saturating_mul(b.into())) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (11_750_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(16_260_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Skipped Metadata (r:0 w:0) fn set_storage(i: u32) -> Weight { - (0 as Weight) - // Standard Error: 9_000 - .saturating_add((1_266_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + Weight::from_ref_time(7_690_000) + // Standard Error: 4_435 + .saturating_add(Weight::from_ref_time(1_133_019).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } // Storage: Skipped Metadata (r:0 w:0) fn kill_storage(i: u32) -> Weight { - (0 as Weight) - // Standard Error: 3_000 - .saturating_add((1_021_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + Weight::from_ref_time(589_951) + // Standard Error: 8_232 + .saturating_add(Weight::from_ref_time(925_898).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } // Storage: Skipped Metadata (r:0 w:0) fn kill_prefix(p: u32) -> Weight { - (0 as Weight) - // Standard Error: 11_000 - .saturating_add((2_239_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + Weight::from_ref_time(10_930_000) + // Standard Error: 10_457 + .saturating_add(Weight::from_ref_time(2_090_894).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) } } diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs index 3d0fbcf4e..826493ca0 100644 --- a/runtime/common/src/weights/mod.rs +++ b/runtime/common/src/weights/mod.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,12 +19,10 @@ cfg_if::cfg_if! { if #[cfg(feature = "parachain")] { pub mod cumulus_pallet_xcmp_queue; - pub mod pallet_author_inherent; pub mod pallet_author_mapping; + pub mod pallet_author_inherent; pub mod pallet_author_slot_filter; pub mod pallet_parachain_staking; - // Currently the benchmark does fail at the verification of least one function - // pub mod pallet_crowdloan_rewards; } else { // Currently the benchmark does yield an invalid weight implementation // pub mod pallet_grandpa; @@ -36,6 +35,7 @@ pub mod orml_tokens; pub mod pallet_balances; pub mod pallet_bounties; pub mod pallet_collective; +pub mod pallet_contracts; pub mod pallet_democracy; pub mod pallet_identity; pub mod pallet_membership; diff --git a/runtime/common/src/weights/orml_currencies.rs b/runtime/common/src/weights/orml_currencies.rs index 92116c82d..6060abb8d 100644 --- a/runtime/common/src/weights/orml_currencies.rs +++ b/runtime/common/src/weights/orml_currencies.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for orml_currencies //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -45,42 +46,37 @@ use frame_support::{traits::Get, weights::Weight}; /// Weight functions for orml_currencies (automatically generated) pub struct WeightInfo(PhantomData); impl orml_currencies::WeightInfo for WeightInfo { - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_non_native_currency() -> Weight { - (67_910_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(126_411_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer_native_currency() -> Weight { - (65_590_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(108_350_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: System Account (r:1 w:1) fn update_balance_non_native_currency() -> Weight { - (54_870_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(81_740_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: System Account (r:1 w:1) fn update_balance_native_currency_creating() -> Weight { - (52_580_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(60_170_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: System Account (r:1 w:1) fn update_balance_native_currency_killing() -> Weight { - (51_960_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(56_730_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/orml_tokens.rs b/runtime/common/src/weights/orml_tokens.rs index 42a7200ad..576eea239 100644 --- a/runtime/common/src/weights/orml_tokens.rs +++ b/runtime/common/src/weights/orml_tokens.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for orml_tokens //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -45,45 +46,40 @@ use frame_support::{traits::Get, weights::Weight}; /// Weight functions for orml_tokens (automatically generated) pub struct WeightInfo(PhantomData); impl orml_tokens::WeightInfo for WeightInfo { - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (67_361_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(77_290_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (79_580_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(79_941_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (68_240_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(64_210_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:2 w:1) fn force_transfer() -> Weight { - (74_910_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(69_260_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: System Account (r:1 w:1) fn set_balance() -> Weight { - (58_480_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(52_360_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/runtime/common/src/weights/pallet_author_inherent.rs b/runtime/common/src/weights/pallet_author_inherent.rs index 47b4209c1..a5077da73 100644 --- a/runtime/common/src/weights/pallet_author_inherent.rs +++ b/runtime/common/src/weights/pallet_author_inherent.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,11 +19,11 @@ //! Autogenerated weights for pallet_author_inherent //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-09-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/zeitgeist +// ./target/production/zeitgeist // benchmark // pallet // --chain=dev @@ -45,7 +46,7 @@ use frame_support::{ weights::{constants::RocksDbWeight, Weight}, }; -/// Weight functions for pallet_author_mapping (automatically generated) +/// Weight functions for pallet_author_inherent (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_author_inherent::weights::WeightInfo for WeightInfo { // Storage: ParachainSystem ValidationData (r:1 w:0) @@ -54,10 +55,9 @@ impl pallet_author_inherent::weights::WeightInfo for We // Storage: ParachainStaking SelectedCandidates (r:1 w:0) // Storage: AuthorFilter EligibleCount (r:1 w:0) // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - #[rustfmt::skip] fn kick_off_authorship_validation() -> Weight { - (20_862_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(59_020_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_author_mapping.rs b/runtime/common/src/weights/pallet_author_mapping.rs index 03196fb0f..16aa4183e 100644 --- a/runtime/common/src/weights/pallet_author_mapping.rs +++ b/runtime/common/src/weights/pallet_author_mapping.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_author_mapping //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -52,38 +53,38 @@ impl pallet_author_mapping::weights::WeightInfo for Wei // Storage: System Account (r:1 w:1) // Storage: AuthorMapping NimbusLookup (r:0 w:1) fn add_association() -> Weight { - (51_350_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(53_390_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AuthorMapping MappingWithDeposit (r:2 w:2) // Storage: AuthorMapping NimbusLookup (r:0 w:1) fn update_association() -> Weight { - (43_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(48_100_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AuthorMapping MappingWithDeposit (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: AuthorMapping NimbusLookup (r:0 w:1) fn clear_association() -> Weight { - (53_600_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(63_280_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AuthorMapping NimbusLookup (r:1 w:1) // Storage: AuthorMapping MappingWithDeposit (r:1 w:1) // Storage: System Account (r:1 w:1) fn remove_keys() -> Weight { - (59_700_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(68_601_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AuthorMapping NimbusLookup (r:1 w:1) // Storage: AuthorMapping MappingWithDeposit (r:2 w:2) fn set_keys() -> Weight { - (49_860_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(54_100_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/runtime/common/src/weights/pallet_author_slot_filter.rs b/runtime/common/src/weights/pallet_author_slot_filter.rs index 1c4af1ee3..e11b60f57 100644 --- a/runtime/common/src/weights/pallet_author_slot_filter.rs +++ b/runtime/common/src/weights/pallet_author_slot_filter.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_author_slot_filter //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,6 +51,6 @@ pub struct WeightInfo(PhantomData); impl pallet_author_slot_filter::weights::WeightInfo for WeightInfo { // Storage: AuthorFilter EligibleCount (r:0 w:1) fn set_eligible() -> Weight { - (25_110_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(24_300_000).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_balances.rs b/runtime/common/src/weights/pallet_balances.rs index 2db9ec484..286238098 100644 --- a/runtime/common/src/weights/pallet_balances.rs +++ b/runtime/common/src/weights/pallet_balances.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -48,46 +49,46 @@ use frame_support::{ /// Weight functions for pallet_balances (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_balances::weights::WeightInfo for WeightInfo { - // Storage: System Account (r:1 w:1) + // Storage: System Account (r:2 w:2) fn transfer() -> Weight { - (73_560_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(88_860_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (56_010_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(57_540_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (37_611_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(43_620_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (42_260_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(47_800_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: System Account (r:2 w:2) + // Storage: System Account (r:3 w:3) fn force_transfer() -> Weight { - (74_041_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(87_450_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (66_100_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(66_530_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (34_060_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(36_940_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_bounties.rs b/runtime/common/src/weights/pallet_bounties.rs index 8e0ba74b8..aef831d20 100644 --- a/runtime/common/src/weights/pallet_bounties.rs +++ b/runtime/common/src/weights/pallet_bounties.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -52,82 +53,83 @@ impl pallet_bounties::weights::WeightInfo for WeightInf // Storage: Bounties BountyDescriptions (r:0 w:1) // Storage: Bounties Bounties (r:0 w:1) fn propose_bounty(d: u32) -> Weight { - (47_153_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(54_249_004) + // Standard Error: 51 + .saturating_add(Weight::from_ref_time(1_476).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) fn approve_bounty() -> Weight { - (20_440_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(23_710_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Bounties Bounties (r:1 w:1) fn propose_curator() -> Weight { - (15_870_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_920_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Storage: System Account (r:2 w:2) fn unassign_curator() -> Weight { - (55_740_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(73_561_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (47_910_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(51_951_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Bounties Bounties (r:1 w:1) fn award_bounty() -> Weight { - (37_650_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(40_840_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: Bounties BountyDescriptions (r:0 w:1) fn claim_bounty() -> Weight { - (128_800_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(118_311_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Bounties Bounties (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_proposed() -> Weight { - (59_260_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(75_210_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_active() -> Weight { - (84_461_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(91_651_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Bounties Bounties (r:1 w:1) fn extend_bounty_expiry() -> Weight { - (32_200_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(39_970_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Storage: Bounties Bounties (r:2 w:2) + // Storage: System Account (r:3 w:3) fn spend_funds(b: u32) -> Weight { - (0 as Weight) - // Standard Error: 142_000 - .saturating_add((58_120_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) + Weight::from_ref_time(30_972_788) + // Standard Error: 253_591 + .saturating_add(Weight::from_ref_time(45_213_614).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into()))) } } diff --git a/runtime/common/src/weights/pallet_collective.rs b/runtime/common/src/weights/pallet_collective.rs index 65ed5f343..208dac109 100644 --- a/runtime/common/src/weights/pallet_collective.rs +++ b/runtime/common/src/weights/pallet_collective.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,35 +51,37 @@ pub struct WeightInfo(PhantomData); impl pallet_collective::weights::WeightInfo for WeightInfo { // Storage: AdvisoryCommittee Members (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:0) - // Storage: AdvisoryCommittee Voting (r:255 w:255) // Storage: AdvisoryCommittee Prime (r:0 w:1) + // Storage: AdvisoryCommittee Voting (r:255 w:255) fn set_members(m: u32, _n: u32, p: u32) -> Weight { - (0 as Weight) - // Standard Error: 83_000 - .saturating_add((56_925_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 38_000 - .saturating_add((30_621_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + Weight::from_ref_time(32_731_000) + // Standard Error: 311_304 + .saturating_add(Weight::from_ref_time(23_235_351).saturating_mul(m.into())) + // Standard Error: 122_225 + .saturating_add(Weight::from_ref_time(13_933_822).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) } // Storage: AdvisoryCommittee Members (r:1 w:0) fn execute(b: u32, m: u32) -> Weight { - (36_706_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 1_000 - .saturating_add((41_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(38_099_888) + // Standard Error: 306 + .saturating_add(Weight::from_ref_time(2_613).saturating_mul(b.into())) + // Standard Error: 3_157 + .saturating_add(Weight::from_ref_time(32_308).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1)) } // Storage: AdvisoryCommittee Members (r:1 w:0) // Storage: AdvisoryCommittee ProposalOf (r:1 w:0) - fn propose_execute(_b: u32, m: u32) -> Weight { - (48_486_000 as Weight) - // Standard Error: 5_000 - .saturating_add((97_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + fn propose_execute(b: u32, m: u32) -> Weight { + Weight::from_ref_time(31_265_128) + // Standard Error: 1_317 + .saturating_add(Weight::from_ref_time(10_669).saturating_mul(b.into())) + // Standard Error: 13_595 + .saturating_add(Weight::from_ref_time(112_110).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2)) } // Storage: AdvisoryCommittee Members (r:1 w:0) // Storage: AdvisoryCommittee ProposalOf (r:1 w:1) @@ -86,50 +89,50 @@ impl pallet_collective::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee ProposalCount (r:1 w:1) // Storage: AdvisoryCommittee Voting (r:0 w:1) fn propose_proposed(b: u32, m: u32, p: u32) -> Weight { - (53_939_000 as Weight) - // Standard Error: 1_000 - .saturating_add((10_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 14_000 - .saturating_add((163_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 6_000 - .saturating_add((382_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(25_616_035) + // Standard Error: 1_527 + .saturating_add(Weight::from_ref_time(17_284).saturating_mul(b.into())) + // Standard Error: 15_956 + .saturating_add(Weight::from_ref_time(169_554).saturating_mul(m.into())) + // Standard Error: 6_142 + .saturating_add(Weight::from_ref_time(343_561).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: AdvisoryCommittee Members (r:1 w:0) // Storage: AdvisoryCommittee Voting (r:1 w:1) fn vote(m: u32) -> Weight { - (90_862_000 as Weight) - // Standard Error: 12_000 - .saturating_add((277_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(90_528_096) + // Standard Error: 14_755 + .saturating_add(Weight::from_ref_time(146_151).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: AdvisoryCommittee Voting (r:1 w:1) // Storage: AdvisoryCommittee Members (r:1 w:0) // Storage: AdvisoryCommittee Proposals (r:1 w:1) // Storage: AdvisoryCommittee ProposalOf (r:0 w:1) fn close_early_disapproved(_m: u32, p: u32) -> Weight { - (98_487_000 as Weight) - // Standard Error: 5_000 - .saturating_add((273_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(75_980_153) + // Standard Error: 6_504 + .saturating_add(Weight::from_ref_time(264_113).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommittee Voting (r:1 w:1) // Storage: AdvisoryCommittee Members (r:1 w:0) // Storage: AdvisoryCommittee ProposalOf (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:1) fn close_early_approved(b: u32, m: u32, p: u32) -> Weight { - (73_947_000 as Weight) - // Standard Error: 1_000 - .saturating_add((13_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 13_000 - .saturating_add((239_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 5_000 - .saturating_add((340_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(69_183_206) + // Standard Error: 1_705 + .saturating_add(Weight::from_ref_time(3_701).saturating_mul(b.into())) + // Standard Error: 18_045 + .saturating_add(Weight::from_ref_time(56_946).saturating_mul(m.into())) + // Standard Error: 6_858 + .saturating_add(Weight::from_ref_time(354_392).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommittee Voting (r:1 w:1) // Storage: AdvisoryCommittee Members (r:1 w:0) @@ -137,11 +140,11 @@ impl pallet_collective::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee Proposals (r:1 w:1) // Storage: AdvisoryCommittee ProposalOf (r:0 w:1) fn close_disapproved(_m: u32, p: u32) -> Weight { - (100_924_000 as Weight) - // Standard Error: 5_000 - .saturating_add((268_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(70_835_908) + // Standard Error: 5_382 + .saturating_add(Weight::from_ref_time(251_804).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommittee Voting (r:1 w:1) // Storage: AdvisoryCommittee Members (r:1 w:0) @@ -149,24 +152,24 @@ impl pallet_collective::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee ProposalOf (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:1) fn close_approved(b: u32, m: u32, p: u32) -> Weight { - (101_633_000 as Weight) - // Standard Error: 1_000 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 12_000 - .saturating_add((137_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 5_000 - .saturating_add((315_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(75_528_267) + // Standard Error: 1_711 + .saturating_add(Weight::from_ref_time(7_499).saturating_mul(b.into())) + // Standard Error: 18_111 + .saturating_add(Weight::from_ref_time(50_403).saturating_mul(m.into())) + // Standard Error: 6_883 + .saturating_add(Weight::from_ref_time(320_949).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommittee Proposals (r:1 w:1) // Storage: AdvisoryCommittee Voting (r:0 w:1) // Storage: AdvisoryCommittee ProposalOf (r:0 w:1) fn disapprove_proposal(p: u32) -> Weight { - (45_138_000 as Weight) - // Standard Error: 8_000 - .saturating_add((361_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(44_597_874) + // Standard Error: 4_479 + .saturating_add(Weight::from_ref_time(227_653).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/runtime/common/src/weights/pallet_contracts.rs b/runtime/common/src/weights/pallet_contracts.rs new file mode 100644 index 000000000..e620888ad --- /dev/null +++ b/runtime/common/src/weights/pallet_contracts.rs @@ -0,0 +1,1035 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. +// Copyright 2021-2022 Zeitgeist PM LLC. +// +// This file is part of Zeitgeist. +// +// Zeitgeist 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. +// +// Zeitgeist 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 Zeitgeist. If not, see . + +//! Autogenerated weights for pallet_contracts +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/zeitgeist +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_contracts +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./misc/frame_weight_template.hbs +// --output=./runtime/common/src/weights/ + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use core::marker::PhantomData; +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; + +/// Weight functions for pallet_contracts (automatically generated) +pub struct WeightInfo(PhantomData); +impl pallet_contracts::weights::WeightInfo for WeightInfo { + // Storage: Contracts DeletionQueue (r:1 w:0) + fn on_process_deletion_queue_batch() -> Weight { + Weight::from_ref_time(5_430_000).saturating_add(T::DbWeight::get().reads(1)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn on_initialize_per_trie_key(k: u32) -> Weight { + Weight::from_ref_time(21_126_505) + // Standard Error: 13_440 + .saturating_add(Weight::from_ref_time(1_728_031).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) + } + // Storage: Contracts DeletionQueue (r:1 w:0) + fn on_initialize_per_queue_item(q: u32) -> Weight { + Weight::from_ref_time(18_600_736) + // Standard Error: 14_810 + .saturating_add(Weight::from_ref_time(2_184_181).saturating_mul(q.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: Contracts PristineCode (r:1 w:0) + // Storage: Contracts CodeStorage (r:0 w:1) + fn reinstrument(c: u32) -> Weight { + Weight::from_ref_time(55_981_230) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(92_321).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: System EventTopics (r:2 w:2) + fn call_with_code_per_byte(c: u32) -> Weight { + Weight::from_ref_time(337_950_536) + // Standard Error: 215 + .saturating_add(Weight::from_ref_time(95_890).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: Contracts CodeStorage (r:1 w:1) + // Storage: Contracts Nonce (r:1 w:1) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: System EventTopics (r:3 w:3) + // Storage: Contracts PristineCode (r:0 w:1) + // Storage: Contracts OwnerInfoOf (r:0 w:1) + fn instantiate_with_code(c: u32, s: u32) -> Weight { + Weight::from_ref_time(2_421_717_000) + // Standard Error: 427 + .saturating_add(Weight::from_ref_time(219_033).saturating_mul(c.into())) + // Standard Error: 50 + .saturating_add(Weight::from_ref_time(1_109).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(9)) + } + // Storage: Contracts CodeStorage (r:1 w:1) + // Storage: Contracts Nonce (r:1 w:1) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Contracts OwnerInfoOf (r:1 w:1) + // Storage: System EventTopics (r:2 w:2) + fn instantiate(s: u32) -> Weight { + Weight::from_ref_time(335_483_496) + // Standard Error: 20 + .saturating_add(Weight::from_ref_time(2_381).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(7)) + } + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: System EventTopics (r:2 w:2) + fn call() -> Weight { + Weight::from_ref_time(285_701_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: Contracts CodeStorage (r:1 w:1) + // Storage: System EventTopics (r:1 w:1) + // Storage: Contracts PristineCode (r:0 w:1) + // Storage: Contracts OwnerInfoOf (r:0 w:1) + fn upload_code(c: u32) -> Weight { + Weight::from_ref_time(112_178_130) + // Standard Error: 332 + .saturating_add(Weight::from_ref_time(95_761).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: Contracts OwnerInfoOf (r:1 w:1) + // Storage: System EventTopics (r:1 w:1) + // Storage: Contracts CodeStorage (r:0 w:1) + // Storage: Contracts PristineCode (r:0 w:1) + fn remove_code() -> Weight { + Weight::from_ref_time(59_740_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts OwnerInfoOf (r:2 w:2) + // Storage: System EventTopics (r:3 w:3) + fn set_code() -> Weight { + Weight::from_ref_time(63_861_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_caller(r: u32) -> Weight { + Weight::from_ref_time(429_851_105) + // Standard Error: 519_341 + .saturating_add(Weight::from_ref_time(64_705_911).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_is_contract(r: u32) -> Weight { + Weight::from_ref_time(228_433_066) + // Standard Error: 2_457_712 + .saturating_add(Weight::from_ref_time(414_003_443).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_code_hash(r: u32) -> Weight { + Weight::from_ref_time(253_602_444) + // Standard Error: 2_566_145 + .saturating_add(Weight::from_ref_time(501_245_968).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_own_code_hash(r: u32) -> Weight { + Weight::from_ref_time(410_061_442) + // Standard Error: 554_698 + .saturating_add(Weight::from_ref_time(74_990_773).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_caller_is_origin(r: u32) -> Weight { + Weight::from_ref_time(370_129_126) + // Standard Error: 305_060 + .saturating_add(Weight::from_ref_time(34_207_685).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_address(r: u32) -> Weight { + Weight::from_ref_time(382_094_225) + // Standard Error: 559_795 + .saturating_add(Weight::from_ref_time(71_147_591).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_gas_left(r: u32) -> Weight { + Weight::from_ref_time(380_790_502) + // Standard Error: 465_874 + .saturating_add(Weight::from_ref_time(71_661_062).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_balance(r: u32) -> Weight { + Weight::from_ref_time(431_292_750) + // Standard Error: 1_167_048 + .saturating_add(Weight::from_ref_time(191_585_845).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_value_transferred(r: u32) -> Weight { + Weight::from_ref_time(391_162_195) + // Standard Error: 568_077 + .saturating_add(Weight::from_ref_time(70_814_297).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_minimum_balance(r: u32) -> Weight { + Weight::from_ref_time(373_534_298) + // Standard Error: 570_574 + .saturating_add(Weight::from_ref_time(72_100_896).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_block_number(r: u32) -> Weight { + Weight::from_ref_time(399_854_114) + // Standard Error: 650_050 + .saturating_add(Weight::from_ref_time(69_599_814).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_now(r: u32) -> Weight { + Weight::from_ref_time(409_619_912) + // Standard Error: 546_591 + .saturating_add(Weight::from_ref_time(68_293_199).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + fn seal_weight_to_fee(r: u32) -> Weight { + Weight::from_ref_time(442_803_328) + // Standard Error: 1_135_167 + .saturating_add(Weight::from_ref_time(188_615_603).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_gas(r: u32) -> Weight { + Weight::from_ref_time(266_802_137) + // Standard Error: 241_974 + .saturating_add(Weight::from_ref_time(35_276_027).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_input(r: u32) -> Weight { + Weight::from_ref_time(388_193_410) + // Standard Error: 671_777 + .saturating_add(Weight::from_ref_time(66_820_636).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_input_per_kb(n: u32) -> Weight { + Weight::from_ref_time(566_118_524) + // Standard Error: 48_908 + .saturating_add(Weight::from_ref_time(11_277_830).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_return(r: u32) -> Weight { + Weight::from_ref_time(360_679_048) + // Standard Error: 7_022_513 + .saturating_add(Weight::from_ref_time(2_407_051).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_return_per_kb(n: u32) -> Weight { + Weight::from_ref_time(332_530_984) + // Standard Error: 5_870 + .saturating_add(Weight::from_ref_time(292_619).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: Contracts DeletionQueue (r:1 w:1) + // Storage: Contracts OwnerInfoOf (r:1 w:1) + fn seal_terminate(r: u32) -> Weight { + Weight::from_ref_time(362_646_016) + // Standard Error: 8_084_601 + .saturating_add(Weight::from_ref_time(126_591_583).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(r.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + fn seal_random(r: u32) -> Weight { + Weight::from_ref_time(483_492_798) + // Standard Error: 1_084_291 + .saturating_add(Weight::from_ref_time(234_691_271).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_deposit_event(r: u32) -> Weight { + Weight::from_ref_time(475_254_342) + // Standard Error: 1_210_835 + .saturating_add(Weight::from_ref_time(414_842_876).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32) -> Weight { + Weight::from_ref_time(800_511_261) + // Standard Error: 4_024_007 + .saturating_add(Weight::from_ref_time(273_889_344).saturating_mul(t.into())) + // Standard Error: 1_105_187 + .saturating_add(Weight::from_ref_time(128_312_139).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(t.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(t.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_debug_message(r: u32) -> Weight { + Weight::from_ref_time(260_227_469) + // Standard Error: 329_312 + .saturating_add(Weight::from_ref_time(61_555_618).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_set_storage(r: u32) -> Weight { + Weight::from_ref_time(211_554_844) + // Standard Error: 3_488_247 + .saturating_add(Weight::from_ref_time(765_641_607).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_set_storage_per_new_kb(n: u32) -> Weight { + Weight::from_ref_time(909_084_701) + // Standard Error: 2_743_185 + .saturating_add(Weight::from_ref_time(157_699_453).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(52)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(50)) + .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_set_storage_per_old_kb(n: u32) -> Weight { + Weight::from_ref_time(906_858_298) + // Standard Error: 2_597_668 + .saturating_add(Weight::from_ref_time(131_583_508).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(49)) + .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_clear_storage(r: u32) -> Weight { + Weight::from_ref_time(250_838_557) + // Standard Error: 3_953_072 + .saturating_add(Weight::from_ref_time(752_817_562).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_clear_storage_per_kb(n: u32) -> Weight { + Weight::from_ref_time(888_409_158) + // Standard Error: 2_872_941 + .saturating_add(Weight::from_ref_time(137_003_843).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(48)) + .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_get_storage(r: u32) -> Weight { + Weight::from_ref_time(307_853_330) + // Standard Error: 2_929_425 + .saturating_add(Weight::from_ref_time(624_411_181).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_get_storage_per_kb(n: u32) -> Weight { + Weight::from_ref_time(843_713_360) + // Standard Error: 3_030_824 + .saturating_add(Weight::from_ref_time(276_315_933).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_contains_storage(r: u32) -> Weight { + Weight::from_ref_time(249_841_376) + // Standard Error: 3_135_806 + .saturating_add(Weight::from_ref_time(603_144_627).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_contains_storage_per_kb(n: u32) -> Weight { + Weight::from_ref_time(763_767_425) + // Standard Error: 2_472_643 + .saturating_add(Weight::from_ref_time(130_252_790).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_take_storage(r: u32) -> Weight { + Weight::from_ref_time(334_655_059) + // Standard Error: 3_051_400 + .saturating_add(Weight::from_ref_time(785_392_996).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) + } + // Storage: Skipped Metadata (r:0 w:0) + fn seal_take_storage_per_kb(n: u32) -> Weight { + Weight::from_ref_time(966_883_133) + // Standard Error: 3_258_692 + .saturating_add(Weight::from_ref_time(278_953_423).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(48)) + .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_transfer(r: u32) -> Weight { + Weight::from_ref_time(273_996_331) + // Standard Error: 6_652_380 + .saturating_add(Weight::from_ref_time(2_417_165_113).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_call(r: u32) -> Weight { + Weight::from_ref_time(386_971_000) + // Standard Error: 22_578_548 + .saturating_add(Weight::from_ref_time(26_372_914_655).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((160_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((160_u64).saturating_mul(r.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_delegate_call(r: u32) -> Weight { + Weight::from_ref_time(388_991_000) + // Standard Error: 23_351_009 + .saturating_add(Weight::from_ref_time(25_697_616_633).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((75_u64).saturating_mul(r.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:81 w:81) + // Storage: Contracts CodeStorage (r:2 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:82 w:82) + fn seal_call_per_transfer_clone_kb(t: u32, c: u32) -> Weight { + Weight::from_ref_time(16_857_681_725) + // Standard Error: 80_358_674 + .saturating_add(Weight::from_ref_time(2_533_007_016).saturating_mul(t.into())) + // Standard Error: 120_493 + .saturating_add(Weight::from_ref_time(12_716_262).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(167)) + .saturating_add(T::DbWeight::get().reads((81_u64).saturating_mul(t.into()))) + .saturating_add(T::DbWeight::get().writes(163)) + .saturating_add(T::DbWeight::get().writes((81_u64).saturating_mul(t.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: Contracts Nonce (r:1 w:1) + // Storage: Contracts OwnerInfoOf (r:80 w:80) + fn seal_instantiate(r: u32) -> Weight { + Weight::from_ref_time(334_620_000) + // Standard Error: 44_876_896 + .saturating_add(Weight::from_ref_time(37_005_078_638).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().reads((400_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((400_u64).saturating_mul(r.into()))) + } + // Storage: System Account (r:81 w:81) + // Storage: Contracts ContractInfoOf (r:81 w:81) + // Storage: Contracts CodeStorage (r:2 w:1) + // Storage: Timestamp Now (r:1 w:0) + // Storage: Contracts Nonce (r:1 w:1) + // Storage: Contracts OwnerInfoOf (r:1 w:1) + // Storage: System EventTopics (r:82 w:82) + fn seal_instantiate_per_transfer_salt_kb(t: u32, s: u32) -> Weight { + Weight::from_ref_time(22_281_656_470) + // Standard Error: 217_359_849 + .saturating_add(Weight::from_ref_time(741_718_573).saturating_mul(t.into())) + // Standard Error: 347_653 + .saturating_add(Weight::from_ref_time(157_462_985).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(249)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) + .saturating_add(T::DbWeight::get().writes(247)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_sha2_256(r: u32) -> Weight { + Weight::from_ref_time(415_594_038) + // Standard Error: 654_607 + .saturating_add(Weight::from_ref_time(75_882_836).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_sha2_256_per_kb(n: u32) -> Weight { + Weight::from_ref_time(489_535_499) + // Standard Error: 90_743 + .saturating_add(Weight::from_ref_time(75_697_388).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_keccak_256(r: u32) -> Weight { + Weight::from_ref_time(387_212_676) + // Standard Error: 781_503 + .saturating_add(Weight::from_ref_time(118_018_650).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_keccak_256_per_kb(n: u32) -> Weight { + Weight::from_ref_time(414_375_901) + // Standard Error: 298_046 + .saturating_add(Weight::from_ref_time(339_822_495).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_blake2_256(r: u32) -> Weight { + Weight::from_ref_time(405_586_694) + // Standard Error: 663_562 + .saturating_add(Weight::from_ref_time(86_490_468).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_blake2_256_per_kb(n: u32) -> Weight { + Weight::from_ref_time(413_977_103) + // Standard Error: 152_186 + .saturating_add(Weight::from_ref_time(142_126_964).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_blake2_128(r: u32) -> Weight { + Weight::from_ref_time(444_521_069) + // Standard Error: 750_665 + .saturating_add(Weight::from_ref_time(83_524_062).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_hash_blake2_128_per_kb(n: u32) -> Weight { + Weight::from_ref_time(516_241_606) + // Standard Error: 166_730 + .saturating_add(Weight::from_ref_time(142_486_559).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_ecdsa_recover(r: u32) -> Weight { + Weight::from_ref_time(522_466_425) + // Standard Error: 3_403_869 + .saturating_add(Weight::from_ref_time(5_058_433_282).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + fn seal_ecdsa_to_eth_address(r: u32) -> Weight { + Weight::from_ref_time(451_250_199) + // Standard Error: 2_486_466 + .saturating_add(Weight::from_ref_time(3_146_420_906).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: Contracts OwnerInfoOf (r:16 w:16) + fn seal_set_code_hash(r: u32) -> Weight { + Weight::from_ref_time(385_651_000) + // Standard Error: 5_606_558 + .saturating_add(Weight::from_ref_time(1_961_350_521).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((150_u64).saturating_mul(r.into()))) + } + fn instr_i64const(_r: u32) -> Weight { + Weight::from_ref_time(122_460_750) + } + fn instr_i64load(r: u32) -> Weight { + Weight::from_ref_time(125_175_300) + // Standard Error: 105_692 + .saturating_add(Weight::from_ref_time(3_359_715).saturating_mul(r.into())) + } + fn instr_i64store(r: u32) -> Weight { + Weight::from_ref_time(112_576_350) + // Standard Error: 101_259 + .saturating_add(Weight::from_ref_time(3_521_170).saturating_mul(r.into())) + } + fn instr_select(r: u32) -> Weight { + Weight::from_ref_time(102_506_019) + // Standard Error: 75_352 + .saturating_add(Weight::from_ref_time(2_401_178).saturating_mul(r.into())) + } + fn instr_if(r: u32) -> Weight { + Weight::from_ref_time(99_372_077) + // Standard Error: 83_410 + .saturating_add(Weight::from_ref_time(2_944_705).saturating_mul(r.into())) + } + fn instr_br(r: u32) -> Weight { + Weight::from_ref_time(98_973_384) + // Standard Error: 41_547 + .saturating_add(Weight::from_ref_time(1_068_659).saturating_mul(r.into())) + } + fn instr_br_if(r: u32) -> Weight { + Weight::from_ref_time(91_819_087) + // Standard Error: 40_887 + .saturating_add(Weight::from_ref_time(2_207_857).saturating_mul(r.into())) + } + fn instr_br_table(r: u32) -> Weight { + Weight::from_ref_time(95_474_418) + // Standard Error: 58_610 + .saturating_add(Weight::from_ref_time(2_581_391).saturating_mul(r.into())) + } + fn instr_br_table_per_entry(_e: u32) -> Weight { + Weight::from_ref_time(117_405_984) + } + fn instr_call(r: u32) -> Weight { + Weight::from_ref_time(112_429_292) + // Standard Error: 99_778 + .saturating_add(Weight::from_ref_time(13_774_135).saturating_mul(r.into())) + } + fn instr_call_indirect(r: u32) -> Weight { + Weight::from_ref_time(150_769_904) + // Standard Error: 95_834 + .saturating_add(Weight::from_ref_time(15_632_455).saturating_mul(r.into())) + } + fn instr_call_indirect_per_param(p: u32) -> Weight { + Weight::from_ref_time(154_075_963) + // Standard Error: 32_914 + .saturating_add(Weight::from_ref_time(503_883).saturating_mul(p.into())) + } + fn instr_local_get(r: u32) -> Weight { + Weight::from_ref_time(102_998_676) + // Standard Error: 44_362 + .saturating_add(Weight::from_ref_time(719_850).saturating_mul(r.into())) + } + fn instr_local_set(r: u32) -> Weight { + Weight::from_ref_time(108_712_354) + // Standard Error: 76_347 + .saturating_add(Weight::from_ref_time(1_044_158).saturating_mul(r.into())) + } + fn instr_local_tee(r: u32) -> Weight { + Weight::from_ref_time(101_232_008) + // Standard Error: 54_203 + .saturating_add(Weight::from_ref_time(1_352_671).saturating_mul(r.into())) + } + fn instr_global_get(r: u32) -> Weight { + Weight::from_ref_time(118_094_896) + // Standard Error: 51_874 + .saturating_add(Weight::from_ref_time(2_298_229).saturating_mul(r.into())) + } + fn instr_global_set(r: u32) -> Weight { + Weight::from_ref_time(110_609_615) + // Standard Error: 64_730 + .saturating_add(Weight::from_ref_time(2_619_354).saturating_mul(r.into())) + } + fn instr_memory_current(r: u32) -> Weight { + Weight::from_ref_time(106_231_874) + // Standard Error: 46_093 + .saturating_add(Weight::from_ref_time(1_138_117).saturating_mul(r.into())) + } + fn instr_memory_grow(r: u32) -> Weight { + Weight::from_ref_time(105_442_708) + // Standard Error: 184_928 + .saturating_add(Weight::from_ref_time(253_568_391).saturating_mul(r.into())) + } + fn instr_i64clz(r: u32) -> Weight { + Weight::from_ref_time(109_882_080) + // Standard Error: 79_867 + .saturating_add(Weight::from_ref_time(1_045_369).saturating_mul(r.into())) + } + fn instr_i64ctz(r: u32) -> Weight { + Weight::from_ref_time(104_382_071) + // Standard Error: 59_887 + .saturating_add(Weight::from_ref_time(1_392_400).saturating_mul(r.into())) + } + fn instr_i64popcnt(r: u32) -> Weight { + Weight::from_ref_time(99_412_583) + // Standard Error: 63_924 + .saturating_add(Weight::from_ref_time(2_054_239).saturating_mul(r.into())) + } + fn instr_i64eqz(r: u32) -> Weight { + Weight::from_ref_time(125_130_116) + // Standard Error: 64_926 + .saturating_add(Weight::from_ref_time(646_256).saturating_mul(r.into())) + } + fn instr_i64extendsi32(r: u32) -> Weight { + Weight::from_ref_time(107_210_858) + // Standard Error: 56_648 + .saturating_add(Weight::from_ref_time(1_048_235).saturating_mul(r.into())) + } + fn instr_i64extendui32(r: u32) -> Weight { + Weight::from_ref_time(110_419_986) + // Standard Error: 44_693 + .saturating_add(Weight::from_ref_time(988_942).saturating_mul(r.into())) + } + fn instr_i32wrapi64(r: u32) -> Weight { + Weight::from_ref_time(106_097_103) + // Standard Error: 76_263 + .saturating_add(Weight::from_ref_time(1_316_794).saturating_mul(r.into())) + } + fn instr_i64eq(r: u32) -> Weight { + Weight::from_ref_time(108_116_972) + // Standard Error: 75_075 + .saturating_add(Weight::from_ref_time(1_862_540).saturating_mul(r.into())) + } + fn instr_i64ne(r: u32) -> Weight { + Weight::from_ref_time(108_928_442) + // Standard Error: 65_988 + .saturating_add(Weight::from_ref_time(1_749_498).saturating_mul(r.into())) + } + fn instr_i64lts(r: u32) -> Weight { + Weight::from_ref_time(106_800_063) + // Standard Error: 58_401 + .saturating_add(Weight::from_ref_time(1_961_216).saturating_mul(r.into())) + } + fn instr_i64ltu(r: u32) -> Weight { + Weight::from_ref_time(103_579_984) + // Standard Error: 75_440 + .saturating_add(Weight::from_ref_time(1_974_347).saturating_mul(r.into())) + } + fn instr_i64gts(r: u32) -> Weight { + Weight::from_ref_time(96_102_214) + // Standard Error: 68_969 + .saturating_add(Weight::from_ref_time(2_188_537).saturating_mul(r.into())) + } + fn instr_i64gtu(r: u32) -> Weight { + Weight::from_ref_time(102_308_447) + // Standard Error: 61_981 + .saturating_add(Weight::from_ref_time(1_944_744).saturating_mul(r.into())) + } + fn instr_i64les(r: u32) -> Weight { + Weight::from_ref_time(101_265_982) + // Standard Error: 56_197 + .saturating_add(Weight::from_ref_time(1_985_022).saturating_mul(r.into())) + } + fn instr_i64leu(r: u32) -> Weight { + Weight::from_ref_time(103_437_480) + // Standard Error: 42_629 + .saturating_add(Weight::from_ref_time(1_877_996).saturating_mul(r.into())) + } + fn instr_i64ges(r: u32) -> Weight { + Weight::from_ref_time(110_657_052) + // Standard Error: 49_776 + .saturating_add(Weight::from_ref_time(1_622_420).saturating_mul(r.into())) + } + fn instr_i64geu(r: u32) -> Weight { + Weight::from_ref_time(112_441_903) + // Standard Error: 57_140 + .saturating_add(Weight::from_ref_time(1_803_781).saturating_mul(r.into())) + } + fn instr_i64add(r: u32) -> Weight { + Weight::from_ref_time(101_923_895) + // Standard Error: 44_865 + .saturating_add(Weight::from_ref_time(2_081_863).saturating_mul(r.into())) + } + fn instr_i64sub(r: u32) -> Weight { + Weight::from_ref_time(105_037_682) + // Standard Error: 67_975 + .saturating_add(Weight::from_ref_time(1_982_365).saturating_mul(r.into())) + } + fn instr_i64mul(r: u32) -> Weight { + Weight::from_ref_time(102_264_234) + // Standard Error: 45_342 + .saturating_add(Weight::from_ref_time(2_007_440).saturating_mul(r.into())) + } + fn instr_i64divs(r: u32) -> Weight { + Weight::from_ref_time(103_770_139) + // Standard Error: 42_377 + .saturating_add(Weight::from_ref_time(1_816_014).saturating_mul(r.into())) + } + fn instr_i64divu(r: u32) -> Weight { + Weight::from_ref_time(99_619_964) + // Standard Error: 56_465 + .saturating_add(Weight::from_ref_time(1_998_149).saturating_mul(r.into())) + } + fn instr_i64rems(r: u32) -> Weight { + Weight::from_ref_time(105_446_479) + // Standard Error: 67_747 + .saturating_add(Weight::from_ref_time(1_944_050).saturating_mul(r.into())) + } + fn instr_i64remu(r: u32) -> Weight { + Weight::from_ref_time(92_700_760) + // Standard Error: 38_698 + .saturating_add(Weight::from_ref_time(2_193_530).saturating_mul(r.into())) + } + fn instr_i64and(r: u32) -> Weight { + Weight::from_ref_time(101_410_626) + // Standard Error: 84_478 + .saturating_add(Weight::from_ref_time(2_127_952).saturating_mul(r.into())) + } + fn instr_i64or(r: u32) -> Weight { + Weight::from_ref_time(96_179_133) + // Standard Error: 45_323 + .saturating_add(Weight::from_ref_time(5_277_734).saturating_mul(r.into())) + } + fn instr_i64xor(r: u32) -> Weight { + Weight::from_ref_time(103_567_886) + // Standard Error: 39_751 + .saturating_add(Weight::from_ref_time(1_857_890).saturating_mul(r.into())) + } + fn instr_i64shl(r: u32) -> Weight { + Weight::from_ref_time(119_259_398) + // Standard Error: 110_741 + .saturating_add(Weight::from_ref_time(1_393_081).saturating_mul(r.into())) + } + fn instr_i64shrs(r: u32) -> Weight { + Weight::from_ref_time(100_419_754) + // Standard Error: 80_452 + .saturating_add(Weight::from_ref_time(2_076_493).saturating_mul(r.into())) + } + fn instr_i64shru(r: u32) -> Weight { + Weight::from_ref_time(108_703_844) + // Standard Error: 61_560 + .saturating_add(Weight::from_ref_time(1_797_329).saturating_mul(r.into())) + } + fn instr_i64rotl(r: u32) -> Weight { + Weight::from_ref_time(98_000_338) + // Standard Error: 45_962 + .saturating_add(Weight::from_ref_time(2_037_187).saturating_mul(r.into())) + } + fn instr_i64rotr(r: u32) -> Weight { + Weight::from_ref_time(100_878_437) + // Standard Error: 64_534 + .saturating_add(Weight::from_ref_time(2_112_436).saturating_mul(r.into())) + } +} diff --git a/runtime/common/src/weights/pallet_democracy.rs b/runtime/common/src/weights/pallet_democracy.rs index 774083caa..cd9363669 100644 --- a/runtime/common/src/weights/pallet_democracy.rs +++ b/runtime/common/src/weights/pallet_democracy.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -53,228 +54,180 @@ impl pallet_democracy::weights::WeightInfo for WeightIn // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - (99_190_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(85_720_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy DepositOf (r:1 w:1) - fn second(s: u32) -> Weight { - (50_566_000 as Weight) - // Standard Error: 7_000 - .saturating_add((445_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn second() -> Weight { + Weight::from_ref_time(85_541_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - fn vote_new(r: u32) -> Weight { - (72_516_000 as Weight) - // Standard Error: 12_000 - .saturating_add((405_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_new() -> Weight { + Weight::from_ref_time(87_931_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - fn vote_existing(r: u32) -> Weight { - (69_938_000 as Weight) - // Standard Error: 18_000 - .saturating_add((449_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_existing() -> Weight { + Weight::from_ref_time(89_590_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) fn emergency_cancel() -> Weight { - (34_740_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_740_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy DepositOf (r:1 w:1) + // Storage: System Account (r:2 w:2) // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Blacklist (r:0 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:2 w:2) - fn blacklist(p: u32) -> Weight { - (102_527_000 as Weight) - // Standard Error: 17_000 - .saturating_add((650_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + fn blacklist() -> Weight { + Weight::from_ref_time(136_551_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) - fn external_propose(v: u32) -> Weight { - (22_773_000 as Weight) - // Standard Error: 1_000 - .saturating_add((47_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn external_propose() -> Weight { + Weight::from_ref_time(32_960_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - (7_420_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(10_160_000).saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - (7_880_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(10_260_000).saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - (35_750_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(41_010_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) - fn veto_external(v: u32) -> Weight { - (42_116_000 as Weight) - // Standard Error: 4_000 - .saturating_add((46_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn veto_external() -> Weight { + Weight::from_ref_time(44_320_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:2 w:2) - fn cancel_proposal(p: u32) -> Weight { - (79_688_000 as Weight) - // Standard Error: 12_000 - .saturating_add((679_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + fn cancel_proposal() -> Weight { + Weight::from_ref_time(118_040_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - (24_280_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn cancel_queued(r: u32) -> Weight { - (39_489_000 as Weight) - // Standard Error: 18_000 - .saturating_add((1_227_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(26_210_000).saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) fn on_initialize_base(r: u32) -> Weight { - (9_262_000 as Weight) - // Standard Error: 23_000 - .saturating_add((6_409_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_685_582) + // Standard Error: 29_688 + .saturating_add(Weight::from_ref_time(3_650_691).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) fn on_initialize_base_with_launch_period(r: u32) -> Weight { - (12_094_000 as Weight) - // Standard Error: 17_000 - .saturating_add((6_467_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_028_388) + // Standard Error: 31_771 + .saturating_add(Weight::from_ref_time(3_759_627).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy VotingOf (r:3 w:3) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) fn delegate(r: u32) -> Weight { - (63_558_000 as Weight) - // Standard Error: 53_000 - .saturating_add((9_035_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + Weight::from_ref_time(80_660_465) + // Standard Error: 46_086 + .saturating_add(Weight::from_ref_time(5_710_550).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) fn undelegate(r: u32) -> Weight { - (33_478_000 as Weight) - // Standard Error: 42_000 - .saturating_add((8_797_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + Weight::from_ref_time(47_463_351) + // Standard Error: 82_783 + .saturating_add(Weight::from_ref_time(5_824_287).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - (9_400_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - fn note_preimage(b: u32) -> Weight { - (53_547_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - fn note_imminent_preimage(b: u32) -> Weight { - (35_292_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - // Storage: System Account (r:1 w:0) - fn reap_preimage(b: u32) -> Weight { - (53_182_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(11_770_000).saturating_add(T::DbWeight::get().writes(1)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_remove(r: u32) -> Weight { - (45_241_000 as Weight) - // Standard Error: 7_000 - .saturating_add((213_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(56_811_597) + // Standard Error: 6_746 + .saturating_add(Weight::from_ref_time(49_599).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn unlock_set(r: u32) -> Weight { - (44_693_000 as Weight) - // Standard Error: 7_000 - .saturating_add((361_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(54_791_225) + // Standard Error: 6_309 + .saturating_add(Weight::from_ref_time(145_190).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_vote(r: u32) -> Weight { - (27_874_000 as Weight) - // Standard Error: 6_000 - .saturating_add((371_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_774_882) + // Standard Error: 7_750 + .saturating_add(Weight::from_ref_time(95_570).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) fn remove_other_vote(r: u32) -> Weight { - (29_844_000 as Weight) - // Standard Error: 6_000 - .saturating_add((340_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(35_889_773) + // Standard Error: 9_778 + .saturating_add(Weight::from_ref_time(146_925).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/common/src/weights/pallet_grandpa.rs b/runtime/common/src/weights/pallet_grandpa.rs index 52c00e8d1..93c2a162b 100644 --- a/runtime/common/src/weights/pallet_grandpa.rs +++ b/runtime/common/src/weights/pallet_grandpa.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -49,20 +50,20 @@ impl pallet_grandpa::weights::WeightInfo for WeightInfo fn check_equivocation_proof(x: u32, ) -> Weight { - (206_093_000 as Weight) + Weight::from_ref_time(206_093_000) // Standard Error: 82_000 - .saturating_add((33_636_000 as Weight).saturating_mul(x as Weight)) + .saturating_add(Weight::from_ref_time(33_636_000).saturating_mul(x as u64)) } // Storage: Grandpa Stalled (r:0 w:1) fn note_stalled() -> Weight { - (6_440_000 as Weight) + Weight::from_ref_time(6_440_000) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/common/src/weights/pallet_identity.rs b/runtime/common/src/weights/pallet_identity.rs index 633f7700a..15a9426c3 100644 --- a/runtime/common/src/weights/pallet_identity.rs +++ b/runtime/common/src/weights/pallet_identity.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_identity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,162 +51,164 @@ pub struct WeightInfo(PhantomData); impl pallet_identity::weights::WeightInfo for WeightInfo { // Storage: Identity Registrars (r:1 w:1) fn add_registrar(r: u32) -> Weight { - (27_815_000 as Weight) - // Standard Error: 44_000 - .saturating_add((436_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_175_952) + // Standard Error: 6_649 + .saturating_add(Weight::from_ref_time(568_064).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity IdentityOf (r:1 w:1) - fn set_identity(_r: u32, x: u32) -> Weight { - (57_184_000 as Weight) - // Standard Error: 10_000 - .saturating_add((740_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn set_identity(r: u32, x: u32) -> Weight { + Weight::from_ref_time(57_485_137) + // Standard Error: 77_669 + .saturating_add(Weight::from_ref_time(127_536).saturating_mul(r.into())) + // Standard Error: 9_021 + .saturating_add(Weight::from_ref_time(631_202).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:1 w:1) fn set_subs_new(s: u32) -> Weight { - (74_862_000 as Weight) - // Standard Error: 54_000 - .saturating_add((5_540_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + Weight::from_ref_time(53_262_650) + // Standard Error: 28_202 + .saturating_add(Weight::from_ref_time(4_134_551).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:1) fn set_subs_old(p: u32) -> Weight { - (51_247_000 as Weight) - // Standard Error: 35_000 - .saturating_add((2_194_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + Weight::from_ref_time(53_828_418) + // Standard Error: 28_373 + .saturating_add(Weight::from_ref_time(1_739_257).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:64) - fn clear_identity(r: u32, s: u32, x: u32) -> Weight { - (48_392_000 as Weight) - // Standard Error: 563_000 - .saturating_add((1_925_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 32_000 - .saturating_add((2_195_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 32_000 - .saturating_add((365_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn clear_identity(_r: u32, s: u32, x: u32) -> Weight { + Weight::from_ref_time(76_530_218) + // Standard Error: 23_044 + .saturating_add(Weight::from_ref_time(1_760_418).saturating_mul(s.into())) + // Standard Error: 23_044 + .saturating_add(Weight::from_ref_time(123_806).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) fn request_judgement(r: u32, x: u32) -> Weight { - (40_879_000 as Weight) - // Standard Error: 99_000 - .saturating_add((2_118_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 6_000 - .saturating_add((924_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(62_913_188) + // Standard Error: 74_244 + .saturating_add(Weight::from_ref_time(380_051).saturating_mul(r.into())) + // Standard Error: 8_623 + .saturating_add(Weight::from_ref_time(605_729).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity IdentityOf (r:1 w:1) - fn cancel_request(_r: u32, x: u32) -> Weight { - (73_831_000 as Weight) - // Standard Error: 24_000 - .saturating_add((583_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn cancel_request(r: u32, x: u32) -> Weight { + Weight::from_ref_time(55_860_505) + // Standard Error: 178_092 + .saturating_add(Weight::from_ref_time(798_626).saturating_mul(r.into())) + // Standard Error: 20_686 + .saturating_add(Weight::from_ref_time(604_804).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity Registrars (r:1 w:1) fn set_fee(r: u32) -> Weight { - (13_827_000 as Weight) - // Standard Error: 31_000 - .saturating_add((315_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_983_570) + // Standard Error: 4_806 + .saturating_add(Weight::from_ref_time(414_278).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity Registrars (r:1 w:1) fn set_account_id(r: u32) -> Weight { - (13_142_000 as Weight) - // Standard Error: 31_000 - .saturating_add((703_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_397_471) + // Standard Error: 10_158 + .saturating_add(Weight::from_ref_time(425_812).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity Registrars (r:1 w:1) fn set_fields(r: u32) -> Weight { - (15_301_000 as Weight) - // Standard Error: 17_000 - .saturating_add((435_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(18_475_937) + // Standard Error: 8_774 + .saturating_add(Weight::from_ref_time(349_292).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) - fn provide_judgement(r: u32, x: u32) -> Weight { - (48_594_000 as Weight) - // Standard Error: 112_000 - .saturating_add((16_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 6_000 - .saturating_add((678_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn provide_judgement(_r: u32, x: u32) -> Weight { + Weight::from_ref_time(56_036_919) + // Standard Error: 12_666 + .saturating_add(Weight::from_ref_time(861_516).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: Identity SuperOf (r:0 w:64) - fn kill_identity(r: u32, s: u32, _x: u32) -> Weight { - (102_128_000 as Weight) - // Standard Error: 661_000 - .saturating_add((193_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 38_000 - .saturating_add((1_874_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn kill_identity(r: u32, s: u32, x: u32) -> Weight { + Weight::from_ref_time(80_696_476) + // Standard Error: 230_226 + .saturating_add(Weight::from_ref_time(331_035).saturating_mul(r.into())) + // Standard Error: 26_808 + .saturating_add(Weight::from_ref_time(1_739_278).saturating_mul(s.into())) + // Standard Error: 26_808 + .saturating_add(Weight::from_ref_time(279_776).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) fn add_sub(s: u32) -> Weight { - (66_983_000 as Weight) - // Standard Error: 8_000 - .saturating_add((172_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(66_058_206) + // Standard Error: 42_243 + .saturating_add(Weight::from_ref_time(284_963).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) fn rename_sub(s: u32) -> Weight { - (24_681_000 as Weight) - // Standard Error: 10_000 - .saturating_add((104_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(29_854_772) + // Standard Error: 5_414 + .saturating_add(Weight::from_ref_time(96_262).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) fn remove_sub(s: u32) -> Weight { - (63_074_000 as Weight) - // Standard Error: 8_000 - .saturating_add((274_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(72_544_835) + // Standard Error: 13_434 + .saturating_add(Weight::from_ref_time(115_890).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) fn quit_sub(s: u32) -> Weight { - (46_651_000 as Weight) - // Standard Error: 17_000 - .saturating_add((252_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(55_160_250) + // Standard Error: 22_975 + .saturating_add(Weight::from_ref_time(101_585).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/common/src/weights/pallet_membership.rs b/runtime/common/src/weights/pallet_membership.rs index 8c41f7c7d..1f5cfbd3d 100644 --- a/runtime/common/src/weights/pallet_membership.rs +++ b/runtime/common/src/weights/pallet_membership.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_membership //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -53,21 +54,23 @@ impl pallet_membership::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee Members (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn add_member(m: u32) -> Weight { - (29_252_000 as Weight) - // Standard Error: 2_000 - .saturating_add((129_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(45_243_140) + // Standard Error: 6_818 + .saturating_add(Weight::from_ref_time(54_998).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommitteeMembership Members (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:0) // Storage: AdvisoryCommitteeMembership Prime (r:1 w:0) // Storage: AdvisoryCommittee Members (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) - fn remove_member(_m: u32) -> Weight { - (42_627_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn remove_member(m: u32) -> Weight { + Weight::from_ref_time(47_920_741) + // Standard Error: 7_372 + .saturating_add(Weight::from_ref_time(73_246).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommitteeMembership Members (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:0) @@ -75,11 +78,11 @@ impl pallet_membership::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee Members (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn swap_member(m: u32) -> Weight { - (31_151_000 as Weight) - // Standard Error: 1_000 - .saturating_add((199_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(46_793_220) + // Standard Error: 6_935 + .saturating_add(Weight::from_ref_time(114_705).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommitteeMembership Members (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:0) @@ -87,11 +90,11 @@ impl pallet_membership::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee Members (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn reset_member(m: u32) -> Weight { - (33_891_000 as Weight) - // Standard Error: 8_000 - .saturating_add((351_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(53_808_610) + // Standard Error: 14_944 + .saturating_add(Weight::from_ref_time(172_290).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: AdvisoryCommitteeMembership Members (r:1 w:1) // Storage: AdvisoryCommittee Proposals (r:1 w:0) @@ -99,28 +102,28 @@ impl pallet_membership::weights::WeightInfo for WeightI // Storage: AdvisoryCommittee Members (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn change_key(m: u32) -> Weight { - (40_274_000 as Weight) - // Standard Error: 2_000 - .saturating_add((36_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(48_637_357) + // Standard Error: 3_984 + .saturating_add(Weight::from_ref_time(65_363).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: AdvisoryCommitteeMembership Members (r:1 w:0) // Storage: AdvisoryCommitteeMembership Prime (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn set_prime(m: u32) -> Weight { - (8_503_000 as Weight) - // Standard Error: 0 - .saturating_add((67_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(19_740_067) + // Standard Error: 2_839 + .saturating_add(Weight::from_ref_time(4_630).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: AdvisoryCommitteeMembership Prime (r:0 w:1) // Storage: AdvisoryCommittee Prime (r:0 w:1) fn clear_prime(m: u32) -> Weight { - (3_299_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(10_636_405) + // Standard Error: 656 + .saturating_add(Weight::from_ref_time(1_975).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/common/src/weights/pallet_multisig.rs b/runtime/common/src/weights/pallet_multisig.rs index 956a787df..4604eb250 100644 --- a/runtime/common/src/weights/pallet_multisig.rs +++ b/runtime/common/src/weights/pallet_multisig.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_multisig //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -49,101 +50,65 @@ use frame_support::{ pub struct WeightInfo(PhantomData); impl pallet_multisig::weights::WeightInfo for WeightInfo { fn as_multi_threshold_1(z: u32) -> Weight { - (38_915_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) + Weight::from_ref_time(33_725_610) + // Standard Error: 43 + .saturating_add(Weight::from_ref_time(797).saturating_mul(z.into())) } - // Storage: MultiSig Multisigs (r:1 w:1) + // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn as_multi_create(s: u32, z: u32) -> Weight { - (85_862_000 as Weight) - // Standard Error: 15_000 - .saturating_add((208_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(65_276_434) + // Standard Error: 9_980 + .saturating_add(Weight::from_ref_time(167_498).saturating_mul(s.into())) + // Standard Error: 97 + .saturating_add(Weight::from_ref_time(1_882).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - fn as_multi_create_store(s: u32, z: u32) -> Weight { - (73_237_000 as Weight) - // Standard Error: 9_000 - .saturating_add((243_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: MultiSig Multisigs (r:1 w:1) + // Storage: Multisig Multisigs (r:1 w:1) fn as_multi_approve(s: u32, z: u32) -> Weight { - (52_952_000 as Weight) - // Standard Error: 8_000 - .saturating_add((163_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:1) - fn as_multi_approve_store(s: u32, z: u32) -> Weight { - (68_506_000 as Weight) - // Standard Error: 10_000 - .saturating_add((213_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(58_474_334) + // Standard Error: 17_171 + .saturating_add(Weight::from_ref_time(67_702).saturating_mul(s.into())) + // Standard Error: 168 + .saturating_add(Weight::from_ref_time(1_840).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:1) + // Storage: Multisig Multisigs (r:1 w:1) // Storage: System Account (r:1 w:1) fn as_multi_complete(s: u32, z: u32) -> Weight { - (81_537_000 as Weight) - // Standard Error: 13_000 - .saturating_add((460_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(63_745_126) + // Standard Error: 9_505 + .saturating_add(Weight::from_ref_time(218_407).saturating_mul(s.into())) + // Standard Error: 93 + .saturating_add(Weight::from_ref_time(2_283).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: MultiSig Multisigs (r:1 w:1) + // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) fn approve_as_multi_create(s: u32) -> Weight { - (68_980_000 as Weight) - // Standard Error: 10_000 - .saturating_add((211_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(61_096_537) + // Standard Error: 6_788 + .saturating_add(Weight::from_ref_time(112_279).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:0) + // Storage: Multisig Multisigs (r:1 w:1) fn approve_as_multi_approve(s: u32) -> Weight { - (39_761_000 as Weight) - // Standard Error: 9_000 - .saturating_add((296_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:1) - // Storage: System Account (r:1 w:1) - fn approve_as_multi_complete(s: u32) -> Weight { - (121_916_000 as Weight) - // Standard Error: 15_000 - .saturating_add((496_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(44_265_556) + // Standard Error: 9_851 + .saturating_add(Weight::from_ref_time(137_830).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: MultiSig Multisigs (r:1 w:1) - // Storage: MultiSig Calls (r:1 w:1) + // Storage: Multisig Multisigs (r:1 w:1) fn cancel_as_multi(s: u32) -> Weight { - (93_947_000 as Weight) - // Standard Error: 20_000 - .saturating_add((293_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(58_457_156) + // Standard Error: 11_353 + .saturating_add(Weight::from_ref_time(172_491).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_parachain_staking.rs b/runtime/common/src/weights/pallet_parachain_staking.rs index 12b75e0ae..2e63905ea 100644 --- a/runtime/common/src/weights/pallet_parachain_staking.rs +++ b/runtime/common/src/weights/pallet_parachain_staking.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_parachain_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,49 +51,49 @@ pub struct WeightInfo(PhantomData); impl pallet_parachain_staking::weights::WeightInfo for WeightInfo { // Storage: ParachainStaking InflationConfig (r:1 w:1) fn set_staking_expectations() -> Weight { - (30_011_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(35_670_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking InflationConfig (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) fn set_inflation() -> Weight { - (86_350_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(87_440_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking ParachainBondInfo (r:1 w:1) fn set_parachain_bond_account() -> Weight { - (29_470_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(34_790_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking ParachainBondInfo (r:1 w:1) fn set_parachain_bond_reserve_percent() -> Weight { - (31_920_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(33_430_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking TotalSelected (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) fn set_total_selected() -> Weight { - (32_160_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(37_440_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking CollatorCommission (r:1 w:1) fn set_collator_commission() -> Weight { - (31_010_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(32_340_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking Round (r:1 w:1) // Storage: ParachainStaking TotalSelected (r:1 w:0) // Storage: ParachainStaking InflationConfig (r:1 w:1) fn set_blocks_per_round() -> Weight { - (109_270_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(93_860_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking DelegatorState (r:1 w:0) @@ -103,21 +104,21 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: ParachainStaking TopDelegations (r:0 w:1) // Storage: ParachainStaking BottomDelegations (r:0 w:1) fn join_candidates(x: u32) -> Weight { - (176_454_000 as Weight) - // Standard Error: 4_000 - .saturating_add((181_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(123_056_992) + // Standard Error: 3_370 + .saturating_add(Weight::from_ref_time(375_510).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking CandidateInfo (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 { - (142_707_000 as Weight) - // Standard Error: 5_000 - .saturating_add((164_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(116_170_118) + // Standard Error: 4_082 + .saturating_add(Weight::from_ref_time(332_657).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) @@ -126,39 +127,40 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: Balances Locks (r:2 w:2) // Storage: System Account (r:2 w:2) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) // Storage: ParachainStaking BottomDelegations (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_leave_candidates(x: u32) -> Weight { - (0 as Weight) - // Standard Error: 231_000 - .saturating_add((64_246_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(143_510_000) + // Standard Error: 140_714 + .saturating_add(Weight::from_ref_time(42_799_568).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn cancel_leave_candidates(x: u32) -> Weight { - (140_788_000 as Weight) - // Standard Error: 4_000 - .saturating_add((168_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(122_928_231) + // Standard Error: 5_155 + .saturating_add(Weight::from_ref_time(356_447).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_offline() -> Weight { - (42_920_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(70_580_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_online() -> Weight { - (41_760_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(80_801_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -166,16 +168,16 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn candidate_bond_more() -> Weight { - (70_700_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(89_120_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) fn schedule_candidate_bond_less() -> Weight { - (40_220_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(50_400_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) @@ -184,15 +186,15 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn execute_candidate_bond_less() -> Weight { - (72_820_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(100_361_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) fn cancel_candidate_bond_less() -> Weight { - (28_360_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(45_510_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) // Storage: ParachainStaking DelegatorState (r:1 w:1) @@ -202,21 +204,21 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn delegate(x: u32, y: u32) -> Weight { - (275_442_000 as Weight) - // Standard Error: 33_000 - .saturating_add((59_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 11_000 - .saturating_add((281_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(186_651_756) + // Standard Error: 55_002 + .saturating_add(Weight::from_ref_time(867_499).saturating_mul(x.into())) + // Standard Error: 18_044 + .saturating_add(Weight::from_ref_time(553_824).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) fn schedule_leave_delegators() -> Weight { - (50_240_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(56_271_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) @@ -225,31 +227,32 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: ParachainStaking TopDelegations (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn execute_leave_delegators(x: u32) -> Weight { - (0 as Weight) - // Standard Error: 147_000 - .saturating_add((50_946_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(42_497_518) + // Standard Error: 165_856 + .saturating_add(Weight::from_ref_time(35_902_041).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) fn cancel_leave_delegators() -> Weight { - (51_670_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(57_280_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) fn schedule_revoke_delegation() -> Weight { - (57_460_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(68_190_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) // Storage: ParachainStaking DelegatorState (r:1 w:1) @@ -260,31 +263,32 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn delegator_bond_more() -> Weight { - (99_120_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(118_230_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) fn schedule_delegator_bond_less() -> Weight { - (59_450_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(56_290_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) // Storage: ParachainStaking Round (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:0) // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking TopDelegations (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_revoke_delegation() -> Weight { - (120_970_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(145_220_000) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) @@ -296,65 +300,114 @@ impl pallet_parachain_staking::weights::WeightInfo for // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_delegator_bond_less() -> Weight { - (110_711_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(126_790_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) fn cancel_revoke_delegation() -> Weight { - (43_980_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(53_520_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) fn cancel_delegator_bond_less() -> Weight { - (52_200_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(62_760_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: ParachainStaking Round (r:1 w:1) // Storage: ParachainStaking Points (r:1 w:0) - // Storage: ParachainStaking Staked (r:1 w:2) + // Storage: ParachainStaking Staked (r:1 w:1) // Storage: ParachainStaking InflationConfig (r:1 w:0) // Storage: ParachainStaking ParachainBondInfo (r:1 w:0) - // Storage: System Account (r:302 w:301) + // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CollatorCommission (r:1 w:0) + // Storage: ParachainStaking DelayedPayouts (r:0 w:1) + fn prepare_staking_payouts() -> Weight { + Weight::from_ref_time(75_670_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) + // Storage: ParachainStaking TopDelegations (r:1 w:0) + fn get_rewardable_delegators(y: u32) -> Weight { + Weight::from_ref_time(17_681_343) + // Standard Error: 8_876 + .saturating_add(Weight::from_ref_time(502_117).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(2)) + } // Storage: ParachainStaking CandidatePool (r:1 w:0) // Storage: ParachainStaking TotalSelected (r:1 w:0) - // Storage: ParachainStaking CandidateInfo (r:9 w:0) - // Storage: ParachainStaking DelegationScheduledRequests (r:9 w:0) - // Storage: ParachainStaking TopDelegations (r:9 w:0) - // Storage: ParachainStaking Total (r:1 w:0) - // Storage: ParachainStaking AwardedPts (r:2 w:1) - // Storage: ParachainStaking AtStake (r:1 w:10) + // Storage: ParachainStaking CandidateInfo (r:1 w:0) + // Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) + // Storage: ParachainStaking TopDelegations (r:1 w:0) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:0) // Storage: ParachainStaking SelectedCandidates (r:0 w:1) - // Storage: ParachainStaking DelayedPayouts (r:0 w:1) - fn round_transition_on_initialize(x: u32, y: u32) -> Weight { - (0 as Weight) - // Standard Error: 1_511_000 - .saturating_add((90_015_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 5_000 - .saturating_add((550_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(x as Weight))) + // Storage: ParachainStaking AtStake (r:0 w:1) + fn select_top_candidates(x: u32, y: u32) -> Weight { + Weight::from_ref_time(49_680_000) + // Standard Error: 1_177_642 + .saturating_add(Weight::from_ref_time(49_689_789).saturating_mul(x.into())) + // Standard Error: 587_258 + .saturating_add(Weight::from_ref_time(12_322_486).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking DelayedPayouts (r:1 w:0) // Storage: ParachainStaking Points (r:1 w:0) - // Storage: ParachainStaking AwardedPts (r:2 w:1) - // Storage: ParachainStaking AtStake (r:1 w:1) + // Storage: ParachainStaking AtStake (r:2 w:1) + // Storage: ParachainStaking AwardedPts (r:1 w:1) // Storage: System Account (r:1 w:1) fn pay_one_collator_reward(y: u32) -> Weight { - (8_729_000 as Weight) - // Standard Error: 53_000 - .saturating_add((24_974_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(y as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(y as Weight))) + Weight::from_ref_time(106_371_824) + // Standard Error: 93_457 + .saturating_add(Weight::from_ref_time(20_766_401).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) } // Storage: ParachainStaking Round (r:1 w:0) fn base_on_initialize() -> Weight { - (7_010_000 as Weight).saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(16_070_000).saturating_add(T::DbWeight::get().reads(1)) + } + // Storage: ParachainStaking DelegatorState (r:1 w:0) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) + fn set_auto_compound(x: u32, y: u32) -> Weight { + Weight::from_ref_time(130_193_847) + // Standard Error: 11_664 + .saturating_add(Weight::from_ref_time(641_058).saturating_mul(x.into())) + // Standard Error: 34_919 + .saturating_add(Weight::from_ref_time(293_987).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: System Account (r:1 w:1) + // Storage: ParachainStaking DelegatorState (r:1 w:1) + // Storage: ParachainStaking CandidateInfo (r:1 w:1) + // Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) + // Storage: ParachainStaking TopDelegations (r:1 w:1) + // Storage: ParachainStaking CandidatePool (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: ParachainStaking Total (r:1 w:1) + // Storage: ParachainStaking BottomDelegations (r:1 w:1) + fn delegate_with_auto_compound(x: u32, y: u32, _z: u32) -> Weight { + Weight::from_ref_time(332_503_261) + // Standard Error: 12_876 + .saturating_add(Weight::from_ref_time(301_412).saturating_mul(x.into())) + // Standard Error: 12_876 + .saturating_add(Weight::from_ref_time(192_596).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(8)) + } + // Storage: System Account (r:1 w:1) + fn mint_collator_reward() -> Weight { + Weight::from_ref_time(50_240_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_preimage.rs b/runtime/common/src/weights/pallet_preimage.rs index 5f5bbd4c2..dc9c27669 100644 --- a/runtime/common/src/weights/pallet_preimage.rs +++ b/runtime/common/src/weights/pallet_preimage.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_preimage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -48,89 +49,88 @@ use frame_support::{ /// Weight functions for pallet_preimage (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_preimage::weights::WeightInfo for WeightInfo { - // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) fn note_preimage(s: u32) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(52_281_000) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(2_842).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) fn note_requested_preimage(s: u32) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(37_890_000) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(2_843).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) fn note_no_deposit_preimage(s: u32) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(58_020_000) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(2_823).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (90_241_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(85_920_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (68_510_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(70_810_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (95_300_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(65_940_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (72_430_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(45_880_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (47_350_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(42_470_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (22_100_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_660_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (66_950_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(65_070_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (43_790_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(18_540_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (22_570_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_820_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_proxy.rs b/runtime/common/src/weights/pallet_proxy.rs index 3fa33fea5..f5cec07d7 100644 --- a/runtime/common/src/weights/pallet_proxy.rs +++ b/runtime/common/src/weights/pallet_proxy.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_proxy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,92 +51,92 @@ pub struct WeightInfo(PhantomData); impl pallet_proxy::weights::WeightInfo for WeightInfo { // Storage: Proxy Proxies (r:1 w:0) fn proxy(p: u32) -> Weight { - (31_661_000 as Weight) - // Standard Error: 10_000 - .saturating_add((224_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(38_813_017) + // Standard Error: 12_164 + .saturating_add(Weight::from_ref_time(55_828).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) fn proxy_announced(a: u32, p: u32) -> Weight { - (68_434_000 as Weight) - // Standard Error: 39_000 - .saturating_add((265_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 41_000 - .saturating_add((14_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(70_138_051) + // Standard Error: 22_795 + .saturating_add(Weight::from_ref_time(142_027).saturating_mul(a.into())) + // Standard Error: 23_552 + .saturating_add(Weight::from_ref_time(44_496).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) - fn remove_announcement(a: u32, p: u32) -> Weight { - (40_722_000 as Weight) - // Standard Error: 9_000 - .saturating_add((434_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 9_000 - .saturating_add((72_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn remove_announcement(a: u32, _p: u32) -> Weight { + Weight::from_ref_time(52_322_996) + // Standard Error: 23_300 + .saturating_add(Weight::from_ref_time(89_493).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) - fn reject_announcement(a: u32, p: u32) -> Weight { - (44_132_000 as Weight) - // Standard Error: 33_000 - .saturating_add((394_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 34_000 - .saturating_add((62_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn reject_announcement(a: u32, _p: u32) -> Weight { + Weight::from_ref_time(51_337_128) + // Standard Error: 17_654 + .saturating_add(Weight::from_ref_time(102_594).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) - fn announce(a: u32, _p: u32) -> Weight { - (63_543_000 as Weight) - // Standard Error: 40_000 - .saturating_add((356_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn announce(a: u32, p: u32) -> Weight { + Weight::from_ref_time(61_924_058) + // Standard Error: 25_171 + .saturating_add(Weight::from_ref_time(170_865).saturating_mul(a.into())) + // Standard Error: 26_006 + .saturating_add(Weight::from_ref_time(108_550).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Proxy Proxies (r:1 w:1) fn add_proxy(p: u32) -> Weight { - (51_619_000 as Weight) - // Standard Error: 15_000 - .saturating_add((233_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(51_760_535) + // Standard Error: 19_935 + .saturating_add(Weight::from_ref_time(181_482).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxy(p: u32) -> Weight { - (52_529_000 as Weight) - // Standard Error: 9_000 - .saturating_add((212_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(50_793_408) + // Standard Error: 18_245 + .saturating_add(Weight::from_ref_time(229_589).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Proxy Proxies (r:1 w:1) fn remove_proxies(p: u32) -> Weight { - (44_494_000 as Weight) - // Standard Error: 4_000 - .saturating_add((154_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(44_155_777) + // Standard Error: 9_895 + .saturating_add(Weight::from_ref_time(138_340).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) - fn anonymous(_p: u32) -> Weight { - (60_255_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn create_pure(p: u32) -> Weight { + Weight::from_ref_time(55_555_781) + // Standard Error: 6_475 + .saturating_add(Weight::from_ref_time(20_634).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Proxy Proxies (r:1 w:1) - fn kill_anonymous(p: u32) -> Weight { - (44_307_000 as Weight) - // Standard Error: 69_000 - .saturating_add((257_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn kill_pure(p: u32) -> Weight { + Weight::from_ref_time(47_801_082) + // Standard Error: 14_776 + .saturating_add(Weight::from_ref_time(49_907).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_scheduler.rs b/runtime/common/src/weights/pallet_scheduler.rs index ab4c7bf06..798057a53 100644 --- a/runtime/common/src/weights/pallet_scheduler.rs +++ b/runtime/common/src/weights/pallet_scheduler.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_scheduler //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -48,148 +49,78 @@ use frame_support::{ /// Weight functions for pallet_scheduler (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_scheduler::weights::WeightInfo for WeightInfo { - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - fn on_initialize_periodic_named_resolved(s: u32) -> Weight { - (15_878_000 as Weight) - // Standard Error: 544_000 - .saturating_add((41_862_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + // Storage: Scheduler IncompleteSince (r:1 w:1) + fn service_agendas_base() -> Weight { + Weight::from_ref_time(8_730_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - fn on_initialize_named_resolved(s: u32) -> Weight { - (10_252_000 as Weight) - // Standard Error: 440_000 - .saturating_add((32_954_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + fn service_agenda_base(s: u32) -> Weight { + Weight::from_ref_time(16_148_157) + // Standard Error: 15_790 + .saturating_add(Weight::from_ref_time(602_294).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - fn on_initialize_periodic_resolved(s: u32) -> Weight { - (7_473_000 as Weight) - // Standard Error: 161_000 - .saturating_add((35_361_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + fn service_task_base() -> Weight { + Weight::from_ref_time(17_290_000) } - // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) - fn on_initialize_resolved(s: u32) -> Weight { - (0 as Weight) - // Standard Error: 156_000 - .saturating_add((29_887_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + fn service_task_fetched(s: u32) -> Weight { + Weight::from_ref_time(38_440_000) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(2_139).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) - fn on_initialize_named_aborted(s: u32) -> Weight { - (26_628_000 as Weight) - // Standard Error: 60_000 - .saturating_add((11_243_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) - fn on_initialize_aborted(s: u32) -> Weight { - (29_715_000 as Weight) - // Standard Error: 81_000 - .saturating_add((6_070_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn service_task_named() -> Weight { + Weight::from_ref_time(19_870_000).saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:0 w:1) - fn on_initialize_periodic_named(s: u32) -> Weight { - (20_565_000 as Weight) - // Standard Error: 40_000 - .saturating_add((20_118_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + fn service_task_periodic() -> Weight { + Weight::from_ref_time(17_530_000) } - // Storage: Scheduler Agenda (r:2 w:2) - fn on_initialize_periodic(s: u32) -> Weight { - (51_399_000 as Weight) - // Standard Error: 127_000 - .saturating_add((14_763_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn execute_dispatch_signed() -> Weight { + Weight::from_ref_time(8_010_000) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - fn on_initialize_named(s: u32) -> Weight { - (33_895_000 as Weight) - // Standard Error: 57_000 - .saturating_add((11_791_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:1 w:1) - fn on_initialize(s: u32) -> Weight { - (41_957_000 as Weight) - // Standard Error: 109_000 - .saturating_add((9_825_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn execute_dispatch_unsigned() -> Weight { + Weight::from_ref_time(7_960_000) } // Storage: Scheduler Agenda (r:1 w:1) fn schedule(s: u32) -> Weight { - (36_388_000 as Weight) - // Standard Error: 6_000 - .saturating_add((148_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(36_389_558) + // Standard Error: 17_862 + .saturating_add(Weight::from_ref_time(712_217).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) fn cancel(s: u32) -> Weight { - (37_514_000 as Weight) - // Standard Error: 7_000 - .saturating_add((1_101_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_453_612) + // Standard Error: 9_437 + .saturating_add(Weight::from_ref_time(540_810).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) - fn schedule_named(_s: u32) -> Weight { - (48_375_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn schedule_named(s: u32) -> Weight { + Weight::from_ref_time(45_792_369) + // Standard Error: 14_702 + .saturating_add(Weight::from_ref_time(614_083).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn cancel_named(s: u32) -> Weight { - (38_182_000 as Weight) - // Standard Error: 11_000 - .saturating_add((1_045_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(40_577_357) + // Standard Error: 13_678 + .saturating_add(Weight::from_ref_time(632_570).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/common/src/weights/pallet_timestamp.rs b/runtime/common/src/weights/pallet_timestamp.rs index a94214901..61922521d 100644 --- a/runtime/common/src/weights/pallet_timestamp.rs +++ b/runtime/common/src/weights/pallet_timestamp.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -51,11 +52,11 @@ impl pallet_timestamp::weights::WeightInfo for WeightIn // Storage: Timestamp Now (r:1 w:1) // Storage: Aura CurrentSlot (r:1 w:0) fn set() -> Weight { - (19_010_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_880_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } fn on_finalize() -> Weight { - (5_500_000 as Weight) + Weight::from_ref_time(9_280_000) } } diff --git a/runtime/common/src/weights/pallet_treasury.rs b/runtime/common/src/weights/pallet_treasury.rs index 3e646321b..1dd7f7085 100644 --- a/runtime/common/src/weights/pallet_treasury.rs +++ b/runtime/common/src/weights/pallet_treasury.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -49,47 +50,48 @@ use frame_support::{ pub struct WeightInfo(PhantomData); impl pallet_treasury::weights::WeightInfo for WeightInfo { fn spend() -> Weight { - (290_000 as Weight) + Weight::from_ref_time(400_000) } // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn propose_spend() -> Weight { - (46_190_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(50_770_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Treasury Proposals (r:1 w:1) + // Storage: System Account (r:1 w:1) fn reject_proposal() -> Weight { - (58_530_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(72_201_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Treasury Proposals (r:1 w:0) // Storage: Treasury Approvals (r:1 w:1) fn approve_proposal(p: u32) -> Weight { - (22_156_000 as Weight) - // Standard Error: 7_000 - .saturating_add((300_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(26_551_906) + // Standard Error: 6_492 + .saturating_add(Weight::from_ref_time(202_250).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Treasury Approvals (r:1 w:1) fn remove_approval() -> Weight { - (13_870_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(17_980_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) // Storage: Treasury Approvals (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) // Storage: Treasury Proposals (r:2 w:2) fn on_initialize_proposals(p: u32) -> Weight { - (106_923_000 as Weight) - // Standard Error: 370_000 - .saturating_add((56_357_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight))) + Weight::from_ref_time(98_013_908) + // Standard Error: 217_163 + .saturating_add(Weight::from_ref_time(43_828_352).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into()))) } } diff --git a/runtime/common/src/weights/pallet_utility.rs b/runtime/common/src/weights/pallet_utility.rs index dc64b168a..6fd7de5c5 100644 --- a/runtime/common/src/weights/pallet_utility.rs +++ b/runtime/common/src/weights/pallet_utility.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_utility //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -49,24 +50,24 @@ use frame_support::{ pub struct WeightInfo(PhantomData); impl pallet_utility::weights::WeightInfo for WeightInfo { fn batch(c: u32) -> Weight { - (40_987_000 as Weight) - // Standard Error: 18_000 - .saturating_add((5_614_000 as Weight).saturating_mul(c as Weight)) + Weight::from_ref_time(70_569_638) + // Standard Error: 21_128 + .saturating_add(Weight::from_ref_time(5_949_586).saturating_mul(c.into())) } fn as_derivative() -> Weight { - (8_160_000 as Weight) + Weight::from_ref_time(12_090_000) } fn batch_all(c: u32) -> Weight { - (89_220_000 as Weight) - // Standard Error: 52_000 - .saturating_add((5_803_000 as Weight).saturating_mul(c as Weight)) + Weight::from_ref_time(127_200_010) + // Standard Error: 19_602 + .saturating_add(Weight::from_ref_time(6_038_335).saturating_mul(c.into())) } fn dispatch_as() -> Weight { - (24_700_000 as Weight) + Weight::from_ref_time(26_170_000) } fn force_batch(c: u32) -> Weight { - (69_293_000 as Weight) - // Standard Error: 46_000 - .saturating_add((5_611_000 as Weight).saturating_mul(c as Weight)) + Weight::from_ref_time(132_350_384) + // Standard Error: 46_795 + .saturating_add(Weight::from_ref_time(5_920_953).saturating_mul(c.into())) } } diff --git a/runtime/common/src/weights/pallet_vesting.rs b/runtime/common/src/weights/pallet_vesting.rs index df746fda3..7bd556993 100644 --- a/runtime/common/src/weights/pallet_vesting.rs +++ b/runtime/common/src/weights/pallet_vesting.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for pallet_vesting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -51,89 +52,87 @@ impl pallet_vesting::weights::WeightInfo for WeightInfo // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_locked(l: u32, s: u32) -> Weight { - (64_180_000 as Weight) - // Standard Error: 22_000 - .saturating_add((68_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 46_000 - .saturating_add((202_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(63_395_103) + // Standard Error: 14_913 + .saturating_add(Weight::from_ref_time(107_241).saturating_mul(l.into())) + // Standard Error: 26_533 + .saturating_add(Weight::from_ref_time(239_493).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vest_unlocked(l: u32, s: u32) -> Weight { - (61_117_000 as Weight) - // Standard Error: 21_000 - .saturating_add((77_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 43_000 - .saturating_add((274_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(67_323_157) + // Standard Error: 19_777 + .saturating_add(Weight::from_ref_time(17_873).saturating_mul(l.into())) + // Standard Error: 35_187 + .saturating_add(Weight::from_ref_time(74_060).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) - fn vest_other_locked(l: u32, _s: u32) -> Weight { - (71_338_000 as Weight) - // Standard Error: 21_000 - .saturating_add((99_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vest_other_locked(l: u32, s: u32) -> Weight { + Weight::from_ref_time(61_323_796) + // Standard Error: 13_176 + .saturating_add(Weight::from_ref_time(156_287).saturating_mul(l.into())) + // Standard Error: 23_442 + .saturating_add(Weight::from_ref_time(131_222).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) fn vest_other_unlocked(_l: u32, s: u32) -> Weight { - (62_952_000 as Weight) - // Standard Error: 65_000 - .saturating_add((500_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(66_740_069) + // Standard Error: 29_462 + .saturating_add(Weight::from_ref_time(76_715).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vested_transfer(l: u32, s: u32) -> Weight { - (79_913_000 as Weight) - // Standard Error: 24_000 - .saturating_add((206_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 49_000 - .saturating_add((535_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(94_575_564) + // Standard Error: 23_761 + .saturating_add(Weight::from_ref_time(16_361).saturating_mul(l.into())) + // Standard Error: 42_276 + .saturating_add(Weight::from_ref_time(51_945).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: Balances Locks (r:1 w:1) - fn force_vested_transfer(l: u32, s: u32) -> Weight { - (78_857_000 as Weight) - // Standard Error: 67_000 - .saturating_add((223_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 137_000 - .saturating_add((808_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + fn force_vested_transfer(l: u32, _s: u32) -> Weight { + Weight::from_ref_time(94_393_009) + // Standard Error: 19_791 + .saturating_add(Weight::from_ref_time(25_067).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn not_unlocking_merge_schedules(l: u32, s: u32) -> Weight { - (59_290_000 as Weight) - // Standard Error: 25_000 - .saturating_add((249_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 54_000 - .saturating_add((207_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(65_727_968) + // Standard Error: 16_052 + .saturating_add(Weight::from_ref_time(127_569).saturating_mul(l.into())) + // Standard Error: 29_644 + .saturating_add(Weight::from_ref_time(131_874).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - fn unlocking_merge_schedules(l: u32, s: u32) -> Weight { - (50_783_000 as Weight) - // Standard Error: 20_000 - .saturating_add((247_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 43_000 - .saturating_add((584_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn unlocking_merge_schedules(l: u32, _s: u32) -> Weight { + Weight::from_ref_time(70_624_103) + // Standard Error: 19_352 + .saturating_add(Weight::from_ref_time(55_943).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/zeitgeist/Cargo.toml b/runtime/zeitgeist/Cargo.toml index d4662ef96..b50e159ef 100644 --- a/runtime/zeitgeist/Cargo.toml +++ b/runtime/zeitgeist/Cargo.toml @@ -1,100 +1,105 @@ [build-dependencies] -substrate-wasm-builder = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +substrate-wasm-builder = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } [dependencies] -frame-executive = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system-rpc-runtime-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-currencies = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } -pallet-balances = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-bounties = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-collective = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-democracy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-identity = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-membership = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-multisig = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-preimage = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-proxy = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-randomness-collective-flip = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-scheduler = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-treasury = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-utility = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-vesting = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-executive = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system-rpc-runtime-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-currencies = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +pallet-balances = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-bounties = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-collective = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-contracts-primitives = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-democracy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-identity = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-membership = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-multisig = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-preimage = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-proxy = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-randomness-collective-flip = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-scheduler = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-transaction-payment-rpc-runtime-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-treasury = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-utility = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-vesting = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } +polkadot-primitives = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-block-builder = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-inherents = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-offchain = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-session = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-transaction-pool = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-version = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-block-builder = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-inherents = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-offchain = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-session = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-std = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-transaction-pool = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-version = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } substrate-fixed = { default-features = false, features = ["serde"], git = "https://github.com/encointer/substrate-fixed" } # Try-Runtime -frame-try-runtime = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-try-runtime = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } # Benchmark -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } -frame-system-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +frame-system-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } # Cumulus -cumulus-pallet-dmp-queue = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-parachain-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-xcm = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -cumulus-primitives-utility = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } -parachain-info = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-dmp-queue = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-parachain-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-xcm = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-pallet-xcmp-queue = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +cumulus-primitives-utility = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } +parachain-info = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/cumulus", optional = true } # Parachain -nimbus-primitives = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-inherent = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-author-mapping = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -pallet-author-slot-filter = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/nimbus", optional = true } -pallet-crowdloan-rewards = { branch = "moonbeam-polkadot-v0.9.26", default-features = false, git = "https://github.com/purestake/crowdloan-rewards", optional = true } -pallet-parachain-staking = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } -polkadot-parachain = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -session-keys-primitives = { tag = "v0.26.1", default-features = false, git = "https://github.com/purestake/moonbeam", optional = true } +nimbus-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-inherent = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-mapping = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-author-slot-filter = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +pallet-parachain-staking = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } +session-keys-primitives = { default-features = false, git = "https://github.com/zeitgeistpm/external", optional = true } + +# Polkadot + +polkadot-parachain = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } # Standalone -pallet-aura = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -pallet-grandpa = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-consensus-aura = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-finality-grandpa = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-aura = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +pallet-grandpa = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-consensus-aura = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-finality-grandpa = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } # Utility cfg-if = { version = "1.0.0" } hex-literal = { default-features = false, optional = true, version = "0.3.4" } -log = { version = "0.4.17", default-features = false, optional = true } +log = { version = "0.4.18", default-features = false, optional = true } # XCM -kusama-runtime = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -orml-asset-registry = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-unknown-tokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-xcm-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-xtokens = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -pallet-xcm = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-primitives = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -polkadot-runtime-parachains = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm-builder = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } -xcm-executor = { branch = "release-v0.9.26", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +orml-asset-registry = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-unknown-tokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-xcm-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-xtokens = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +pallet-xcm = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-runtime = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +polkadot-runtime-parachains = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm-builder = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } +xcm-executor = { branch = "release-v0.9.32", default-features = false, git = "https://github.com/paritytech/polkadot", optional = true } # Zeitgeist @@ -113,12 +118,14 @@ zrml-swaps = { default-features = false, path = "../../zrml/swaps" } zrml-swaps-runtime-api = { default-features = false, path = "../../zrml/swaps/runtime-api" } [dev-dependencies] -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -xcm-emulator = { rev = "ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe", git = "https://github.com/shaunxw/xcm-simulator" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +test-case = "2.0.2" +xcm-emulator = { rev = "158a6bd2768c679563efa891aa17329635b2764b", git = "https://github.com/shaunxw/xcm-simulator" } [features] default = ["std"] parachain = [ + "zrml-prediction-markets/parachain", # Cumulus "cumulus-pallet-dmp-queue", @@ -136,15 +143,13 @@ parachain = [ "pallet-author-inherent", "pallet-author-mapping", "pallet-author-slot-filter", - "pallet-crowdloan-rewards", "pallet-parachain-staking", "polkadot-parachain", "session-keys-primitives", # XCM - "kusama-runtime", - "polkadot-primitives", + "polkadot-runtime", "polkadot-runtime-parachains", "orml-asset-registry", "orml-unknown-tokens", @@ -165,10 +170,10 @@ runtime-benchmarks = [ "cumulus-pallet-xcmp-queue?/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", - "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "hex-literal", - "kusama-runtime?/runtime-benchmarks", + "polkadot-runtime?/runtime-benchmarks", "orml-asset-registry?/runtime-benchmarks", "orml-tokens/runtime-benchmarks", "orml-xtokens?/runtime-benchmarks", @@ -179,7 +184,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", - "pallet-crowdloan-rewards?/runtime-benchmarks", + "pallet-contracts/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-identity/runtime-benchmarks", @@ -220,6 +225,8 @@ std = [ "pallet-balances/std", "pallet-bounties/std", "pallet-collective/std", + "pallet-contracts/std", + "pallet-contracts-primitives/std", "pallet-democracy/std", "pallet-identity/std", "pallet-membership/std", @@ -235,6 +242,7 @@ std = [ "pallet-utility/std", "pallet-vesting/std", "parity-scale-codec/std", + "polkadot-primitives/std", "scale-info/std", "sp-api/std", "sp-block-builder/std", @@ -272,14 +280,12 @@ std = [ "pallet-author-inherent?/std", "pallet-author-mapping?/std", "pallet-author-slot-filter?/std", - "pallet-crowdloan-rewards?/std", "pallet-parachain-staking?/std", "session-keys-primitives?/std", # XCM - "kusama-runtime?/std", - "polkadot-primitives?/std", + "polkadot-runtime?/std", "polkadot-runtime-parachains?/std", "orml-asset-registry?/std", "orml-unknown-tokens?/std", @@ -319,6 +325,7 @@ try-runtime = [ # For every pallet in the runtime include try-runtime # System runtime pallets + "frame-support/try-runtime", "frame-system/try-runtime", "pallet-timestamp/try-runtime", "pallet-randomness-collective-flip/try-runtime", @@ -339,6 +346,7 @@ try-runtime = [ "pallet-membership/try-runtime", # Other Parity runtime pallets + "pallet-contracts/try-runtime", "pallet-identity/try-runtime", "pallet-utility/try-runtime", @@ -363,10 +371,22 @@ try-runtime = [ # Parachain "pallet-author-mapping?/try-runtime", + "pallet-author-inherent?/try-runtime", "pallet-author-slot-filter?/try-runtime", "pallet-parachain-staking?/try-runtime", # Required by pallet-parachain-staking@v0.26.1 "parity-scale-codec/full", + "pallet-proxy/try-runtime", + "pallet-grandpa/try-runtime", + "pallet-aura/try-runtime", + "pallet-xcm/try-runtime", + # Cumulus + + "cumulus-pallet-dmp-queue?/try-runtime", + "cumulus-pallet-parachain-system?/try-runtime", + "cumulus-pallet-xcm?/try-runtime", + "cumulus-pallet-xcmp-queue?/try-runtime", + "parachain-info?/try-runtime", ] with-global-disputes = [ "zrml-global-disputes", @@ -378,7 +398,7 @@ with-global-disputes = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zeitgeist-runtime" -version = "0.3.7" +version = "0.3.9" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/runtime/zeitgeist/src/integration_tests/mod.rs b/runtime/zeitgeist/src/integration_tests/mod.rs index 64f89683b..31216c4f4 100644 --- a/runtime/zeitgeist/src/integration_tests/mod.rs +++ b/runtime/zeitgeist/src/integration_tests/mod.rs @@ -1,4 +1,5 @@ // Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it diff --git a/runtime/zeitgeist/src/integration_tests/xcm/mod.rs b/runtime/zeitgeist/src/integration_tests/xcm/mod.rs index d2226363f..d37a62036 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/mod.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/mod.rs @@ -1,4 +1,5 @@ // Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it diff --git a/runtime/zeitgeist/src/integration_tests/xcm/setup.rs b/runtime/zeitgeist/src/integration_tests/xcm/setup.rs index e3da82f91..aa717bf53 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/setup.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/setup.rs @@ -1,5 +1,5 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021 Centrifuge Foundation (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -17,19 +17,18 @@ // along with Zeitgeist. If not, see . use crate::{ - xcm_config::{ - asset_registry::CustomMetadata, - config::{general_key, zeitgeist}, - }, - AccountId, AssetRegistry, Balance, CurrencyId, ExistentialDeposit, Origin, Runtime, System, + xcm_config::config::{general_key, zeitgeist}, + AccountId, AssetRegistry, Balance, CurrencyId, ExistentialDeposit, Runtime, RuntimeOrigin, + System, }; use frame_support::{assert_ok, traits::GenesisBuild}; use orml_traits::asset_registry::AssetMetadata; +use sp_runtime::AccountId32; use xcm::{ latest::{Junction::Parachain, Junctions::X2, MultiLocation}, VersionedMultiLocation, }; -use zeitgeist_primitives::types::Asset; +use zeitgeist_primitives::types::{Asset, CustomMetadata}; pub(super) struct ExtBuilder { balances: Vec<(AccountId, CurrencyId, Balance)>, @@ -97,8 +96,8 @@ impl ExtBuilder { } /// Accounts -pub const ALICE: [u8; 32] = [4u8; 32]; -pub const BOB: [u8; 32] = [5u8; 32]; +pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]); +pub const BOB: AccountId32 = AccountId32::new([1u8; 32]); /// A PARA ID used for a sibling parachain. /// It must be one that doesn't collide with any other in use. @@ -136,7 +135,7 @@ pub(super) fn register_foreign_ztg(additional_meta: Option) { additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_ZTG_ID))); + assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), meta, Some(FOREIGN_ZTG_ID))); } pub(super) fn register_foreign_sibling(additional_meta: Option) { @@ -150,21 +149,25 @@ pub(super) fn register_foreign_sibling(additional_meta: Option) additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_SIBLING_ID))); + assert_ok!(AssetRegistry::register_asset( + RuntimeOrigin::root(), + meta, + Some(FOREIGN_SIBLING_ID) + )); } pub(super) fn register_foreign_parent(additional_meta: Option) { - // Register KSM as foreign asset in the sibling parachain + // Register dot as foreign asset in the sibling parachain let meta: AssetMetadata = AssetMetadata { - decimals: 12, - name: "Kusama".into(), - symbol: "KSM".into(), - existential_deposit: 10_000_000_000, // 0.01 + decimals: 10, + name: "Polkadot".into(), + symbol: "DOT".into(), + existential_deposit: 10_000_000_000, // 1 location: Some(VersionedMultiLocation::V1(foreign_parent_multilocation())), additional: additional_meta.unwrap_or_default(), }; - assert_ok!(AssetRegistry::register_asset(Origin::root(), meta, Some(FOREIGN_PARENT_ID))); + assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), meta, Some(FOREIGN_PARENT_ID))); } #[inline] @@ -173,8 +176,8 @@ pub(super) fn ztg(amount: Balance) -> Balance { } #[inline] -pub(super) fn ksm(amount: Balance) -> Balance { - foreign(amount, 12) +pub(super) fn dot(amount: Balance) -> Balance { + foreign(amount, 10) } #[inline] diff --git a/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs b/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs index ead4ca132..050527635 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs @@ -1,5 +1,6 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Centrifuge GmbH (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. +// // This file is part of Zeitgeist. // // Zeitgeist is free software: you can redistribute it and/or modify it @@ -16,20 +17,20 @@ // along with Zeitgeist. If not, see . use crate::{ - parameters::ZeitgeistTreasuryAccount, xcm_config::config::zeitgeist, AccountId, CurrencyId, - DmpQueue, Origin, Runtime, XcmpQueue, + parameters::ZeitgeistTreasuryAccount, xcm_config::config::zeitgeist, CurrencyId, DmpQueue, + Runtime, RuntimeOrigin, XcmpQueue, }; use frame_support::{traits::GenesisBuild, weights::Weight}; use polkadot_primitives::v2::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; use xcm_emulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain}; -use super::setup::{ksm, ztg, ExtBuilder, ALICE, FOREIGN_PARENT_ID, PARA_ID_SIBLING}; +use super::setup::{dot, ztg, ExtBuilder, ALICE, FOREIGN_PARENT_ID, PARA_ID_SIBLING}; decl_test_relay_chain! { - pub struct KusamaNet { - Runtime = kusama_runtime::Runtime, - XcmConfig = kusama_runtime::xcm_config::XcmConfig, + pub struct PolkadotNet { + Runtime = polkadot_runtime::Runtime, + XcmConfig = polkadot_runtime::xcm_config::XcmConfig, new_ext = relay_ext(), } } @@ -37,7 +38,7 @@ decl_test_relay_chain! { decl_test_parachain! { pub struct Zeitgeist { Runtime = Runtime, - Origin = Origin, + RuntimeOrigin = RuntimeOrigin, XcmpMessageHandler = XcmpQueue, DmpMessageHandler = DmpQueue, new_ext = para_ext(zeitgeist::ID), @@ -47,7 +48,7 @@ decl_test_parachain! { decl_test_parachain! { pub struct Sibling { Runtime = Runtime, - Origin = Origin, + RuntimeOrigin = RuntimeOrigin, XcmpMessageHandler = XcmpQueue, DmpMessageHandler = DmpQueue, new_ext = para_ext(PARA_ID_SIBLING), @@ -56,13 +57,13 @@ decl_test_parachain! { decl_test_network! { pub struct TestNet { - relay_chain = KusamaNet, + relay_chain = PolkadotNet, parachains = vec![ // N.B: Ideally, we could use the defined para id constants but doing so // fails with: "error: arbitrary expressions aren't allowed in patterns" // Be sure to use `xcm_config::config::zeitgeist::ID` - (2101, Zeitgeist), + (2092, Zeitgeist), // Be sure to use `PARA_ID_SIBLING` (3000, Sibling), ], @@ -70,15 +71,13 @@ decl_test_network! { } pub(super) fn relay_ext() -> sp_io::TestExternalities { - use kusama_runtime::{Runtime, System}; + use polkadot_runtime::{Runtime, System}; let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { - balances: vec![(AccountId::from(ALICE), ksm(2002))], - } - .assimilate_storage(&mut t) - .unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(ALICE, dot(2002))] } + .assimilate_storage(&mut t) + .unwrap(); polkadot_runtime_parachains::configuration::GenesisConfig:: { config: default_parachains_host_configuration(), @@ -100,9 +99,9 @@ pub(super) fn relay_ext() -> sp_io::TestExternalities { pub(super) fn para_ext(parachain_id: u32) -> sp_io::TestExternalities { ExtBuilder::default() .set_balances(vec![ - (AccountId::from(ALICE), CurrencyId::Ztg, ztg(10)), - (AccountId::from(ALICE), FOREIGN_PARENT_ID, ksm(10)), - (ZeitgeistTreasuryAccount::get(), FOREIGN_PARENT_ID, ksm(1)), + (ALICE, CurrencyId::Ztg, ztg(10)), + (ALICE, FOREIGN_PARENT_ID, dot(10)), + (ZeitgeistTreasuryAccount::get(), FOREIGN_PARENT_ID, dot(10)), ]) .set_parachain_id(parachain_id) .build() @@ -123,7 +122,7 @@ fn default_parachains_host_configuration() -> HostConfiguration { max_upward_queue_count: 8, max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024, - ump_service_total_weight: Weight::from(4 * 1_000_000_000u32), + ump_service_total_weight: Weight::from_ref_time(4_u64 * 1_000_000_000_u64), max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, diff --git a/runtime/zeitgeist/src/integration_tests/xcm/tests/currency_id_convert.rs b/runtime/zeitgeist/src/integration_tests/xcm/tests/currency_id_convert.rs index 757e13be5..0737250aa 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/tests/currency_id_convert.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/tests/currency_id_convert.rs @@ -1,5 +1,5 @@ -// Copyright 2021 Centrifuge Foundation (centrifuge.io). // Copyright 2022 Forecasting Technologies LTD. +// Copyright 2021 Centrifuge Foundation (centrifuge.io). // // This file is part of Zeitgeist. // diff --git a/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs b/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs index 25543b4e1..bf17fc2a0 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs @@ -1,5 +1,5 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021 Centrifuge Foundation (centrifuge.io). -// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -19,18 +19,14 @@ use crate::{ integration_tests::xcm::{ setup::{ - ksm, register_foreign_parent, register_foreign_ztg, sibling_parachain_account, + dot, register_foreign_parent, register_foreign_ztg, sibling_parachain_account, zeitgeist_parachain_account, ztg, ALICE, BOB, FOREIGN_PARENT_ID, FOREIGN_ZTG_ID, PARA_ID_SIBLING, }, - test_net::{KusamaNet, Sibling, TestNet, Zeitgeist}, + test_net::{PolkadotNet, Sibling, TestNet, Zeitgeist}, }, - xcm_config::{ - asset_registry::{CustomMetadata, XcmMetadata}, - config::zeitgeist, - fees::default_per_second, - }, - AssetRegistry, Balance, Balances, CurrencyId, Origin, Tokens, XTokens, + xcm_config::{config::zeitgeist, fees::default_per_second}, + AssetRegistry, Balance, Balances, CurrencyId, RuntimeOrigin, Tokens, XTokens, ZeitgeistTreasuryAccount, }; @@ -38,7 +34,10 @@ use frame_support::assert_ok; use orml_traits::MultiCurrency; use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, NetworkId}; use xcm_emulator::TestExt; -use zeitgeist_primitives::constants::BalanceFractionalDecimals; +use zeitgeist_primitives::{ + constants::BalanceFractionalDecimals, + types::{CustomMetadata, XcmMetadata}, +}; #[test] fn transfer_ztg_to_sibling() { @@ -51,15 +50,15 @@ fn transfer_ztg_to_sibling() { Sibling::execute_with(|| { treasury_initial_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), 0); register_foreign_ztg(None); }); Zeitgeist::execute_with(|| { - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); - assert_eq!(Balances::free_balance(&sibling_parachain_account()), 0); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); + assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), CurrencyId::Ztg, transfer_amount, Box::new( @@ -67,23 +66,23 @@ fn transfer_ztg_to_sibling() { 1, X2( Parachain(PARA_ID_SIBLING), - Junction::AccountId32 { network: NetworkId::Any, id: BOB } + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Alice's balance is initial_balance - amount_transferred - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance - transfer_amount); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance - transfer_amount); // Verify that the amount transferred is now part of the sibling account here - assert_eq!(Balances::free_balance(&sibling_parachain_account()), transfer_amount); + assert_eq!(Balances::free_balance(sibling_parachain_account()), transfer_amount); }); Sibling::execute_with(|| { - let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()); + let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB); // Verify that BOB now has (amount transferred - fee) assert_eq!(current_balance, transfer_amount - ztg_fee()); @@ -118,18 +117,18 @@ fn transfer_ztg_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { treasury_initial_balance = Balances::free_balance(ZeitgeistTreasuryAccount::get()); - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); assert_eq!( - Balances::free_balance(&sibling_parachain_account()), + Balances::free_balance(sibling_parachain_account()), sibling_sovereign_initial_balance ); }); Sibling::execute_with(|| { - assert_eq!(Balances::free_balance(&zeitgeist_parachain_account()), 0); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), bob_initial_balance); + assert_eq!(Balances::free_balance(zeitgeist_parachain_account()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), bob_initial_balance); assert_ok!(XTokens::transfer( - Origin::signed(BOB.into()), + RuntimeOrigin::signed(BOB), FOREIGN_ZTG_ID, transfer_amount, Box::new( @@ -137,17 +136,17 @@ fn transfer_ztg_sibling_to_zeitgeist() { 1, X2( Parachain(zeitgeist::ID), - Junction::AccountId32 { network: NetworkId::Any, id: ALICE } + Junction::AccountId32 { network: NetworkId::Any, id: ALICE.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Bobs's balance is initial balance - amount transferred assert_eq!( - Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), + Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), bob_initial_balance - transfer_amount ); }); @@ -155,13 +154,13 @@ fn transfer_ztg_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { // Verify that ALICE now has initial balance + amount transferred - fee assert_eq!( - Balances::free_balance(&ALICE.into()), + Balances::free_balance(&ALICE), alice_initial_balance + transfer_amount - ztg_fee(), ); // Verify that the reserve has been adjusted properly assert_eq!( - Balances::free_balance(&sibling_parachain_account()), + Balances::free_balance(sibling_parachain_account()), sibling_sovereign_initial_balance - transfer_amount ); @@ -174,69 +173,68 @@ fn transfer_ztg_sibling_to_zeitgeist() { } #[test] -fn transfer_ksm_from_relay_chain() { +fn transfer_dot_from_relay_chain() { TestNet::reset(); - let transfer_amount: Balance = ksm(1); + let transfer_amount: Balance = dot(2); Zeitgeist::execute_with(|| { register_foreign_parent(None); }); - KusamaNet::execute_with(|| { - let initial_balance = kusama_runtime::Balances::free_balance(&ALICE.into()); + PolkadotNet::execute_with(|| { + let initial_balance = polkadot_runtime::Balances::free_balance(&ALICE); assert!(initial_balance >= transfer_amount); - assert_ok!(kusama_runtime::XcmPallet::reserve_transfer_assets( - kusama_runtime::Origin::signed(ALICE.into()), + assert_ok!(polkadot_runtime::XcmPallet::reserve_transfer_assets( + polkadot_runtime::RuntimeOrigin::signed(ALICE), Box::new(Parachain(zeitgeist::ID).into().into()), - Box::new(Junction::AccountId32 { network: NetworkId::Any, id: BOB }.into().into()), + Box::new( + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() }.into().into() + ), Box::new((Here, transfer_amount).into()), 0 )); }); Zeitgeist::execute_with(|| { - assert_eq!( - Tokens::free_balance(FOREIGN_PARENT_ID, &BOB.into()), - transfer_amount - ksm_fee() - ); + assert_eq!(Tokens::free_balance(FOREIGN_PARENT_ID, &BOB), transfer_amount - dot_fee()); }); } #[test] -fn transfer_ksm_to_relay_chain() { +fn transfer_dot_to_relay_chain() { TestNet::reset(); - let transfer_amount: Balance = ksm(1); - transfer_ksm_from_relay_chain(); + let transfer_amount: Balance = dot(2); + transfer_dot_from_relay_chain(); Zeitgeist::execute_with(|| { - let initial_balance = Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE.into()); + let initial_balance = Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE); assert!(initial_balance >= transfer_amount); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), FOREIGN_PARENT_ID, transfer_amount, Box::new( MultiLocation::new( 1, - X1(Junction::AccountId32 { id: BOB, network: NetworkId::Any }) + X1(Junction::AccountId32 { id: BOB.into(), network: NetworkId::Any }) ) .into() ), - 4_000_000_000 + xcm_emulator::Limited(4_000_000_000) )); assert_eq!( - Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE.into()), + Tokens::free_balance(FOREIGN_PARENT_ID, &ALICE), initial_balance - transfer_amount ) }); - KusamaNet::execute_with(|| { - assert_eq!(kusama_runtime::Balances::free_balance(&BOB.into()), 999_988_476_752); + PolkadotNet::execute_with(|| { + assert_eq!(polkadot_runtime::Balances::free_balance(&BOB), 19_573_469_824); }); } @@ -253,7 +251,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { Sibling::execute_with(|| { treasury_initial_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); - assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()), 0); + assert_eq!(Tokens::free_balance(FOREIGN_ZTG_ID, &BOB), 0); register_foreign_ztg(None); let custom_metadata = CustomMetadata { @@ -272,10 +270,10 @@ fn transfer_ztg_to_sibling_with_custom_fee() { }); Zeitgeist::execute_with(|| { - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance); - assert_eq!(Balances::free_balance(&sibling_parachain_account()), 0); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance); + assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( - Origin::signed(ALICE.into()), + RuntimeOrigin::signed(ALICE), CurrencyId::Ztg, transfer_amount, Box::new( @@ -283,23 +281,23 @@ fn transfer_ztg_to_sibling_with_custom_fee() { 1, X2( Parachain(PARA_ID_SIBLING), - Junction::AccountId32 { network: NetworkId::Any, id: BOB } + Junction::AccountId32 { network: NetworkId::Any, id: BOB.into() } ) ) .into() ), - 4_000_000_000, + xcm_emulator::Limited(4_000_000_000), )); // Confirm that Alice's balance is initial_balance - amount_transferred - assert_eq!(Balances::free_balance(&ALICE.into()), alice_initial_balance - transfer_amount); + assert_eq!(Balances::free_balance(&ALICE), alice_initial_balance - transfer_amount); // Verify that the amount transferred is now part of the sibling account here - assert_eq!(Balances::free_balance(&sibling_parachain_account()), transfer_amount); + assert_eq!(Balances::free_balance(sibling_parachain_account()), transfer_amount); }); Sibling::execute_with(|| { - let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB.into()); + let current_balance = Tokens::free_balance(FOREIGN_ZTG_ID, &BOB); let custom_fee = calc_fee(default_per_second(10) * 10); // Verify that BOB now has (amount transferred - fee) @@ -319,7 +317,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { #[test] fn test_total_fee() { assert_eq!(ztg_fee(), 92_696_000); - assert_eq!(ksm_fee(), 9_269_600_000); + assert_eq!(dot_fee(), 92_696_000); } #[inline] @@ -332,10 +330,10 @@ fn fee(decimals: u32) -> Balance { calc_fee(default_per_second(decimals)) } -// The fee associated with transferring KSM tokens +// The fee associated with transferring dot tokens #[inline] -fn ksm_fee() -> Balance { - fee(12) +fn dot_fee() -> Balance { + fee(10) } #[inline] diff --git a/runtime/zeitgeist/src/lib.rs b/runtime/zeitgeist/src/lib.rs index d7dabfa85..66b965fe2 100644 --- a/runtime/zeitgeist/src/lib.rs +++ b/runtime/zeitgeist/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -33,6 +34,7 @@ pub use frame_system::{ }; #[cfg(feature = "parachain")] pub use pallet_author_slot_filter::EligibilityValue; +pub use pallet_balances::Call as BalancesCall; #[cfg(feature = "parachain")] pub use crate::parachain_params::*; @@ -40,12 +42,15 @@ pub use crate::parameters::*; use alloc::vec; use frame_support::{ traits::{ConstU16, ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter}, - weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee}, + weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight}, }; use frame_system::EnsureRoot; -use pallet_collective::{EnsureProportionAtLeast, PrimeDefaultVote}; +use pallet_collective::{EnsureProportionAtLeast, EnsureProportionMoreThan, PrimeDefaultVote}; use pallet_transaction_payment::ChargeTransactionPayment; -use sp_runtime::traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}; +use sp_runtime::{ + traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}, + DispatchError, +}; #[cfg(feature = "std")] use sp_version::NativeVersion; use substrate_fixed::{types::extra::U33, FixedI128, FixedU128}; @@ -54,10 +59,9 @@ use zrml_rikiddo::types::{EmaMarketVolume, FeeSigmoid, RikiddoSigmoidMV}; #[cfg(feature = "parachain")] use { frame_support::traits::{AsEnsureOriginWithArg, Everything, Nothing}, - frame_system::EnsureSigned, xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, LocationInverter}, xcm_config::{ - asset_registry::{CustomAssetProcessor, CustomMetadata}, + asset_registry::CustomAssetProcessor, config::{LocalOriginToLocation, XcmConfig, XcmOriginToTransactDispatchOrigin, XcmRouter}, }, }; @@ -74,7 +78,7 @@ use sp_runtime::{ }; #[cfg(feature = "parachain")] -use nimbus_primitives::{CanAuthor, NimbusId}; +use nimbus_primitives::CanAuthor; use sp_version::RuntimeVersion; #[cfg(test)] @@ -89,10 +93,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("zeitgeist"), impl_name: create_runtime_str!("zeitgeist"), authoring_version: 1, - spec_version: 41, + spec_version: 46, impl_version: 1, apis: RUNTIME_API_VERSIONS, - transaction_version: 18, + transaction_version: 21, state_version: 1, }; @@ -101,8 +105,8 @@ pub struct IsCallable; // Currently disables Court, Rikiddo and creation of markets using Court or SimpleDisputes // dispute mechanism. -impl Contains for IsCallable { - fn contains(call: &Call) -> bool { +impl Contains for IsCallable { + fn contains(runtime_call: &RuntimeCall) -> bool { #[cfg(feature = "parachain")] use cumulus_pallet_dmp_queue::Call::service_overweight; use frame_system::Call::{ @@ -111,6 +115,10 @@ impl Contains for IsCallable { use orml_currencies::Call::update_balance; use pallet_balances::Call::{force_transfer, set_balance}; use pallet_collective::Call::set_members; + use pallet_contracts::Call::{ + call, call_old_weight, instantiate, instantiate_old_weight, remove_code, + set_code as set_code_contracts, + }; use pallet_vesting::Call::force_vested_transfer; use zeitgeist_primitives::types::{ @@ -122,12 +130,12 @@ impl Contains for IsCallable { }; #[allow(clippy::match_like_matches_macro)] - match call { + match runtime_call { // Membership is managed by the respective Membership instance - Call::AdvisoryCommittee(set_members { .. }) => false, + RuntimeCall::AdvisoryCommittee(set_members { .. }) => false, // See "balance.set_balance" - Call::AssetManager(update_balance { .. }) => false, - Call::Balances(inner_call) => { + RuntimeCall::AssetManager(update_balance { .. }) => false, + RuntimeCall::Balances(inner_call) => { match inner_call { // Balances should not be set. All newly generated tokens be minted by well // known and approved processes, like staking. However, this could be used @@ -141,13 +149,23 @@ impl Contains for IsCallable { _ => true, } } + // Permissioned contracts: Only deployable via utility.dispatch_as(...) + RuntimeCall::Contracts(inner_call) => match inner_call { + call { .. } => true, + call_old_weight { .. } => true, + instantiate { .. } => true, + instantiate_old_weight { .. } => true, + remove_code { .. } => true, + set_code_contracts { .. } => true, + _ => false, + }, // Membership is managed by the respective Membership instance - Call::Council(set_members { .. }) => false, - Call::Court(_) => false, + RuntimeCall::Council(set_members { .. }) => false, + RuntimeCall::Court(_) => false, #[cfg(feature = "parachain")] - Call::DmpQueue(service_overweight { .. }) => false, - Call::LiquidityMining(_) => false, - Call::PredictionMarkets(inner_call) => { + RuntimeCall::DmpQueue(service_overweight { .. }) => false, + RuntimeCall::LiquidityMining(_) => false, + RuntimeCall::PredictionMarkets(inner_call) => { match inner_call { // Disable Rikiddo markets create_market { scoring_rule: RikiddoSigmoidFeeMarketEma, .. } => false, @@ -162,7 +180,7 @@ impl Contains for IsCallable { _ => true, } } - Call::System(inner_call) => { + RuntimeCall::System(inner_call) => { match inner_call { // Some "waste" storage will never impact proper operation. // Cleaning up storage should be done by pallets or independent migrations. @@ -183,9 +201,9 @@ impl Contains for IsCallable { } } // Membership is managed by the respective Membership instance - Call::TechnicalCommittee(set_members { .. }) => false, + RuntimeCall::TechnicalCommittee(set_members { .. }) => false, // There should be no reason to force vested transfer. - Call::Vesting(force_vested_transfer { .. }) => false, + RuntimeCall::Vesting(force_vested_transfer { .. }) => false, _ => true, } } diff --git a/runtime/zeitgeist/src/parachain_params.rs b/runtime/zeitgeist/src/parachain_params.rs index 3e80d851c..2ccf0ab61 100644 --- a/runtime/zeitgeist/src/parachain_params.rs +++ b/runtime/zeitgeist/src/parachain_params.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,11 +19,11 @@ #![allow( // Constants parameters inside `parameter_types!` already check // arithmetic operations at compile time - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "parachain")] -use super::{parameters::MAXIMUM_BLOCK_WEIGHT, Origin, ParachainInfo}; +use super::{parameters::MAXIMUM_BLOCK_WEIGHT, ParachainInfo, RuntimeOrigin}; use frame_support::{parameter_types, weights::Weight}; use orml_traits::parameter_type_with_key; use sp_runtime::{Perbill, Percent}; @@ -37,22 +38,14 @@ parameter_types! { /// The amount that should be taken as a security deposit when registering a NimbusId. pub const CollatorDeposit: Balance = 2 * BASE; - // Crowdloan - pub const InitializationPayment: Perbill = Perbill::from_percent(30); - pub const Initialized: bool = false; - pub const MaxInitContributorsBatchSizes: u32 = 500; - pub const MinimumReward: Balance = 0; - pub const RelaySignaturesThreshold: Perbill = Perbill::from_percent(100); - pub const SignatureNetworkIdentifier: &'static [u8] = b"zeitgeist-"; - // Cumulus and Polkadot pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub const RelayLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4; - pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UnitWeightCost: Weight = 200_000_000; + pub const RelayNetwork: NetworkId = NetworkId::Polkadot; + pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); + pub UnitWeightCost: u64 = 200_000_000; // Staking /// Rounds before the candidate bond increase/decrease can be executed @@ -90,7 +83,7 @@ parameter_types! { // XCM /// Base weight for XCM execution - pub const BaseXcmWeight: Weight = 200_000_000; + pub const BaseXcmWeight: u64 = 200_000_000; /// The maximum number of distinct assets allowed to be transferred in a /// single helper extrinsic. pub const MaxAssetsForTransfer: usize = 2; diff --git a/runtime/zeitgeist/src/parameters.rs b/runtime/zeitgeist/src/parameters.rs index 062f42f7e..b21a4c6a1 100644 --- a/runtime/zeitgeist/src/parameters.rs +++ b/runtime/zeitgeist/src/parameters.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,15 +19,17 @@ #![allow( // Constants parameters inside `parameter_types!` already check // arithmetic operations at compile time - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] -use super::VERSION; +use super::{Runtime, VERSION}; use frame_support::{ + dispatch::DispatchClass, parameter_types, + traits::WithdrawReasons, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND}, - DispatchClass, Weight, + Weight, }, PalletId, }; @@ -34,7 +37,8 @@ use frame_system::limits::{BlockLength, BlockWeights}; use orml_traits::parameter_type_with_key; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ - traits::AccountIdConversion, FixedPointNumber, Perbill, Percent, Permill, Perquintill, + traits::{AccountIdConversion, Bounded}, + FixedPointNumber, Perbill, Percent, Permill, Perquintill, }; use sp_version::RuntimeVersion; use zeitgeist_primitives::{constants::*, types::*}; @@ -43,7 +47,9 @@ use zeitgeist_primitives::{constants::*, types::*}; use frame_support::traits::LockIdentifier; pub(crate) const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); -pub(crate) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2; +pub(crate) const MAXIMUM_BLOCK_WEIGHT: Weight = + Weight::from_ref_time(WEIGHT_PER_SECOND.ref_time() / 2) + .set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64); pub(crate) const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); pub(crate) const FEES_AND_TIPS_TREASURY_PERCENTAGE: u32 = 100; pub(crate) const FEES_AND_TIPS_BURN_PERCENTAGE: u32 = 0; @@ -51,6 +57,7 @@ pub(crate) const FEES_AND_TIPS_BURN_PERCENTAGE: u32 = 0; parameter_types! { // Authorized pub const AuthorizedPalletId: PalletId = AUTHORIZED_PALLET_ID; + pub const CorrectionPeriod: BlockNumber = BLOCKS_PER_DAY; // Authority pub const MaxAuthorities: u32 = 32; @@ -73,6 +80,20 @@ parameter_types! { pub const TechnicalCommitteeMaxProposals: u32 = 64; pub const TechnicalCommitteeMotionDuration: BlockNumber = 7 * BLOCKS_PER_DAY; + // Contracts + pub const ContractsDeletionQueueDepth: u32 = 128; + pub ContractsDeletionWeightLimit: Weight = Perbill::from_percent(10) + * RuntimeBlockWeights::get() + .per_class + .get(DispatchClass::Normal) + .max_total + .unwrap_or(RuntimeBlockWeights::get().max_block); + pub const ContractsDepositPerByte: Balance = deposit(0,1); + pub const ContractsDepositPerItem: Balance = deposit(1,0); + pub const ContractsMaxCodeLen: u32 = 123 * 1024; + pub const ContractsMaxStorageKeyLen: u32 = 128; + pub ContractsSchedule: pallet_contracts::Schedule = Default::default(); + // Court /// Duration of a single court case. pub const CourtCaseDuration: u64 = BLOCKS_PER_DAY; @@ -112,9 +133,9 @@ parameter_types! { // Identity /// The amount held on deposit for a registered identity - pub const BasicDeposit: Balance = 100 * BASE; + pub const BasicDeposit: Balance = deposit(1, 258); /// The amount held on deposit per additional field for a registered identity. - pub const FieldDeposit: Balance = 25 * BASE; + pub const FieldDeposit: Balance = deposit(0, 66); /// Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O /// required to access an identity, but can be pretty high. pub const MaxAdditionalFields: u32 = 16; @@ -126,7 +147,7 @@ parameter_types! { /// The amount held on deposit for a registered subaccount. This should account for the fact /// that one storage item's value will increase by the size of an account ID, and there will /// be another trie item whose value is the size of an account ID plus 32 bytes. - pub const SubAccountDeposit: Balance = 20 * BASE; + pub const SubAccountDeposit: Balance = deposit(1, 53); // Liquidity Mining parameters /// Pallet identifier, mainly used for named balance reserves. DO NOT CHANGE. @@ -140,12 +161,12 @@ parameter_types! { // ORML pub const GetNativeCurrencyId: CurrencyId = Asset::Ztg; - pub DustAccount: AccountId = PalletId(*b"orml/dst").into_account_truncating(); // Prediction Market parameters /// (Slashable) Bond that is provided for creating an advised market that needs approval. /// Slashed in case the market is rejected. pub const AdvisoryBond: Balance = 200 * BASE; + /// The percentage of the advisory bond that gets slashed when a market is rejected. pub const AdvisoryBondSlashPercentage: Percent = Percent::from_percent(0); /// (Slashable) Bond that is provided for disputing the outcome. /// Slashed in case the final outcome does not match the dispute for which the `DisputeBond` @@ -155,43 +176,46 @@ parameter_types! { pub const DisputeFactor: Balance = 2 * BASE; /// Maximum Categories a prediciton market can have (excluding base asset). pub const MaxCategories: u16 = MAX_CATEGORIES; + /// Maximum block period for a dispute. + pub const MaxDisputeDuration: BlockNumber = MAX_DISPUTE_DURATION; /// Maximum number of disputes. pub const MaxDisputes: u16 = 1; - /// Minimum number of categories. The trivial minimum is 2, which represents a binary market. - pub const MinCategories: u16 = 2; - // 60_000 = 1 minute. Should be raised to something more reasonable in the future. - /// Minimum number of milliseconds a Rikiddo market must be in subsidy gathering phase. - pub const MinSubsidyPeriod: Moment = 60_000; + /// Maximum string length for edit reason. + pub const MaxEditReasonLen: u32 = 1024; + /// Maximum block period for a grace_period. + /// The grace_period is a delay between the point where the market closes and the point where the oracle may report. + pub const MaxGracePeriod: BlockNumber = MAX_GRACE_PERIOD; + /// The maximum allowed duration of a market from creation to market close in blocks. + pub const MaxMarketLifetime: BlockNumber = MAX_MARKET_LIFETIME; + /// Maximum block period for an oracle_duration. + /// The oracle_duration is a duration where the oracle has to submit its report. + pub const MaxOracleDuration: BlockNumber = MAX_ORACLE_DURATION; + /// Maximum string length allowed for reject reason. + pub const MaxRejectReasonLen: u32 = 1024; // 2_678_400_000 = 31 days. /// Maximum number of milliseconds a Rikiddo market can be in subsidy gathering phase. pub const MaxSubsidyPeriod: Moment = 2_678_400_000; + /// Minimum number of categories. The trivial minimum is 2, which represents a binary market. + pub const MinCategories: u16 = 2; /// The dispute_duration is time where users can dispute the outcome. /// Minimum block period for a dispute. pub const MinDisputeDuration: BlockNumber = MIN_DISPUTE_DURATION; - /// Maximum block period for a dispute. - pub const MaxDisputeDuration: BlockNumber = MAX_DISPUTE_DURATION; - /// Maximum block period for a grace_period. - /// The grace_period is a delay between the point where the market closes and the point where the oracle may report. - pub const MaxGracePeriod: BlockNumber = MAX_GRACE_PERIOD; /// Minimum block period for an oracle_duration. pub const MinOracleDuration: BlockNumber = MIN_ORACLE_DURATION; - /// Maximum block period for an oracle_duration. - /// The oracle_duration is a duration where the oracle has to submit its report. - pub const MaxOracleDuration: BlockNumber = MAX_ORACLE_DURATION; - /// The maximum market period. - pub const MaxMarketPeriod: Moment = u64::MAX / 2; + // 60_000 = 1 minute. Should be raised to something more reasonable in the future. + /// Minimum number of milliseconds a Rikiddo market must be in subsidy gathering phase. + pub const MinSubsidyPeriod: Moment = 60_000; /// (Slashable) The orcale bond. Slashed in case the final outcome does not match the /// outcome the oracle reported. pub const OracleBond: Balance = 200 * BASE; + /// (Slashable) A bond for an outcome reporter, who is not the oracle. + /// Slashed in case the final outcome does not match the outcome by the outsider. + pub const OutsiderBond: Balance = 2 * OracleBond::get(); /// Pallet identifier, mainly used for named balance reserves. DO NOT CHANGE. pub const PmPalletId: PalletId = PM_PALLET_ID; /// (Slashable) A bond for creation markets that do not require approval. Slashed in case /// the market is forcefully destroyed. pub const ValidityBond: Balance = 1_000 * BASE; - /// Maximum string length for edit reason. - pub const MaxEditReasonLen: u32 = 1024; - /// Maximum string length allowed for reject reason. - pub const MaxRejectReasonLen: u32 = 1024; // Preimage pub const PreimageMaxSize: u32 = 4096 * 1024; @@ -235,10 +259,8 @@ parameter_types! { pub const MaxTotalWeight: Balance = MaxWeight::get() * 2; /// The maximum weight a single asset can have. pub const MaxWeight: Balance = 64 * BASE; - /// Minimum amount of liquidity required to launch a CPMM pool. - pub const MinLiquidity: Balance = 100 * BASE; /// Minimum subsidy required to launch a Rikiddo pool. - pub const MinSubsidy: Balance = MinLiquidity::get(); + pub const MinSubsidy: Balance = 100 * BASE; /// Minimum subsidy a single account can provide. pub const MinSubsidyPerAccount: Balance = MinSubsidy::get(); /// Minimum weight a single asset can have. @@ -271,9 +293,6 @@ parameter_types! { .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - // Timestamp - pub const MinimumPeriod: u64 = MILLISECS_PER_BLOCK as u64 / 2; - // Transaction payment /// A fee mulitplier for Operational extrinsics to compute “virtual tip” /// to boost their priority. @@ -290,6 +309,12 @@ parameter_types! { /// Minimum amount of the multiplier. The test `multiplier_can_grow_from_zero` ensures /// that this value is not too low. pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); + /// Maximum amount of the multiplier. + pub MaximumMultiplier: Multiplier = Bounded::max_value(); + + // Timestamp + /// MinimumPeriod for Timestamp + pub const MinimumPeriodValue: u64 = MILLISECS_PER_BLOCK as u64 / 2; // Treasury /// Percentage of spare funds (if any) that are burnt per spend period. @@ -341,6 +366,8 @@ parameter_types! { // Vesting pub const MinVestedTransfer: Balance = ExistentialDeposit::get(); + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } #[cfg(feature = "with-global-disputes")] @@ -365,16 +392,43 @@ parameter_types! { } parameter_type_with_key! { - // Well, not every asset is a currency ¯\_(ツ)_/¯ + // Existential deposits used by orml-tokens. + // Only native ZTG and foreign assets should have an existential deposit. + // Winning outcome tokens are redeemed completely by the user, losing outcome tokens + // are cleaned up automatically. In case of scalar outcomes, the market account can have dust. + // Unless LPs use `pool_exit_with_exact_asset_amount`, there can be some dust pool shares remaining. + // Explicit match arms are used to ensure new asset types are respected. pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { + Asset::CategoricalOutcome(_,_) => ExistentialDeposit::get(), + Asset::CombinatorialOutcome => ExistentialDeposit::get(), + Asset::PoolShare(_) => ExistentialDeposit::get(), + Asset::ScalarOutcome(_,_) => ExistentialDeposit::get(), + #[cfg(feature = "parachain")] + Asset::ForeignAsset(id) => { + let maybe_metadata = < + orml_asset_registry::Pallet as orml_traits::asset_registry::Inspect + >::metadata(&Asset::ForeignAsset(*id)); + + if let Some(metadata) = maybe_metadata { + return metadata.existential_deposit; + } + + 1 + } + #[cfg(not(feature = "parachain"))] + Asset::ForeignAsset(_) => ExistentialDeposit::get(), Asset::Ztg => ExistentialDeposit::get(), - _ => 0 } }; } // Parameterized slow adjusting fee updated based on // https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; +pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment< + R, + TargetBlockFullness, + AdjustmentVariable, + MinimumMultiplier, + MaximumMultiplier, +>; diff --git a/runtime/zeitgeist/src/xcm_config/asset_registry.rs b/runtime/zeitgeist/src/xcm_config/asset_registry.rs index ba7807a8c..1b2f16f11 100644 --- a/runtime/zeitgeist/src/xcm_config/asset_registry.rs +++ b/runtime/zeitgeist/src/xcm_config/asset_registry.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -20,6 +20,7 @@ use orml_traits::asset_registry::{AssetMetadata, AssetProcessor}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::DispatchError; +use zeitgeist_primitives::types::CustomMetadata; #[derive( Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, @@ -46,49 +47,3 @@ impl AssetProcessor> for Cust Ok(()) } } - -#[derive( - Clone, - Copy, - Default, - PartialOrd, - Ord, - PartialEq, - Eq, - Debug, - Encode, - Decode, - TypeInfo, - MaxEncodedLen, -)] -/// Custom XC asset metadata -pub struct CustomMetadata { - /// XCM-related metadata. - pub xcm: XcmMetadata, - - /// Whether an asset can be used in pools. - pub allow_in_pool: bool, -} - -#[derive( - Clone, - Copy, - Default, - PartialOrd, - Ord, - PartialEq, - Eq, - Debug, - Encode, - Decode, - TypeInfo, - MaxEncodedLen, -)] -pub struct XcmMetadata { - /// The factor used to determine the fee. - /// It is multiplied by the fee that would have been paid in native currency, so it represents - /// the ratio `native_price / other_asset_price`. It is a fixed point decimal number containing - /// as many fractional decimals as the asset it is used for contains. - /// Should be updated regularly. - pub fee_factor: Option, -} diff --git a/runtime/zeitgeist/src/xcm_config/config.rs b/runtime/zeitgeist/src/xcm_config/config.rs index 8520f5a86..888b97a3c 100644 --- a/runtime/zeitgeist/src/xcm_config/config.rs +++ b/runtime/zeitgeist/src/xcm_config/config.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -17,9 +17,9 @@ use super::fees::{native_per_second, FixedConversionRateProvider}; use crate::{ - AccountId, Ancestry, AssetManager, AssetRegistry, Balance, Call, CurrencyId, MaxInstructions, - Origin, ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, - UnitWeightCost, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, + AccountId, Ancestry, AssetManager, AssetRegistry, Balance, CurrencyId, MaxInstructions, + ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, RuntimeCall, + RuntimeOrigin, UnitWeightCost, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, }; use frame_support::{parameter_types, traits::Everything, WeakBoundedVec}; @@ -50,7 +50,7 @@ use zeitgeist_primitives::types::Asset; pub mod zeitgeist { #[cfg(test)] - pub const ID: u32 = 2101; + pub const ID: u32 = 2092; pub const KEY: &[u8] = &[0, 1]; } @@ -70,7 +70,7 @@ impl Config for XcmConfig { /// Additional filters that specify whether the XCM instruction should be executed at all. type Barrier = Barrier; /// The outer call dispatch type. - type Call = Call; + type RuntimeCall = RuntimeCall; /// Combinations of (Location, Asset) pairs which are trusted as reserves. // Trust the parent chain, sibling parachains and children chains of this chain. type IsReserve = MultiNativeAsset; @@ -89,7 +89,7 @@ impl Config for XcmConfig { /// The means of determining an XCM message's weight. // Adds UnitWeightCost per instruction plus the weight of each instruction. // The total number of instructions are bounded by MaxInstructions - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; /// How to send an onward XCM message. type XcmSender = XcmRouter; } @@ -261,7 +261,7 @@ impl Convert for AccountIdToMultiLocation { } /// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM @@ -282,18 +282,18 @@ pub type XcmOriginToTransactDispatchOrigin = ( // Sovereign account converter; this attempts to derive an `AccountId` from the origin location // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, + SovereignSignedViaLocation, // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognized. - RelayChainAsNative, + RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // recognized. - SiblingParachainAsNative, + SiblingParachainAsNative, // Native signed account converter; this just converts an `AccountId32` origin into a normal // `Origin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, + SignedAccountId32AsNative, // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, + XcmPassthrough, ); /// The means for routing XCM messages which are not for local execution into the right message diff --git a/runtime/zeitgeist/src/xcm_config/fees.rs b/runtime/zeitgeist/src/xcm_config/fees.rs index b70484d97..53a036e53 100644 --- a/runtime/zeitgeist/src/xcm_config/fees.rs +++ b/runtime/zeitgeist/src/xcm_config/fees.rs @@ -1,4 +1,5 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. +// Copyright 2021 Centrifuge Foundation (centrifuge.io). // // This file is part of Zeitgeist. // @@ -15,11 +16,11 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{xcm_config::asset_registry::CustomMetadata, Balance, CurrencyId}; +use crate::{Balance, CurrencyId}; use core::marker::PhantomData; use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_PER_SECOND}; use xcm::latest::MultiLocation; -use zeitgeist_primitives::constants::BalanceFractionalDecimals; +use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::CustomMetadata}; use zrml_swaps::check_arithm_rslt::CheckArithmRslt; /// The fee cost per second for transferring the native token in cents. @@ -28,8 +29,8 @@ pub fn native_per_second() -> Balance { } pub fn default_per_second(decimals: u32) -> Balance { - let base_weight = Balance::from(ExtrinsicBaseWeight::get()); - let default_per_second = (WEIGHT_PER_SECOND as u128) / base_weight; + let base_weight = ExtrinsicBaseWeight::get().ref_time() as u128; + let default_per_second = (WEIGHT_PER_SECOND.ref_time() as u128) / base_weight; default_per_second * base_fee(decimals) } @@ -59,10 +60,10 @@ pub struct FixedConversionRateProvider(PhantomData impl< AssetRegistry: orml_traits::asset_registry::Inspect< - AssetId = CurrencyId, - Balance = Balance, - CustomMetadata = CustomMetadata, - >, + AssetId = CurrencyId, + Balance = Balance, + CustomMetadata = CustomMetadata, + >, > orml_traits::FixedConversionRateProvider for FixedConversionRateProvider { fn get_fee_per_second(location: &MultiLocation) -> Option { diff --git a/runtime/zeitgeist/src/xcm_config/mod.rs b/runtime/zeitgeist/src/xcm_config/mod.rs index 363ac87b1..448000ebe 100644 --- a/runtime/zeitgeist/src/xcm_config/mod.rs +++ b/runtime/zeitgeist/src/xcm_config/mod.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/rust-toolchain b/rust-toolchain index 11954de2c..b5b8dbecd 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-09-24" -components = ["clippy", "rustfmt"] +channel = "nightly-2023-03-01" +components = ["clippy", "rustfmt", "llvm-tools-preview"] profile = "minimal" targets = ["wasm32-unknown-unknown"] diff --git a/scripts/benchmarks/configuration.sh b/scripts/benchmarks/configuration.sh index 937f20edd..c5d8d2486 100644 --- a/scripts/benchmarks/configuration.sh +++ b/scripts/benchmarks/configuration.sh @@ -3,23 +3,20 @@ EXTERNAL_WEIGHTS_PATH="./runtime/common/src/weights/" # This script contains the configuration for other benchmarking scripts. -export FRAME_PALLETS=( frame_system pallet_balances pallet_bounties pallet_democracy \ - pallet_identity pallet_membership pallet_multisig pallet_preimage \ - pallet_proxy pallet_scheduler pallet_timestamp pallet_treasury \ - pallet_utility pallet_vesting pallet_collective ) # pallet_grandpa ) +export FRAME_PALLETS=( + frame_system pallet_balances pallet_bounties pallet_collective pallet_contracts \ + pallet_democracy pallet_identity pallet_membership pallet_multisig pallet_preimage \ + pallet_proxy pallet_scheduler pallet_timestamp pallet_treasury pallet_utility \ + pallet_vesting \ +) # pallet_grandpa ) export FRAME_PALLETS_RUNS="${FRAME_PALLETS_RUNS:-20}" export FRAME_PALLETS_STEPS="${FRAME_PALLETS_STEPS:-50}" export FRAME_WEIGHT_TEMPLATE="./misc/frame_weight_template.hbs" -# pallet_crowdloan_rewards benchmark lead to an error within the verify function (deprecated) export FRAME_PALLETS_PARACHAIN=( - cumulus_pallet_xcmp_queue \ - # pallet_author_inherent \ - pallet_author_slot_filter \ - pallet_author_mapping \ - pallet_parachain_staking \ - # pallet_crowdloan_rewards \ + cumulus_pallet_xcmp_queue pallet_author_inherent pallet_author_slot_filter \ + pallet_author_mapping pallet_parachain_staking \ ) export FRAME_PALLETS_PARACHAIN_RUNS="${FRAME_PALLETS_PARACHAIN_RUNS:-$FRAME_PALLETS_RUNS}" export FRAME_PALLETS_PARACHAIN_STEPS="${FRAME_PALLETS_PARACHAIN_STEPS:-$FRAME_PALLETS_STEPS}" @@ -29,7 +26,10 @@ export ORML_PALLETS_RUNS="${ORML_PALLETS_RUNS:-20}" export ORML_PALLETS_STEPS="${ORML_PALLETS_STEPS:-50}" export ORML_WEIGHT_TEMPLATE="./misc/orml_weight_template.hbs" -export ZEITGEIST_PALLETS=( zrml_authorized zrml_court zrml_global_disputes zrml_liquidity_mining zrml_prediction_markets zrml_swaps zrml_styx ) +export ZEITGEIST_PALLETS=( + zrml_authorized zrml_court zrml_global_disputes zrml_liquidity_mining zrml_prediction_markets \ + zrml_swaps zrml_styx \ +) export ZEITGEIST_PALLETS_RUNS="${ZEITGEIST_PALLETS_RUNS:-1000}" export ZEITGEIST_PALLETS_STEPS="${ZEITGEIST_PALLETS_STEPS:-10}" export ZEITGEIST_WEIGHT_TEMPLATE="./misc/weight_template.hbs" @@ -43,4 +43,4 @@ else fi export EXECUTION="${EXECUTION:-wasm}" export ADDITIONAL="${ADDITIONAL:-}" -export ADDITIONAL_FEATURES="${ADDITIONAL_FEATURES:-with-global-disputes}" \ No newline at end of file +export ADDITIONAL_FEATURES="${ADDITIONAL_FEATURES:-with-global-disputes}" diff --git a/scripts/benchmarks/quick_check.sh b/scripts/benchmarks/quick_check.sh index 6794b3895..a5487dcc0 100755 --- a/scripts/benchmarks/quick_check.sh +++ b/scripts/benchmarks/quick_check.sh @@ -12,13 +12,13 @@ if [ ! -d "./scripts/benchmarks" ]; then exit 1 fi; -export FRAME_PALLETS_STEPS=1 +export FRAME_PALLETS_STEPS=2 export FRAME_PALLETS_RUNS=0 -export ORML_PALLETS_STEPS=1 +export ORML_PALLETS_STEPS=2 export ORML_PALLETS_RUNS=0 -export ZEITGEIST_PALLETS_STEPS=1 +export ZEITGEIST_PALLETS_STEPS=2 export ZEITGEIST_PALLETS_RUNS=0 export PROFILE=release diff --git a/scripts/check-license/Makefile b/scripts/check-license/Makefile new file mode 100644 index 000000000..bc0647f40 --- /dev/null +++ b/scripts/check-license/Makefile @@ -0,0 +1,27 @@ +VENV?=.venv +BIN?=$(VENV)/bin +PYTHON?=$(BIN)/python +PIP?=$(BIN)/pip +PYTEST?=$(BIN)/pytest + +.PHONY: default +default: install + $(PYTEST) tests/ + +.PHONY: venv +venv: + pip install virtualenv + [ -d $(VENV) ] || virtualenv $(VENV) + $(PIP) install -r requirements.txt + make install + +.PHONY: clean +clean: + python setup.py clean + rm -fr .venv + rm -fr build + rm -fr dist + +.PHONY: install +install: + $(PYTHON) setup.py install diff --git a/scripts/check-license/requirements.txt b/scripts/check-license/requirements.txt new file mode 100644 index 000000000..4937c5a10 --- /dev/null +++ b/scripts/check-license/requirements.txt @@ -0,0 +1,3 @@ +click==8.0.3 +pytest==5.4.3 +pytest-mock==3.7.0 diff --git a/scripts/check-license/resources/test_read b/scripts/check-license/resources/test_read new file mode 100644 index 000000000..79382c2e5 --- /dev/null +++ b/scripts/check-license/resources/test_read @@ -0,0 +1,6 @@ +// Copyright 2020-2021, 2023 Holder. +// Copyright 1999 This other guy. +// +// This is the license. + +This is the rest of the file! diff --git a/scripts/check-license/resources/test_read_fails_on_broken_copyright_notice b/scripts/check-license/resources/test_read_fails_on_broken_copyright_notice new file mode 100644 index 000000000..4b8537965 --- /dev/null +++ b/scripts/check-license/resources/test_read_fails_on_broken_copyright_notice @@ -0,0 +1,6 @@ +// Copyright 2020-2021, 2023 Holder. +// (c) Copyright 1999 This other guy. +// +// This is the license. + +This is the rest of the file! diff --git a/scripts/check-license/setup.py b/scripts/check-license/setup.py new file mode 100644 index 000000000..8c6bcc8e9 --- /dev/null +++ b/scripts/check-license/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +setup( + name="check-license", + packages=["check_license"], + package_dir={"": "src"}, + entry_points={"console_scripts": ["check-license = check_license:main"]}, +) diff --git a/scripts/check-license/src/check_license/__init__.py b/scripts/check-license/src/check_license/__init__.py new file mode 100644 index 000000000..ea5f0b5df --- /dev/null +++ b/scripts/check-license/src/check_license/__init__.py @@ -0,0 +1,25 @@ +import argparse +import datetime +import logging +import sys + +from check_license.check_license import check_files, update_files +from check_license.console import echo + + +def main(): + # TODO Add option to ignore files? + parser = argparse.ArgumentParser() + parser.add_argument("files", nargs="*") + parser.add_argument("-w", "--write", action="store_true") + args = parser.parse_args(sys.argv[1:]) + current_year = datetime.date.today().year + if args.write: + failed, count = update_files(current_year, args.files) + echo(f"Updated {count} files. ✍️") + else: + failed = check_files(current_year, args.files) + if failed: + sys.exit(1) + echo("All copyright notices are up to date! 🍉") + sys.exit(0) diff --git a/scripts/check-license/src/check_license/check_license.py b/scripts/check-license/src/check_license/check_license.py new file mode 100644 index 000000000..e889b3bec --- /dev/null +++ b/scripts/check-license/src/check_license/check_license.py @@ -0,0 +1,131 @@ +from __future__ import annotations + +import dataclasses +import datetime +import re +import os + +from check_license.console import echo_error +from check_license.copyright import Copyright, CopyrightError +from check_license.errors import ( + LicenseCheckerError, + MissingCopyrightError, + IllegalCopyrightError, + DuplicateCopyrightError, + OutdatedCopyrightError, +) + +# TODO Get owner according to exact date +FORECASTING_TECH = "Forecasting Technologies LTD" +OWNER = FORECASTING_TECH + + +class File: + def __init__( + self, path: str, copyright_notices: Optional[list] = None, blob: str = "" + ) -> None: + self._path = path + self._copyright_notices = copyright_notices or [] + self._blob = blob + + @property + def path(self) -> str: + return self._path + + def last_changed(self) -> datetime.datetime: + """Return the UTC date at which the file was last changed.""" + # FIXME This doesn't take git into account. + return datetime.datetime.utcfromtimestamp(os.path.getmtime(self._path)) + + def read(self) -> None: + """Read contents of file to buffer. + + May fail due to broken copyright notices. Should be run before calling any other function. + """ + raw_copyright = [] + blob = "" + with open(self._path, "r") as f: + # We're assuming that all copyright notices come in one bunch, so once + # we meet a line of whitespace, we give up. + while (line := f.readline()) and line.startswith("//"): + if re.match(r"^// *$", line): + blob += line + break + raw_copyright.append(line[3:]) # Strip "// ". + blob += f.read() + for i, s in enumerate(raw_copyright): + try: + copyright = Copyright.from_string(s) + except CopyrightError: + raise IllegalCopyrightError(self._path, i, s) + self._copyright_notices.append(copyright) + self._blob = blob + + def check(self, year) -> None: + """Check that this file's copyright notice reflects changed made in the current + ``year``.""" + if not self._copyright_notices: + raise MissingCopyrightError(self._path) + owner_count = len({c.owner for c in self._copyright_notices}) + if owner_count != len(self._copyright_notices): + raise DuplicateCopyrightError(self._path) + # TODO Check that the license blob is as expected + + copyright = self._get_owner_copyright() + if copyright is None: + raise MissingCopyrightError(self._path, OWNER) + if copyright.end < year: + raise OutdatedCopyrightError(self._path, copyright, year) + + def update_license(self, year) -> bool: + """Update the copyright notice and return `True` if anything changed.""" + owner_copyright = self._get_owner_copyright() + if owner_copyright is None: + self._copyright_notices.insert(0, Copyright.from_year(OWNER, year)) + return True + if owner_copyright.end != year: + owner_copyright.push_year(year) + return True + return False + + def write(self) -> None: + content = "\n".join(["// " + str(c) for c in self._copyright_notices]) + if content: + content += "\n" + content += self._blob + with open(self._path, "w") as f: + f.write(content) + + def _get_owner_copyright(self) -> Optional[Copyright]: + matches = (c for c in self._copyright_notices if c.owner == OWNER) + # `len(matches) < 2` at this point. + return next(matches, None) + + +def check_files(year: int, files: list[str]) -> bool: + files = [File(f) for f in files] + result = False + for f in files: + try: + f.read() + f.check(year) + except LicenseCheckerError as e: + echo_error(str(e)) + result = True + return result + + +def update_files(year: int, files: list[str]) -> tuple[bool, int]: + files = [File(f) for f in files] + result = False + count = 0 + for f in files: + try: + f.read() + changed = f.update_license(year) + f.write() + count += changed + except LicenseCheckerError as e: + echo_error(str(e)) + result = True + return result, count diff --git a/scripts/check-license/src/check_license/console.py b/scripts/check-license/src/check_license/console.py new file mode 100644 index 000000000..fe609480f --- /dev/null +++ b/scripts/check-license/src/check_license/console.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +import click + + +def echo(msg: str) -> None: + click.echo(msg) + + +def echo_error(msg: str) -> None: + click.echo(click.style("error: ", fg="red"), nl=False) + click.echo(msg) diff --git a/scripts/check-license/src/check_license/copyright.py b/scripts/check-license/src/check_license/copyright.py new file mode 100644 index 000000000..f417f202f --- /dev/null +++ b/scripts/check-license/src/check_license/copyright.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +import dataclasses +import re + + +@dataclasses.dataclass +class Copyright: + owner: str + years: list[Years] + + @classmethod + def from_string(cls, s) -> Copyright: + """Create ``Copyright`` object from the string ``s``.""" + match = re.match(r"^Copyright ([0-9,\- ]*) (.*)\.$", s) + if not match: + raise ParseError() + years, holder = match.group(1, 2) + years = years.split(", ") + years = [Years.from_string(y) for y in years] + # Check that year ranges don't overlap and are ordered correctly. + for prev, curr in zip(years, years[1:]): + if curr.start <= prev.end: + raise IllegalYearRange() + return Copyright(holder, years) + + @classmethod + def from_year(cls, owner: str, year: int) -> Copyright: + return Copyright(owner, [Years(year)]) + + def __str__(self) -> str: + dates = ", ".join(str(y) for y in self.years) + return f"Copyright {dates} {self.owner}." + + @property + def end(self) -> int: + return self.years[-1].end + + def push_year(self, year: int) -> None: + """Safely add ``year`` to this copyright.""" + # `year` must not be contained in the copyright yet. + if year <= self.years[-1].end: + raise IllegalYearRange() + if year == self.years[-1].end + 1: + self.years[-1].end = year + else: + self.years.push(Years(year, year)) + + +@dataclasses.dataclass +class Years: + """A class for inclusive ranges of years.""" + + start: int + end: int = None + + def __post_init__(self) -> None: + if self.end is None: + self.end = self.start + if self.start > self.end: + raise IllegalYearRange() + + @classmethod + def from_string(cls, s: str) -> Years: + # `s` is only a year, e.g. `"2023"`. + match = re.match(r"^\d{4}$", s) + if match: + year = int(s) + return Years(year, year) + # `s` is a year range, e.g. `"2022-2023"` + match = re.match(r"^(\d{4})-(\d{4})$", s) + if match: + start, end = [int(n) for n in match.group(1, 2)] + if start >= end: + raise IllegalYearRange() + return Years(start, end) + raise ParseError() + + def __str__(self) -> str: + if self.start == self.end: + return str(self.start) + else: + return f"{self.start}-{self.end}" + + +class CopyrightError(Exception): + pass + + +class ParseError(CopyrightError): + pass + + +class IllegalYearRange(CopyrightError): + pass diff --git a/scripts/check-license/src/check_license/errors.py b/scripts/check-license/src/check_license/errors.py new file mode 100644 index 000000000..3da730e5e --- /dev/null +++ b/scripts/check-license/src/check_license/errors.py @@ -0,0 +1,32 @@ +from __future__ import annotations + + +class LicenseCheckerError(Exception): + pass + + +class MissingCopyrightError(LicenseCheckerError): + def __init__(self, path: str, holder: str = "") -> None: + if holder: + msg = f"{path}: no copyright notice for {holder} found" + else: + msg = f"{path}: no copyright notice found" + super().__init__(msg) + + +class IllegalCopyrightError(LicenseCheckerError): + def __init__(self, path: str, number: int, line: str) -> None: + msg = f"{path}:{number}: expected copyright notice, found '{line}'" + super().__init__(msg) + + +class DuplicateCopyrightError(LicenseCheckerError): + def __init__(self, path: str) -> None: + msg = f"{path}: duplicate copyright notice" + super().__init__(msg) + + +class OutdatedCopyrightError(LicenseCheckerError): + def __init__(self, path: str, actual: Copyright, year: int) -> None: + msg = f"{path}: year {year} missing from copyright notice '{actual}'" + super().__init__(msg) diff --git a/scripts/check-license/tests/test_check_license.py b/scripts/check-license/tests/test_check_license.py new file mode 100644 index 000000000..c1f5e5508 --- /dev/null +++ b/scripts/check-license/tests/test_check_license.py @@ -0,0 +1,175 @@ +import builtins +import textwrap + +import pytest + +from check_license.copyright import Copyright, Years +from check_license.check_license import File +from check_license.errors import * + + +class TestFile: + def test_read(self): + path_to_file = "resources/test_read" + file = File(path_to_file) + file.read() + assert file.path == path_to_file + assert file._copyright_notices == [ + Copyright("Holder", [Years(2020, 2021), Years(2023)]), + Copyright("This other guy", [Years(1999)]), + ] + assert ( + file._blob + == "//\n// This is the license.\n\nThis is the rest of the file!\n" + ) + + def test_read_fails_on_broken_copyright_notice(self): + path_to_file = "resources/test_read_fails_on_broken_copyright_notice" + file = File(path_to_file) + with pytest.raises(IllegalCopyrightError): + file.read() + + def test_check_success_or_outdated(self): + file = File( + "path/to/file", + [ + Copyright("Forecasting Technologies LTD", [Years(2023)]), + Copyright("Zeitgeist PM LLC", [Years(2021, 2022)]), + ], + "blob", + ) + file.check(2023) + with pytest.raises(OutdatedCopyrightError): + file.check(2024) + + @pytest.mark.parametrize( + "copyright_notices, year, error", + [ + ( + [ + Copyright.from_string( + "Copyright 2023 Forecasting Technologies LTD." + ), + Copyright.from_string("Copyright 2021-2022 Zeitgeist PM LLC."), + Copyright.from_string( + "Copyright 2022 Forecasting Technologies LTD." + ), + ], + 2023, + DuplicateCopyrightError, + ), + ( + [Copyright.from_string("Copyright 2023 some dude.")], + 2023, + MissingCopyrightError, + ), + ( + [Copyright.from_string("Copyright 2022 Forecasting Technologies LTD.")], + 2023, + OutdatedCopyrightError, + ), + ], + ) + def test_check_fails(self, copyright_notices, year, error): + file = File( + "path/to/file", + copyright_notices, + "blob", + ) + with pytest.raises(error): + file.check(year) + + @pytest.mark.parametrize( + "before, after, year, expected", + [ + ( + [ + Copyright.from_string( + "Copyright 2023 Forecasting Technologies LTD." + ), + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + ], + [ + Copyright.from_string( + "Copyright 2023 Forecasting Technologies LTD." + ), + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + ], + 2023, + False, + ), + ( + [ + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + ], + [ + Copyright.from_string( + "Copyright 2023 Forecasting Technologies LTD." + ), + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + ], + 2023, + True, + ), + ( + [ + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + Copyright.from_string( + "Copyright 2022 Forecasting Technologies LTD." + ), + ], + [ + Copyright.from_string("Copyright 2019-2021, 2023 Someone."), + Copyright.from_string( + "Copyright 2022-2023 Forecasting Technologies LTD." + ), + ], + 2023, + True, + ), + ], + ) + def test_update_license(self, before, after, year, expected): + blob = "blob" + file = File("path/to/file", before, blob) + result = file.update_license(year) + assert file.path == "path/to/file" + assert file._copyright_notices == after + assert file._blob == blob + assert result == expected + + def test_write(self, mocker, monkeypatch): + mock_manager = mocker.Mock(__enter__=mocker.Mock(), __exit__=mocker.Mock()) + mock_open = mocker.Mock(return_value=mock_manager) + monkeypatch.setattr(builtins, "open", mock_open) + + path_to_file = "path/to/file" + file = File( + path_to_file, + [ + Copyright.from_string("Copyright 2022-2023 New Company."), + Copyright.from_string("Copyright 2021-2022 Old Company."), + ], + textwrap.dedent( + """\ + // + // The license + + The rest of the file. + """, + ), + ) + file.write() + + expected = textwrap.dedent( + """\ + // Copyright 2022-2023 New Company. + // Copyright 2021-2022 Old Company. + // + // The license + + The rest of the file. + """, + ) + mock_open.assert_called_once_with(path_to_file, "w") + mock_manager.__enter__().write.assert_called_once_with(expected) diff --git a/scripts/check-license/tests/test_copyright.py b/scripts/check-license/tests/test_copyright.py new file mode 100644 index 000000000..a914be824 --- /dev/null +++ b/scripts/check-license/tests/test_copyright.py @@ -0,0 +1,56 @@ +import pytest + +from check_license.copyright import Copyright, Years, CopyrightError + + +class TestCopyright: + @pytest.mark.parametrize( + "value, holder, years", + [ + ( + "Copyright 2020 Copyright Holder.", + "Copyright Holder", + [Years(2020)], + ), + ( + "Copyright 2020-2021 Copyright Holder.", + "Copyright Holder", + [Years(2020, 2021)], + ), + ( + "Copyright 2020-2021, 2023 Copyright Holder.", + "Copyright Holder", + [Years(2020, 2021), Years(2023)], + ), + ], + ) + def test_from_string(self, value, holder, years): + actual = Copyright.from_string(value) + assert actual == Copyright(holder, years) + + @pytest.mark.parametrize( + "value", + [ + "Copyright 2022-2022 same year range.", + "Copyright missing years.", + "Copyright 2022-2021 decreasing years.", + "Copyright 2020-2022, 2022-2023 overlapping years.", + ], + ) + def test_from_string_fails(self, value): + with pytest.raises(CopyrightError): + Copyright.from_string(value) + + @pytest.mark.parametrize( + "copyright, expected", + [ + (Copyright("Holder", [Years(2020)]), "Copyright 2020 Holder."), + (Copyright("Holder", [Years(2020, 2021)]), "Copyright 2020-2021 Holder."), + ( + Copyright("Holder", [Years(2020, 2021), Years(2023)]), + "Copyright 2020-2021, 2023 Holder.", + ), + ], + ) + def test_str(self, copyright, expected): + assert str(copyright) == expected diff --git a/scripts/init.sh b/scripts/init.sh index 2bf6e6e04..8cee5890e 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,12 +1,20 @@ #!/usr/bin/env bash +# Initializes a build environment. +# Passing "nosudo" in the first argument results in avoiding the usage of sudo for privileged commands. + set -e -echo "*** Initializing WASM build environment" +echo "*** Initializing build environment" -if [ -z $CI_PROJECT_NAME ] ; then - rustup update nightly-2022-04-13 - rustup update stable +if [ "$1" == "nosudo" ]; then + apt-get update && \ + apt-get install -y build-essential clang curl libssl-dev protobuf-compiler +else + sudo apt-get update && \ + sudo apt-get install -y build-essential clang curl libssl-dev protobuf-compiler fi -rustup target add wasm32-unknown-unknown --toolchain nightly-2022-04-13 +curl https://sh.rustup.rs -sSf | sh -s -- -y && \ + . "$HOME/.cargo/env" && \ + rustup show diff --git a/scripts/parachain/bootstrap.sh b/scripts/parachain/bootstrap.sh index db053acde..eb5088a79 100755 --- a/scripts/parachain/bootstrap.sh +++ b/scripts/parachain/bootstrap.sh @@ -24,7 +24,7 @@ export DATA_DIR="$HOME/battery-station-relay" export PARACHAIN_CHAIN="battery_station" export PARACHAIN_FIRST_BOOTNODE_ADDR="/ip4/127.0.0.1/tcp/30001/p2p/12D3KooWBMSGsvMa2A7A9PA2CptRFg9UFaWmNgcaXRxr1pE1jbe9" -export PARACHAIN_ID="2050" +export PARACHAIN_ID="2101" export PARACHAIN_IMAGE="zeitgeistpm/zeitgeist-node-parachain:sha-8ea9683" export PARACHAIN_NIMBUS_PK="0xe6ea0b63b2b5b7247a1e8280350a14c5f9e7745dec2fe3428b68aa4167d48e66" export PARACHAIN_PORT="30000" diff --git a/scripts/parachain/local.sh b/scripts/parachain/local.sh index 62f1e4b54..39bb1e4a6 100755 --- a/scripts/parachain/local.sh +++ b/scripts/parachain/local.sh @@ -7,7 +7,7 @@ set -euxo pipefail PARACHAIN_CHAIN=dev -PARACHAIN_ID=2050 +PARACHAIN_ID=2101 POLKADOT_BRANCH=release-v0.9.11 POLKADOT_DIR="target/polkadot" RELAYCHAIN_CHAIN=rococo-local diff --git a/scripts/tests/all-sequencial.sh b/scripts/tests/all-sequencial.sh index 9b3ecd661..a94141360 100755 --- a/scripts/tests/all-sequencial.sh +++ b/scripts/tests/all-sequencial.sh @@ -4,8 +4,9 @@ # # IMPORTANT: CI verifies most of the following scripts in parallel -. "$(dirname "$0")/misc.sh" --source-only . "$(dirname "$0")/clippy.sh" --source-only -. "$(dirname "$0")/parachain.sh" --source-only . "$(dirname "$0")/standalone.sh" --source-only +. "$(dirname "$0")/parachain.sh" --source-only +. "$(dirname "$0")/test_standalone.sh" --source-only +. "$(dirname "$0")/test_parachain.sh" --source-only . "$(dirname "$0")/fuzz.sh" --source-only diff --git a/scripts/tests/aux-functions.sh b/scripts/tests/aux-functions.sh index 5847fdd9f..0bc90af4a 100755 --- a/scripts/tests/aux-functions.sh +++ b/scripts/tests/aux-functions.sh @@ -13,8 +13,9 @@ check_package_with_feature() { test_package_with_feature() { local package=$1 local features=$2 + local rustflags=${3:-} /bin/echo -e "\e[0;33m***** Testing '$package' with features '$features' *****\e[0m\n" # default rustc profile dev (debug) is used to stop for debug_assertions - CARGO_INCREMENTAL=0 RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features + RUSTFLAGS="$rustflags" cargo test --features $features --manifest-path $package/Cargo.toml --no-default-features } diff --git a/scripts/tests/coverage.sh b/scripts/tests/coverage.sh new file mode 100755 index 000000000..aeed8dbfd --- /dev/null +++ b/scripts/tests/coverage.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Coverage: Generate project coverage files using grcov + +set -euxo pipefail + +. "$(dirname "$0")/aux-functions.sh" --source-only + +export CARGO_INCREMENTAL=0 +export LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" +rustflags="-Cinstrument-coverage" + +test_package_with_feature "primitives" "std" "$rustflags" +no_runtime_benchmarks=('court' 'market-commons' 'rikiddo') + +for package in zrml/*; do +if [[ " ${no_runtime_benchmarks[*]} " != *" ${package##*/} "* ]]; then + echo "TEST $package std,runtime-benchmarks" + test_package_with_feature "$package" "std,runtime-benchmarks" "$rustflags" +else + echo "TEST $package std" + test_package_with_feature "$package" "std" "$rustflags" +fi +done + +unset CARGO_INCREMENTAL LLVM_PROFILE_FILE + +grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --llvm --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov \ No newline at end of file diff --git a/scripts/tests/fuzz.sh b/scripts/tests/fuzz.sh index dc7b3588b..e1b7e0be0 100755 --- a/scripts/tests/fuzz.sh +++ b/scripts/tests/fuzz.sh @@ -2,8 +2,30 @@ # Fuzzing tests +verbose="" + +for arg in "$@"; do + case $arg in + "--verbose" | "-v") + verbose="verbose" + ;; + *) + echo "Unknown option '$arg'" + usage + exit 1 + ;; + esac +done + set -euxo pipefail +if [[ ${verbose} = "verbose" ]]; then + echo "Its verbose" + RUST_BACKTRACE=1 +fi + +# Fuzzing tests + # Using specific_run = (RUN * FUZZ_FACT) / BASE allows us to specify # a hardware- and fuzz target specific run count. BASE=1000 @@ -33,35 +55,35 @@ RIKIDDO_WITH_CALCULATED_FEE_FACT=1750 RIKIDDO_PALLET_FACT=1000 # --- Prediction Market Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS +cargo fuzz run --release --fuzz-dir zrml/prediction-markets/fuzz pm_full_workflow -- -runs=$RUNS # --- Swaps Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz create_pool -- -runs=$(($(($RUNS * $CREATE_POOL_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join -- -runs=$(($(($RUNS * $POOL_JOIN_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_join_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_JOIN_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_in -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_IN_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz swap_exact_amount_out -- -runs=$(($(($RUNS * $SWAP_EXACT_AMOUNT_OUT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_asset_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_ASSET_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit_with_exact_pool_amount -- -runs=$(($(($RUNS * $POOL_EXIT_WITH_EXACT_POOL_AMOUNT_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/swaps/fuzz pool_exit -- -runs=$(($(($RUNS * $POOL_EXIT_FACT)) / $BASE)) # --- Orderbook-v1 Pallet fuzz tests --- -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS +cargo fuzz run --release --fuzz-dir zrml/orderbook-v1/fuzz orderbook_v1_full_workflow -- -runs=$RUNS # --- Rikiddo Pallet fuzz tests --- # Profile release is required here since it triggers debug assertions otherwise # Using the default RUNS multiplier, each fuzz test needs approx. 6-7 seconds -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fee_sigmoid -- -runs=$(($(($RUNS * $FEE_SIGMOID_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedi_to_fixedu_conversion -- -runs=$(($(($RUNS * $FIXEDI_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_fixedi_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_FIXEDI_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz balance_to_fixedu_conversion -- -runs=$(($(($RUNS * $BALANCE_TO_FIXEDU_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz fixedu_to_balance_conversion -- -runs=$(($(($RUNS * $FIXEDU_TO_BALANCE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_first_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_FIRST_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_second_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_SECOND_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_third_state -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_THIRD_STATE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz ema_market_volume_estimate_ema -- -runs=$(($(($RUNS * $EMA_MARKET_VOLUME_ESTIMATE_EMA_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_initial_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_INITIAL_FEE_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_with_calculated_fee -- -runs=$(($(($RUNS * $RIKIDDO_WITH_CALCULATED_FEE_FACT)) / $BASE)) # This actually needs approx. 107 seconds. Need to find a way to optimize fuzzing on-chain -RUST_BACKTRACE=1 cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) +cargo fuzz run --release --fuzz-dir zrml/rikiddo/fuzz rikiddo_pallet -- -runs=$(($(($RUNS * $RIKIDDO_PALLET_FACT)) / $BASE)) diff --git a/scripts/tests/misc.sh b/scripts/tests/misc.sh deleted file mode 100755 index 359581713..000000000 --- a/scripts/tests/misc.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -# Miscellaneous: Checks everything that is not clippy, fuzz, runtime or node related - -set -euxo pipefail - -. "$(dirname "$0")/aux-functions.sh" --source-only - -test_package_with_feature primitives default -test_package_with_feature primitives std - -no_runtime_benchmarks=('court' 'market-commons' 'rikiddo') - -cargo test --package zeitgeist-runtime --lib -- --nocapture - -# TODO(#848): Delete when feature "with-global-dispute" is removed -cargo test -p zrml-prediction-markets --features with-global-disputes - -for package in zrml/* -do - test_package_with_feature "$package" std - echo "TEST $package std" - - if [[ " ${no_runtime_benchmarks[*]} " != *" ${package##*/} "* ]]; then - test_package_with_feature "$package" std,runtime-benchmarks - echo "TEST $package std,runtime-benchmarks" - fi -done - -grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --llvm --ignore '../*' --ignore "/*" -o $RUNNER_TEMP/zeitgeist-test-coverage.lcov diff --git a/scripts/tests/parachain.sh b/scripts/tests/parachain.sh index 47ea3f798..a59f27049 100755 --- a/scripts/tests/parachain.sh +++ b/scripts/tests/parachain.sh @@ -6,7 +6,8 @@ set -euxo pipefail . "$(dirname "$0")/aux-functions.sh" --source-only -check_package_with_feature runtime/battery-station std,parachain -check_package_with_feature runtime/zeitgeist std,parachain +check_package_with_feature runtime/battery-station 'parachain --all-features' -check_package_with_feature node default,parachain +check_package_with_feature runtime/zeitgeist 'parachain --all-features' + +check_package_with_feature node 'parachain --all-features' diff --git a/scripts/tests/standalone.sh b/scripts/tests/standalone.sh index def013e50..8a9065b85 100755 --- a/scripts/tests/standalone.sh +++ b/scripts/tests/standalone.sh @@ -6,11 +6,8 @@ set -euxo pipefail . "$(dirname "$0")/aux-functions.sh" --source-only -check_package_with_feature runtime/battery-station std -check_package_with_feature runtime/battery-station std,runtime-benchmarks +check_package_with_feature runtime/battery-station runtime-benchmarks,std,try-runtime -check_package_with_feature runtime/zeitgeist std -check_package_with_feature runtime/zeitgeist std,runtime-benchmarks +check_package_with_feature runtime/zeitgeist runtime-benchmarks,std,try-runtime -check_package_with_feature node default -check_package_with_feature node default,runtime-benchmarks +check_package_with_feature node default,runtime-benchmarks,try-runtime diff --git a/scripts/tests/test_parachain.sh b/scripts/tests/test_parachain.sh new file mode 100755 index 000000000..d6f26e7e3 --- /dev/null +++ b/scripts/tests/test_parachain.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Tests: Run tests on all crates using a parachain build + +set -euxo pipefail + +. "$(dirname "$0")/aux-functions.sh" --source-only + +# Test parachain +test_package_with_feature "." "default,parachain,runtime-benchmarks" "" \ No newline at end of file diff --git a/scripts/tests/test_standalone.sh b/scripts/tests/test_standalone.sh new file mode 100755 index 000000000..2aac94683 --- /dev/null +++ b/scripts/tests/test_standalone.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Tests: Run tests on all crates using a standalone build + +set -euxo pipefail + +. "$(dirname "$0")/aux-functions.sh" --source-only + +# Test standalone +test_package_with_feature "." "default,runtime-benchmarks" "" \ No newline at end of file diff --git a/scripts/update-copyright.sh b/scripts/update-copyright.sh new file mode 100755 index 000000000..258203422 --- /dev/null +++ b/scripts/update-copyright.sh @@ -0,0 +1,2 @@ +RUST_FILES_CHANGED=$(git diff --name-only main | grep -E .*\.rs$) +check-license -w ${RUST_FILES_CHANGED} diff --git a/zrml/authorized/Cargo.toml b/zrml/authorized/Cargo.toml index cee23ae85..eb7b1beef 100644 --- a/zrml/authorized/Cargo.toml +++ b/zrml/authorized/Cargo.toml @@ -1,17 +1,17 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-market-commons = { default-features = false, path = "../market-commons" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -38,4 +38,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-authorized" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/authorized/src/benchmarks.rs b/zrml/authorized/src/benchmarks.rs index e19beaf35..7a3ce9bfc 100644 --- a/zrml/authorized/src/benchmarks.rs +++ b/zrml/authorized/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,25 +18,83 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "runtime-benchmarks")] #[cfg(test)] use crate::Pallet as Authorized; -use crate::{market_mock, Call, Config, Pallet}; +use crate::{market_mock, AuthorizedOutcomeReports, Call, Config, Pallet}; use frame_benchmarking::benchmarks; -use frame_support::{dispatch::UnfilteredDispatchable, traits::EnsureOrigin}; -use zeitgeist_primitives::types::OutcomeReport; +use frame_support::{ + dispatch::UnfilteredDispatchable, + traits::{EnsureOrigin, Get}, +}; +use sp_runtime::traits::Saturating; +use zeitgeist_primitives::{ + traits::DisputeResolutionApi, + types::{AuthorityReport, OutcomeReport}, +}; use zrml_market_commons::MarketCommonsPalletApi; benchmarks! { - authorize_market_outcome { + authorize_market_outcome_first_report { + let m in 1..63; + + let origin = T::AuthorizedDisputeResolutionOrigin::successful_origin(); + let market_id = 0u32.into(); + let market = market_mock::(); + T::MarketCommons::push_market(market).unwrap(); + + frame_system::Pallet::::set_block_number(42u32.into()); + let now = frame_system::Pallet::::block_number(); + let correction_period_ends_at = now.saturating_add(T::CorrectionPeriod::get()); + for _ in 1..=m { + let id = T::MarketCommons::push_market(market_mock::()).unwrap(); + T::DisputeResolution::add_auto_resolve(&id, correction_period_ends_at).unwrap(); + } + + let call = Call::::authorize_market_outcome { + market_id, + outcome: OutcomeReport::Scalar(1), + }; + }: { + call.dispatch_bypass_filter(origin)? + } verify { + let report = AuthorityReport { + resolve_at: correction_period_ends_at, + outcome: OutcomeReport::Scalar(1) + }; + assert_eq!(AuthorizedOutcomeReports::::get(market_id).unwrap(), report); + } + + authorize_market_outcome_existing_report { let origin = T::AuthorizedDisputeResolutionOrigin::successful_origin(); + let market_id = 0u32.into(); let market = market_mock::(); T::MarketCommons::push_market(market).unwrap(); - let call = Call::::authorize_market_outcome { market_id: 0_u32.into(), outcome: OutcomeReport::Scalar(1) }; - }: { call.dispatch_bypass_filter(origin)? } + + frame_system::Pallet::::set_block_number(42u32.into()); + + let now = frame_system::Pallet::::block_number(); + let resolve_at = now.saturating_add(T::CorrectionPeriod::get()); + + let report = AuthorityReport { resolve_at, outcome: OutcomeReport::Scalar(0) }; + AuthorizedOutcomeReports::::insert(market_id, report); + + let now = frame_system::Pallet::::block_number(); + frame_system::Pallet::::set_block_number(now + 42u32.into()); + + let call = Call::::authorize_market_outcome { + market_id, + outcome: OutcomeReport::Scalar(1), + }; + }: { + call.dispatch_bypass_filter(origin)? + } verify { + let report = AuthorityReport { resolve_at, outcome: OutcomeReport::Scalar(1) }; + assert_eq!(AuthorizedOutcomeReports::::get(market_id).unwrap(), report); + } impl_benchmark_test_suite!( Authorized, diff --git a/zrml/authorized/src/lib.rs b/zrml/authorized/src/lib.rs index 23bd36d92..95a82638a 100644 --- a/zrml/authorized/src/lib.rs +++ b/zrml/authorized/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -24,6 +25,7 @@ mod authorized_pallet_api; mod benchmarks; pub mod migrations; mod mock; +mod mock_storage; mod tests; pub mod weights; @@ -35,22 +37,25 @@ mod pallet { use crate::{weights::WeightInfoZeitgeist, AuthorizedPalletApi}; use core::marker::PhantomData; use frame_support::{ - dispatch::DispatchResult, + dispatch::{DispatchResult, DispatchResultWithPostInfo}, ensure, - pallet_prelude::{EnsureOrigin, OptionQuery, StorageMap}, + pallet_prelude::{ConstU32, EnsureOrigin, OptionQuery, StorageMap}, traits::{Currency, Get, Hooks, IsType, StorageVersion}, PalletId, Twox64Concat, }; use frame_system::pallet_prelude::OriginFor; - use sp_runtime::DispatchError; + use sp_runtime::{traits::Saturating, DispatchError}; use zeitgeist_primitives::{ - traits::DisputeApi, - types::{Market, MarketDispute, MarketDisputeMechanism, MarketStatus, OutcomeReport}, + traits::{DisputeApi, DisputeResolutionApi}, + types::{ + Asset, AuthorityReport, Market, MarketDispute, MarketDisputeMechanism, MarketStatus, + OutcomeReport, + }, }; use zrml_market_commons::MarketCommonsPalletApi; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); pub(crate) type BalanceOf = as Currency<::AccountId>>::Balance; @@ -59,33 +64,56 @@ mod pallet { pub(crate) type MarketIdOf = <::MarketCommons as MarketCommonsPalletApi>::MarketId; pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; - type MarketOf = Market< + pub type CacheSize = ConstU32<64>; + pub(crate) type MarketOf = Market< ::AccountId, BalanceOf, ::BlockNumber, MomentOf, + Asset>, >; #[pallet::call] impl Pallet { /// Overwrites already provided outcomes for the same market and account. #[frame_support::transactional] - #[pallet::weight(T::WeightInfo::authorize_market_outcome())] + #[pallet::weight( + T::WeightInfo::authorize_market_outcome_first_report(CacheSize::get()).max( + T::WeightInfo::authorize_market_outcome_existing_report(), + ) + )] pub fn authorize_market_outcome( origin: OriginFor, market_id: MarketIdOf, outcome: OutcomeReport, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { T::AuthorizedDisputeResolutionOrigin::ensure_origin(origin)?; let market = T::MarketCommons::market(&market_id)?; ensure!(market.status == MarketStatus::Disputed, Error::::MarketIsNotDisputed); ensure!(market.matches_outcome_report(&outcome), Error::::OutcomeMismatch); - match market.dispute_mechanism { - MarketDisputeMechanism::Authorized => { - AuthorizedOutcomeReports::::insert(market_id, outcome); - Ok(()) + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Authorized, + Error::::MarketDoesNotHaveDisputeMechanismAuthorized + ); + + let now = frame_system::Pallet::::block_number(); + + let report_opt = AuthorizedOutcomeReports::::get(market_id); + let (report, ids_len) = match &report_opt { + Some(report) => (AuthorityReport { resolve_at: report.resolve_at, outcome }, 0u32), + None => { + let resolve_at = now.saturating_add(T::CorrectionPeriod::get()); + let ids_len = T::DisputeResolution::add_auto_resolve(&market_id, resolve_at)?; + (AuthorityReport { resolve_at, outcome }, ids_len) } - _ => Err(Error::::MarketDoesNotHaveDisputeMechanismAuthorized.into()), + }; + + AuthorizedOutcomeReports::::insert(market_id, report); + + if report_opt.is_none() { + Ok(Some(T::WeightInfo::authorize_market_outcome_first_report(ids_len)).into()) + } else { + Ok(Some(T::WeightInfo::authorize_market_outcome_existing_report()).into()) } } } @@ -93,16 +121,24 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Event - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// Market commons - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - >; + /// The period, in which the authority can correct the outcome of a market. + /// This value must not be zero. + #[pallet::constant] + type CorrectionPeriod: Get; + + type DisputeResolution: DisputeResolutionApi< + AccountId = Self::AccountId, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + >; + + type MarketCommons: MarketCommonsPalletApi; /// The origin that is allowed to resolved disupute in Authorized dispute mechanism. - type AuthorizedDisputeResolutionOrigin: EnsureOrigin; + type AuthorizedDisputeResolutionOrigin: EnsureOrigin; /// Identifier of this pallet #[pallet::constant] @@ -118,6 +154,8 @@ mod pallet { MarketDoesNotHaveDisputeMechanismAuthorized, /// An account attempts to submit a report to an undisputed market. MarketIsNotDisputed, + /// Only one dispute is allowed. + OnlyOneDisputeAllowed, /// The report does not match the market's type. OutcomeMismatch, } @@ -134,7 +172,15 @@ mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); - impl Pallet where T: Config {} + impl Pallet + where + T: Config, + { + /// Return the resolution block number for the given market. + fn get_auto_resolve(market_id: &MarketIdOf) -> Option { + AuthorizedOutcomeReports::::get(market_id).map(|report| report.resolve_at) + } + } impl DisputeApi for Pallet where @@ -145,22 +191,57 @@ mod pallet { type BlockNumber = T::BlockNumber; type MarketId = MarketIdOf; type Moment = MomentOf; - type Origin = T::Origin; + type Origin = T::RuntimeOrigin; fn on_dispute( - _: &[MarketDispute], + disputes: &[MarketDispute], _: &Self::MarketId, - _: &MarketOf, + market: &MarketOf, ) -> DispatchResult { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Authorized, + Error::::MarketDoesNotHaveDisputeMechanismAuthorized + ); + ensure!(disputes.is_empty(), Error::::OnlyOneDisputeAllowed); Ok(()) } fn on_resolution( _: &[MarketDispute], market_id: &Self::MarketId, - _: &MarketOf, + market: &MarketOf, ) -> Result, DispatchError> { - Ok(AuthorizedOutcomeReports::::take(market_id)) + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Authorized, + Error::::MarketDoesNotHaveDisputeMechanismAuthorized + ); + let report = AuthorizedOutcomeReports::::take(market_id); + Ok(report.map(|r| r.outcome)) + } + + fn get_auto_resolve( + _: &[MarketDispute], + market_id: &Self::MarketId, + market: &MarketOf, + ) -> Result, DispatchError> { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Authorized, + Error::::MarketDoesNotHaveDisputeMechanismAuthorized + ); + Ok(Self::get_auto_resolve(market_id)) + } + + fn has_failed( + _: &[MarketDispute], + _: &Self::MarketId, + market: &MarketOf, + ) -> Result { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Authorized, + Error::::MarketDoesNotHaveDisputeMechanismAuthorized + ); + + Ok(false) } } @@ -170,20 +251,20 @@ mod pallet { #[pallet::storage] #[pallet::getter(fn outcomes)] pub type AuthorizedOutcomeReports = - StorageMap<_, Twox64Concat, MarketIdOf, OutcomeReport, OptionQuery>; + StorageMap<_, Twox64Concat, MarketIdOf, AuthorityReport, OptionQuery>; } #[cfg(any(feature = "runtime-benchmarks", test))] -pub(crate) fn market_mock() --> zeitgeist_primitives::types::Market, T::BlockNumber, MomentOf> +pub(crate) fn market_mock() -> MarketOf where T: crate::Config, { use frame_support::traits::Get; use sp_runtime::traits::AccountIdConversion; - use zeitgeist_primitives::types::{MarketBonds, ScoringRule}; + use zeitgeist_primitives::types::{Asset, MarketBonds, ScoringRule}; zeitgeist_primitives::types::Market { + base_asset: Asset::Ztg, creation: zeitgeist_primitives::types::MarketCreation::Permissionless, creator_fee: 0, creator: T::PalletId::get().into_account_truncating(), diff --git a/zrml/authorized/src/migrations.rs b/zrml/authorized/src/migrations.rs index 16887b73b..13a374949 100644 --- a/zrml/authorized/src/migrations.rs +++ b/zrml/authorized/src/migrations.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -14,3 +15,59 @@ // // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . + +// We use these utilities to prevent having to make the swaps pallet a dependency of +// prediciton-markets. The calls are based on the implementation of `StorageVersion`, found here: +// https://github.com/paritytech/substrate/blob/bc7a1e6c19aec92bfa247d8ca68ec63e07061032/frame/support/src/traits/metadata.rs#L168-L230 +// and previous migrations. +mod utility { + use crate::{BalanceOf, Config, MarketIdOf}; + use alloc::vec::Vec; + use frame_support::{ + migration::{get_storage_value, put_storage_value}, + storage::{storage_prefix, unhashed}, + traits::StorageVersion, + Blake2_128Concat, StorageHasher, + }; + use parity_scale_codec::Encode; + use zeitgeist_primitives::types::{Pool, PoolId}; + + #[allow(unused)] + const SWAPS: &[u8] = b"Swaps"; + #[allow(unused)] + const POOLS: &[u8] = b"Pools"; + #[allow(unused)] + fn storage_prefix_of_swaps_pallet() -> [u8; 32] { + storage_prefix(b"Swaps", b":__STORAGE_VERSION__:") + } + #[allow(unused)] + pub fn key_to_hash(key: K) -> Vec + where + H: StorageHasher, + K: Encode, + { + key.using_encoded(H::hash).as_ref().to_vec() + } + #[allow(unused)] + pub fn get_on_chain_storage_version_of_swaps_pallet() -> StorageVersion { + let key = storage_prefix_of_swaps_pallet(); + unhashed::get_or_default(&key) + } + #[allow(unused)] + pub fn put_storage_version_of_swaps_pallet(value: u16) { + let key = storage_prefix_of_swaps_pallet(); + unhashed::put(&key, &StorageVersion::new(value)); + } + #[allow(unused)] + pub fn get_pool(pool_id: PoolId) -> Option, MarketIdOf>> { + let hash = key_to_hash::(pool_id); + let pool_maybe = + get_storage_value::, MarketIdOf>>>(SWAPS, POOLS, &hash); + pool_maybe.unwrap_or(None) + } + #[allow(unused)] + pub fn set_pool(pool_id: PoolId, pool: Pool, MarketIdOf>) { + let hash = key_to_hash::(pool_id); + put_storage_value(SWAPS, POOLS, &hash, Some(pool)); + } +} diff --git a/zrml/authorized/src/mock.rs b/zrml/authorized/src/mock.rs index 7dece7580..f34cdc7bc 100644 --- a/zrml/authorized/src/mock.rs +++ b/zrml/authorized/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,8 +18,16 @@ #![cfg(test)] -use crate::{self as zrml_authorized}; -use frame_support::{construct_runtime, ord_parameter_types, traits::Everything}; +extern crate alloc; + +use crate::{self as zrml_authorized, mock_storage::pallet as mock_storage}; +use alloc::{vec, vec::Vec}; +use frame_support::{ + construct_runtime, ord_parameter_types, + pallet_prelude::{DispatchError, Weight}, + traits::Everything, + BoundedVec, +}; use frame_system::EnsureSignedBy; use sp_runtime::{ testing::Header, @@ -26,11 +35,13 @@ use sp_runtime::{ }; use zeitgeist_primitives::{ constants::mock::{ - AuthorizedPalletId, BlockHashCount, MaxReserves, MinimumPeriod, PmPalletId, BASE, + AuthorizedPalletId, BlockHashCount, CorrectionPeriod, MaxReserves, MinimumPeriod, + PmPalletId, BASE, }, + traits::DisputeResolutionApi, types::{ - AccountIdTest, Balance, BlockNumber, BlockTest, Hash, Index, MarketId, Moment, - UncheckedExtrinsicTest, + AccountIdTest, Asset, Balance, BlockNumber, BlockTest, Hash, Index, Market, MarketDispute, + MarketId, Moment, OutcomeReport, UncheckedExtrinsicTest, }, }; @@ -50,15 +61,81 @@ construct_runtime!( MarketCommons: zrml_market_commons::{Pallet, Storage}, System: frame_system::{Call, Config, Event, Pallet, Storage}, Timestamp: pallet_timestamp::{Pallet}, + // Just a mock storage for testing. + MockStorage: mock_storage::{Storage}, } ); ord_parameter_types! { pub const AuthorizedDisputeResolutionUser: AccountIdTest = ALICE; + pub const MaxDisputes: u32 = 64; +} + +// MockResolution implements DisputeResolutionApi with no-ops. +pub struct MockResolution; + +impl DisputeResolutionApi for MockResolution { + type AccountId = AccountIdTest; + type Balance = Balance; + type BlockNumber = BlockNumber; + type MarketId = MarketId; + type MaxDisputes = MaxDisputes; + type Moment = Moment; + + fn resolve( + _market_id: &Self::MarketId, + _market: &Market< + Self::AccountId, + Self::Balance, + Self::BlockNumber, + Self::Moment, + Asset, + >, + ) -> Result { + Ok(Weight::zero()) + } + + fn add_auto_resolve( + market_id: &Self::MarketId, + resolve_at: Self::BlockNumber, + ) -> Result { + let ids_len = >::try_mutate( + resolve_at, + |ids| -> Result { + ids.try_push(*market_id).map_err(|_| DispatchError::Other("Storage Overflow"))?; + Ok(ids.len() as u32) + }, + )?; + Ok(ids_len) + } + + fn auto_resolve_exists(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> bool { + >::get(resolve_at).contains(market_id) + } + + fn remove_auto_resolve(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> u32 { + >::mutate(resolve_at, |ids| -> u32 { + ids.retain(|id| id != market_id); + ids.len() as u32 + }) + } + + fn get_disputes( + _market_id: &Self::MarketId, + ) -> BoundedVec, Self::MaxDisputes> { + BoundedVec::try_from(vec![MarketDispute { + at: 42u64, + by: BOB, + outcome: OutcomeReport::Scalar(42), + }]) + .unwrap() + } } impl crate::Config for Runtime { - type Event = (); + type RuntimeEvent = (); + type CorrectionPeriod = CorrectionPeriod; + type DisputeResolution = MockResolution; type MarketCommons = MarketCommons; type PalletId = AuthorizedPalletId; type AuthorizedDisputeResolutionOrigin = @@ -66,6 +143,10 @@ impl crate::Config for Runtime { type WeightInfo = crate::weights::WeightInfo; } +impl mock_storage::Config for Runtime { + type MarketCommons = MarketCommons; +} + impl frame_system::Config for Runtime { type AccountData = pallet_balances::AccountData; type AccountId = AccountIdTest; @@ -74,9 +155,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -85,7 +166,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -97,7 +178,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/authorized/src/mock_storage.rs b/zrml/authorized/src/mock_storage.rs new file mode 100644 index 000000000..88bf6c02b --- /dev/null +++ b/zrml/authorized/src/mock_storage.rs @@ -0,0 +1,50 @@ +// Copyright 2023 Forecasting Technologies LTD. +// Copyright 2022 Forecasting Technologies LTD. +// +// This file is part of Zeitgeist. +// +// Zeitgeist 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. +// +// Zeitgeist 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 Zeitgeist. If not, see . + +#![cfg(test)] +#![allow(dead_code)] + +#[frame_support::pallet] +pub(crate) mod pallet { + use core::marker::PhantomData; + use frame_support::pallet_prelude::*; + use zrml_market_commons::MarketCommonsPalletApi; + + pub(crate) type MarketIdOf = + <::MarketCommons as MarketCommonsPalletApi>::MarketId; + + pub type CacheSize = ConstU32<64>; + + #[pallet::config] + pub trait Config: frame_system::Config { + type MarketCommons: MarketCommonsPalletApi; + } + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + /// Only used for testing the dispute resolution API to prediction-markets + #[pallet::storage] + pub(crate) type MarketIdsPerDisputeBlock = StorageMap< + _, + Twox64Concat, + T::BlockNumber, + BoundedVec, CacheSize>, + ValueQuery, + >; +} diff --git a/zrml/authorized/src/tests.rs b/zrml/authorized/src/tests.rs index c74af01d8..3682ac5e1 100644 --- a/zrml/authorized/src/tests.rs +++ b/zrml/authorized/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -19,13 +20,14 @@ use crate::{ market_mock, - mock::{Authorized, AuthorizedDisputeResolutionUser, ExtBuilder, Origin, Runtime, BOB}, + mock::{Authorized, AuthorizedDisputeResolutionUser, ExtBuilder, Runtime, RuntimeOrigin, BOB}, + mock_storage::pallet as mock_storage, AuthorizedOutcomeReports, Error, }; use frame_support::{assert_noop, assert_ok, dispatch::DispatchError}; use zeitgeist_primitives::{ traits::DisputeApi, - types::{MarketDisputeMechanism, MarketStatus, OutcomeReport}, + types::{AuthorityReport, MarketDispute, MarketDisputeMechanism, MarketStatus, OutcomeReport}, }; use zrml_market_commons::Markets; @@ -34,11 +36,50 @@ fn authorize_market_outcome_inserts_a_new_outcome() { ExtBuilder::default().build().execute_with(|| { Markets::::insert(0, market_mock::()); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(1) )); - assert_eq!(AuthorizedOutcomeReports::::get(0).unwrap(), OutcomeReport::Scalar(1)); + let now = frame_system::Pallet::::block_number(); + let resolve_at = now + ::CorrectionPeriod::get(); + assert_eq!( + AuthorizedOutcomeReports::::get(0).unwrap(), + AuthorityReport { outcome: OutcomeReport::Scalar(1), resolve_at } + ); + }); +} + +#[test] +fn authorize_market_outcome_does_not_reset_dispute_resolution() { + ExtBuilder::default().build().execute_with(|| { + Markets::::insert(0, market_mock::()); + + assert_ok!(Authorized::authorize_market_outcome( + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), + 0, + OutcomeReport::Scalar(1), + )); + let now = frame_system::Pallet::::block_number(); + let resolve_at_0 = now + ::CorrectionPeriod::get(); + assert_eq!( + AuthorizedOutcomeReports::::get(0).unwrap(), + AuthorityReport { outcome: OutcomeReport::Scalar(1), resolve_at: resolve_at_0 } + ); + + assert_eq!(mock_storage::MarketIdsPerDisputeBlock::::get(resolve_at_0), vec![0]); + + assert_ok!(Authorized::authorize_market_outcome( + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), + 0, + OutcomeReport::Scalar(2) + )); + + assert_eq!( + AuthorizedOutcomeReports::::get(0).unwrap(), + AuthorityReport { outcome: OutcomeReport::Scalar(2), resolve_at: resolve_at_0 } + ); + + assert_eq!(mock_storage::MarketIdsPerDisputeBlock::::get(resolve_at_0), vec![0]); }); } @@ -47,7 +88,7 @@ fn authorize_market_outcome_fails_if_market_does_not_exist() { ExtBuilder::default().build().execute_with(|| { assert_noop!( Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(1) ), @@ -64,7 +105,7 @@ fn authorize_market_outcome_fails_on_non_authorized_market() { Markets::::insert(0, market); assert_noop!( Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(1) ), @@ -81,7 +122,7 @@ fn authorize_market_outcome_fails_on_undisputed_market() { Markets::::insert(0, market); assert_noop!( Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(1) ), @@ -96,7 +137,7 @@ fn authorize_market_outcome_fails_on_invalid_report() { Markets::::insert(0, market_mock::()); assert_noop!( Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Categorical(123) ), @@ -110,12 +151,28 @@ fn authorize_market_outcome_fails_on_unauthorized_account() { ExtBuilder::default().build().execute_with(|| { Markets::::insert(0, market_mock::()); assert_noop!( - Authorized::authorize_market_outcome(Origin::signed(BOB), 0, OutcomeReport::Scalar(1)), + Authorized::authorize_market_outcome( + RuntimeOrigin::signed(BOB), + 0, + OutcomeReport::Scalar(1) + ), DispatchError::BadOrigin, ); }); } +#[test] +fn on_dispute_fails_if_disputes_is_not_empty() { + ExtBuilder::default().build().execute_with(|| { + let dispute = + MarketDispute { by: crate::mock::ALICE, at: 0, outcome: OutcomeReport::Scalar(1) }; + assert_noop!( + Authorized::on_dispute(&[dispute], &0, &market_mock::()), + Error::::OnlyOneDisputeAllowed + ); + }); +} + #[test] fn on_resolution_fails_if_no_report_was_submitted() { ExtBuilder::default().build().execute_with(|| { @@ -130,7 +187,7 @@ fn on_resolution_removes_stored_outcomes() { let market = market_mock::(); Markets::::insert(0, &market); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(2) )); @@ -146,12 +203,12 @@ fn on_resolution_returns_the_reported_outcome() { Markets::::insert(0, &market); // Authorize outcome, then overwrite it. assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(1) )); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(2) )); @@ -168,22 +225,49 @@ fn authorized_market_outcome_can_handle_multiple_markets() { Markets::::insert(0, market_mock::()); Markets::::insert(1, market_mock::()); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Scalar(123) )); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 1, OutcomeReport::Scalar(456) )); + let now = frame_system::Pallet::::block_number(); + let resolve_at = now + ::CorrectionPeriod::get(); assert_eq!( AuthorizedOutcomeReports::::get(0).unwrap(), - OutcomeReport::Scalar(123) + AuthorityReport { outcome: OutcomeReport::Scalar(123), resolve_at } ); assert_eq!( AuthorizedOutcomeReports::::get(1).unwrap(), - OutcomeReport::Scalar(456) + AuthorityReport { outcome: OutcomeReport::Scalar(456), resolve_at } ); }); } + +#[test] +fn get_auto_resolve_works() { + ExtBuilder::default().build().execute_with(|| { + frame_system::Pallet::::set_block_number(42); + let market = market_mock::(); + Markets::::insert(0, &market); + assert_ok!(Authorized::authorize_market_outcome( + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), + 0, + OutcomeReport::Scalar(1) + )); + let now = frame_system::Pallet::::block_number(); + let resolve_at = now + ::CorrectionPeriod::get(); + assert_eq!(Authorized::get_auto_resolve(&[], &0, &market).unwrap(), Some(resolve_at),); + }); +} + +#[test] +fn get_auto_resolve_returns_none_without_market_storage() { + ExtBuilder::default().build().execute_with(|| { + let market = market_mock::(); + assert_eq!(Authorized::get_auto_resolve(&[], &0, &market).unwrap(), None,); + }); +} diff --git a/zrml/authorized/src/weights.rs b/zrml/authorized/src/weights.rs index fb76eadbb..0b9b6375f 100644 --- a/zrml/authorized/src/weights.rs +++ b/zrml/authorized/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_authorized //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -45,17 +46,28 @@ use frame_support::{traits::Get, weights::Weight}; /// Trait containing the required functions for weight retrival within /// zrml_authorized (automatically generated) pub trait WeightInfoZeitgeist { - fn authorize_market_outcome() -> Weight; + fn authorize_market_outcome_first_report(m: u32) -> Weight; + fn authorize_market_outcome_existing_report() -> Weight; } /// Weight functions for zrml_authorized (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { // Storage: MarketCommons Markets (r:1 w:0) - // Storage: Authorized AuthorizedOutcomeReports (r:0 w:1) - fn authorize_market_outcome() -> Weight { - (16_170_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) + // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) + fn authorize_market_outcome_first_report(m: u32) -> Weight { + Weight::from_ref_time(39_743_715) + // Standard Error: 1_509 + .saturating_add(Weight::from_ref_time(163_846).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: MarketCommons Markets (r:1 w:0) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) + fn authorize_market_outcome_existing_report() -> Weight { + Weight::from_ref_time(33_991_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/court/Cargo.toml b/zrml/court/Cargo.toml index 50eb1e5c9..587ce33ba 100644 --- a/zrml/court/Cargo.toml +++ b/zrml/court/Cargo.toml @@ -1,20 +1,20 @@ [dependencies] arrayvec = { default-features = false, version = "0.7" } -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } rand = { default-features = false, features = ["alloc", "std_rng"], version = "0.8" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-market-commons = { default-features = false, path = "../market-commons" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-randomness-collective-flip = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-randomness-collective-flip = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -41,4 +41,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-court" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/court/src/benchmarks.rs b/zrml/court/src/benchmarks.rs index e1b86b30c..829695001 100644 --- a/zrml/court/src/benchmarks.rs +++ b/zrml/court/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "runtime-benchmarks")] diff --git a/zrml/court/src/lib.rs b/zrml/court/src/lib.rs index ce0d064c4..7c5b091c4 100644 --- a/zrml/court/src/lib.rs +++ b/zrml/court/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -50,6 +51,7 @@ mod pallet { use core::marker::PhantomData; use frame_support::{ dispatch::DispatchResult, + ensure, pallet_prelude::{CountedStorageMap, StorageDoubleMap, StorageValue, ValueQuery}, traits::{ BalanceStatus, Currency, Get, Hooks, IsType, NamedReservableCurrency, Randomness, @@ -64,8 +66,8 @@ mod pallet { ArithmeticError, DispatchError, SaturatedConversion, }; use zeitgeist_primitives::{ - traits::DisputeApi, - types::{Market, MarketDispute, MarketDisputeMechanism, OutcomeReport}, + traits::{DisputeApi, DisputeResolutionApi}, + types::{Asset, Market, MarketDispute, MarketDisputeMechanism, OutcomeReport}, }; use zrml_market_commons::MarketCommonsPalletApi; @@ -93,6 +95,7 @@ mod pallet { BalanceOf, ::BlockNumber, MomentOf, + Asset>, >; #[pallet::call] @@ -150,14 +153,18 @@ mod pallet { #[pallet::constant] type CourtCaseDuration: Get; + type DisputeResolution: DisputeResolutionApi< + AccountId = Self::AccountId, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + >; + /// Event - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Market commons - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - >; + type MarketCommons: MarketCommonsPalletApi; /// Identifier of this pallet #[pallet::constant] @@ -499,16 +506,17 @@ mod pallet { type BlockNumber = T::BlockNumber; type MarketId = MarketIdOf; type Moment = MomentOf; - type Origin = T::Origin; + type Origin = T::RuntimeOrigin; fn on_dispute( disputes: &[MarketDispute], market_id: &Self::MarketId, market: &MarketOf, ) -> DispatchResult { - if market.dispute_mechanism != MarketDisputeMechanism::Court { - return Err(Error::::MarketDoesNotHaveCourtMechanism.into()); - } + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Court, + Error::::MarketDoesNotHaveCourtMechanism + ); let jurors: Vec<_> = Jurors::::iter().collect(); let necessary_jurors_num = Self::necessary_jurors_num(disputes); let mut rng = Self::rng(); @@ -530,9 +538,10 @@ mod pallet { market_id: &Self::MarketId, market: &MarketOf, ) -> Result, DispatchError> { - if market.dispute_mechanism != MarketDisputeMechanism::Court { - return Err(Error::::MarketDoesNotHaveCourtMechanism.into()); - } + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Court, + Error::::MarketDoesNotHaveCourtMechanism + ); let votes: Vec<_> = Votes::::iter_prefix(market_id).collect(); let requested_jurors: Vec<_> = RequestedJurors::::iter_prefix(market_id) .map(|(juror_id, max_allowed_block)| { @@ -552,6 +561,30 @@ mod pallet { let _ = RequestedJurors::::clear_prefix(market_id, u32::max_value(), None); Ok(Some(first)) } + + fn get_auto_resolve( + _: &[MarketDispute], + _: &Self::MarketId, + market: &MarketOf, + ) -> Result, DispatchError> { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Court, + Error::::MarketDoesNotHaveCourtMechanism + ); + Ok(None) + } + + fn has_failed( + _: &[MarketDispute], + _: &Self::MarketId, + market: &MarketOf, + ) -> Result { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::Court, + Error::::MarketDoesNotHaveCourtMechanism + ); + Ok(false) + } } impl CourtPalletApi for Pallet where T: Config {} diff --git a/zrml/court/src/mock.rs b/zrml/court/src/mock.rs index 6d14af846..9167f6dc3 100644 --- a/zrml/court/src/mock.rs +++ b/zrml/court/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,13 @@ #![cfg(test)] use crate::{self as zrml_court}; -use frame_support::{construct_runtime, parameter_types, traits::Everything, PalletId}; +use frame_support::{ + construct_runtime, + pallet_prelude::{DispatchError, Weight}, + parameter_types, + traits::Everything, + BoundedVec, PalletId, +}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, @@ -28,9 +35,10 @@ use zeitgeist_primitives::{ BlockHashCount, CourtCaseDuration, CourtPalletId, MaxReserves, MinimumPeriod, PmPalletId, StakeWeight, BASE, }, + traits::DisputeResolutionApi, types::{ - AccountIdTest, Balance, BlockNumber, BlockTest, Hash, Index, MarketId, Moment, - UncheckedExtrinsicTest, + AccountIdTest, Asset, Balance, BlockNumber, BlockTest, Hash, Index, Market, MarketDispute, + MarketId, Moment, UncheckedExtrinsicTest, }, }; @@ -59,9 +67,56 @@ construct_runtime!( } ); +// NoopResolution implements DisputeResolutionApi with no-ops. +pub struct NoopResolution; + +impl DisputeResolutionApi for NoopResolution { + type AccountId = AccountIdTest; + type Balance = Balance; + type BlockNumber = BlockNumber; + type MarketId = MarketId; + type MaxDisputes = u32; + type Moment = Moment; + + fn resolve( + _market_id: &Self::MarketId, + _market: &Market< + Self::AccountId, + Self::Balance, + Self::BlockNumber, + Self::Moment, + Asset, + >, + ) -> Result { + Ok(Weight::zero()) + } + + fn add_auto_resolve( + _market_id: &Self::MarketId, + _resolve_at: Self::BlockNumber, + ) -> Result { + Ok(0u32) + } + + fn auto_resolve_exists(_market_id: &Self::MarketId, _resolve_at: Self::BlockNumber) -> bool { + false + } + + fn remove_auto_resolve(_market_id: &Self::MarketId, _resolve_at: Self::BlockNumber) -> u32 { + 0u32 + } + + fn get_disputes( + _market_id: &Self::MarketId, + ) -> BoundedVec, Self::MaxDisputes> { + Default::default() + } +} + impl crate::Config for Runtime { type CourtCaseDuration = CourtCaseDuration; - type Event = (); + type DisputeResolution = NoopResolution; + type RuntimeEvent = (); type MarketCommons = MarketCommons; type PalletId = CourtPalletId; type Random = RandomnessCollectiveFlip; @@ -78,9 +133,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -89,7 +144,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -101,7 +156,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/court/src/tests.rs b/zrml/court/src/tests.rs index c2ecc4b32..48fc37a10 100644 --- a/zrml/court/src/tests.rs +++ b/zrml/court/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -19,8 +20,8 @@ use crate::{ mock::{ - Balances, Court, ExtBuilder, Origin, RandomnessCollectiveFlip, Runtime, System, ALICE, BOB, - CHARLIE, INITIAL_BALANCE, + Balances, Court, ExtBuilder, RandomnessCollectiveFlip, Runtime, RuntimeOrigin, System, + ALICE, BOB, CHARLIE, INITIAL_BALANCE, }, Error, Juror, JurorStatus, Jurors, MarketOf, RequestedJurors, Votes, }; @@ -32,12 +33,13 @@ use zeitgeist_primitives::{ constants::BASE, traits::DisputeApi, types::{ - Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, - MarketStatus, MarketType, OutcomeReport, ScoringRule, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, + MarketPeriod, MarketStatus, MarketType, OutcomeReport, ScoringRule, }, }; const DEFAULT_MARKET: MarketOf = Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: 0, @@ -51,7 +53,7 @@ const DEFAULT_MARKET: MarketOf = Market { resolved_outcome: None, status: MarketStatus::Closed, scoring_rule: ScoringRule::CPMM, - bonds: MarketBonds { creation: None, oracle: None }, + bonds: MarketBonds { creation: None, oracle: None, outsider: None }, }; const DEFAULT_SET_OF_JURORS: &[(u128, Juror)] = &[ (7, Juror { status: JurorStatus::Ok }), @@ -66,11 +68,11 @@ const DEFAULT_SET_OF_JURORS: &[(u128, Juror)] = &[ #[test] fn exit_court_successfully_removes_a_juror_and_frees_balances() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(Court::join_court(Origin::signed(ALICE))); + assert_ok!(Court::join_court(RuntimeOrigin::signed(ALICE))); assert_eq!(Jurors::::iter().count(), 1); assert_eq!(Balances::free_balance(ALICE), 998 * BASE); assert_eq!(Balances::reserved_balance_named(&Court::reserve_id(), &ALICE), 2 * BASE); - assert_ok!(Court::exit_court(Origin::signed(ALICE))); + assert_ok!(Court::exit_court(RuntimeOrigin::signed(ALICE))); assert_eq!(Jurors::::iter().count(), 0); assert_eq!(Balances::free_balance(ALICE), INITIAL_BALANCE); assert_eq!(Balances::reserved_balance_named(&Court::reserve_id(), &ALICE), 0); @@ -81,7 +83,7 @@ fn exit_court_successfully_removes_a_juror_and_frees_balances() { fn exit_court_will_not_remove_an_unknown_juror() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - Court::exit_court(Origin::signed(ALICE)), + Court::exit_court(RuntimeOrigin::signed(ALICE)), Error::::JurorDoesNotExists ); }); @@ -91,12 +93,12 @@ fn exit_court_will_not_remove_an_unknown_juror() { fn join_court_reserves_balance_according_to_the_number_of_jurors() { ExtBuilder::default().build().execute_with(|| { assert_eq!(Balances::free_balance(ALICE), 1000 * BASE); - assert_ok!(Court::join_court(Origin::signed(ALICE))); + assert_ok!(Court::join_court(RuntimeOrigin::signed(ALICE))); assert_eq!(Balances::free_balance(ALICE), 998 * BASE); assert_eq!(Balances::reserved_balance_named(&Court::reserve_id(), &ALICE), 2 * BASE); assert_eq!(Balances::free_balance(BOB), 1000 * BASE); - assert_ok!(Court::join_court(Origin::signed(BOB))); + assert_ok!(Court::join_court(RuntimeOrigin::signed(BOB))); assert_eq!(Balances::free_balance(BOB), 996 * BASE); assert_eq!(Balances::reserved_balance_named(&Court::reserve_id(), &BOB), 4 * BASE); }); @@ -105,7 +107,7 @@ fn join_court_reserves_balance_according_to_the_number_of_jurors() { #[test] fn join_court_successfully_stores_a_juror() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(Court::join_court(Origin::signed(ALICE))); + assert_ok!(Court::join_court(RuntimeOrigin::signed(ALICE))); assert_eq!( Jurors::::iter().next().unwrap(), (ALICE, Juror { status: JurorStatus::Ok }) @@ -116,9 +118,9 @@ fn join_court_successfully_stores_a_juror() { #[test] fn join_court_will_not_insert_an_already_stored_juror() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(Court::join_court(Origin::signed(ALICE))); + assert_ok!(Court::join_court(RuntimeOrigin::signed(ALICE))); assert_noop!( - Court::join_court(Origin::signed(ALICE)), + Court::join_court(RuntimeOrigin::signed(ALICE)), Error::::JurorAlreadyExists ); }); @@ -152,11 +154,11 @@ fn on_resolution_denies_non_court_markets() { fn on_dispute_stores_jurors_that_should_vote() { ExtBuilder::default().build().execute_with(|| { setup_blocks(123); - let _ = Court::join_court(Origin::signed(ALICE)); - let _ = Court::join_court(Origin::signed(BOB)); + let _ = Court::join_court(RuntimeOrigin::signed(ALICE)); + let _ = Court::join_court(RuntimeOrigin::signed(BOB)); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); assert_noop!( - Court::join_court(Origin::signed(ALICE)), + Court::join_court(RuntimeOrigin::signed(ALICE)), Error::::JurorAlreadyExists ); assert_eq!(RequestedJurors::::iter().count(), 2); @@ -168,13 +170,13 @@ fn on_dispute_stores_jurors_that_should_vote() { fn on_resolution_awards_winners_and_slashes_losers() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); - Court::join_court(Origin::signed(CHARLIE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); + Court::join_court(RuntimeOrigin::signed(CHARLIE)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(BOB), 0, OutcomeReport::Scalar(2)).unwrap(); - Court::vote(Origin::signed(CHARLIE), 0, OutcomeReport::Scalar(3)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(2)).unwrap(); + Court::vote(RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Scalar(3)).unwrap(); let _ = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); assert_eq!(Balances::free_balance(ALICE), 998 * BASE + 3 * BASE); assert_eq!(Balances::reserved_balance_named(&Court::reserve_id(), &ALICE), 2 * BASE); @@ -189,13 +191,13 @@ fn on_resolution_awards_winners_and_slashes_losers() { fn on_resolution_decides_market_outcome_based_on_the_majority() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); - Court::join_court(Origin::signed(CHARLIE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); + Court::join_court(RuntimeOrigin::signed(CHARLIE)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); let outcome = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); assert_eq!(outcome, Some(OutcomeReport::Scalar(1))); }); @@ -205,9 +207,9 @@ fn on_resolution_decides_market_outcome_based_on_the_majority() { fn on_resolution_sets_late_jurors_as_tardy() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); let _ = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); assert_eq!(Jurors::::get(ALICE).unwrap().status, JurorStatus::Ok); @@ -219,13 +221,13 @@ fn on_resolution_sets_late_jurors_as_tardy() { fn on_resolution_sets_jurors_that_voted_on_the_second_most_voted_outcome_as_tardy() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); - Court::join_court(Origin::signed(CHARLIE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); + Court::join_court(RuntimeOrigin::signed(CHARLIE)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); let _ = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); assert_eq!(Jurors::::get(CHARLIE).unwrap().status, JurorStatus::Tardy); }); @@ -235,10 +237,10 @@ fn on_resolution_sets_jurors_that_voted_on_the_second_most_voted_outcome_as_tard fn on_resolution_punishes_tardy_jurors_that_failed_to_vote_a_second_time() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); Court::set_stored_juror_as_tardy(&BOB).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); let _ = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); let join_court_stake = 40000000000; @@ -253,13 +255,13 @@ fn on_resolution_punishes_tardy_jurors_that_failed_to_vote_a_second_time() { fn on_resolution_removes_requested_jurors_and_votes() { ExtBuilder::default().build().execute_with(|| { setup_blocks(2); - Court::join_court(Origin::signed(ALICE)).unwrap(); - Court::join_court(Origin::signed(BOB)).unwrap(); - Court::join_court(Origin::signed(CHARLIE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(ALICE)).unwrap(); + Court::join_court(RuntimeOrigin::signed(BOB)).unwrap(); + Court::join_court(RuntimeOrigin::signed(CHARLIE)).unwrap(); Court::on_dispute(&[], &0, &DEFAULT_MARKET).unwrap(); - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); - Court::vote(Origin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(1)).unwrap(); + Court::vote(RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Scalar(2)).unwrap(); let _ = Court::on_resolution(&[], &0, &DEFAULT_MARKET).unwrap(); assert_eq!(RequestedJurors::::iter().count(), 0); assert_eq!(Votes::::iter().count(), 0); @@ -316,7 +318,7 @@ fn random_jurors_returns_a_subset_of_jurors() { fn vote_will_not_accept_unknown_accounts() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(0)), + Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(0)), Error::::OnlyJurorsCanVote ); }); @@ -325,8 +327,8 @@ fn vote_will_not_accept_unknown_accounts() { #[test] fn vote_will_stored_outcome_from_a_juror() { ExtBuilder::default().build().execute_with(|| { - let _ = Court::join_court(Origin::signed(ALICE)); - let _ = Court::vote(Origin::signed(ALICE), 0, OutcomeReport::Scalar(0)); + let _ = Court::join_court(RuntimeOrigin::signed(ALICE)); + let _ = Court::vote(RuntimeOrigin::signed(ALICE), 0, OutcomeReport::Scalar(0)); assert_eq!(Votes::::get(ALICE, 0).unwrap(), (0, OutcomeReport::Scalar(0))); }); } diff --git a/zrml/court/src/weights.rs b/zrml/court/src/weights.rs index 0989647b2..97f3faef7 100644 --- a/zrml/court/src/weights.rs +++ b/zrml/court/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_court //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -59,23 +60,23 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: Court RequestedJurors (r:1 w:0) // Storage: Court Votes (r:1 w:0) fn exit_court() -> Weight { - (78_840_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(77_001_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Court Jurors (r:1 w:1) // Storage: Court CounterForJurors (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) fn join_court() -> Weight { - (56_951_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(55_990_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Court Jurors (r:1 w:0) // Storage: Court Votes (r:0 w:1) fn vote() -> Weight { - (18_980_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_410_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/global-disputes/Cargo.toml b/zrml/global-disputes/Cargo.toml index 2496e8509..77ca074eb 100644 --- a/zrml/global-disputes/Cargo.toml +++ b/zrml/global-disputes/Cargo.toml @@ -1,11 +1,11 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-std = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-std = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-market-commons = { default-features = false, path = "../market-commons" } @@ -14,9 +14,9 @@ num-traits = { version = "0.2.15", default-features = false, optional = true } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } test-case = "2.0.2" @@ -45,4 +45,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-global-disputes" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/global-disputes/src/benchmarks.rs b/zrml/global-disputes/src/benchmarks.rs index 486d08cae..2fb52724b 100644 --- a/zrml/global-disputes/src/benchmarks.rs +++ b/zrml/global-disputes/src/benchmarks.rs @@ -1,5 +1,4 @@ -// Copyright 2022 Forecasting Technologies LTD. -// Copyright 2022 Zeitgeist PM LLC. +// Copyright 2022-2023 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -20,7 +19,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "runtime-benchmarks")] @@ -48,7 +47,7 @@ where T::Currency::deposit_creating(caller, BalanceOf::::max_value() / 2u128.saturated_into()); } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/zrml/global-disputes/src/global_disputes_pallet_api.rs b/zrml/global-disputes/src/global_disputes_pallet_api.rs index b4a14cae7..26682c768 100644 --- a/zrml/global-disputes/src/global_disputes_pallet_api.rs +++ b/zrml/global-disputes/src/global_disputes_pallet_api.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/zrml/global-disputes/src/lib.rs b/zrml/global-disputes/src/lib.rs index e71ed9e76..14b594ea8 100644 --- a/zrml/global-disputes/src/lib.rs +++ b/zrml/global-disputes/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -58,7 +58,7 @@ mod pallet { /// The currency implementation used to lock tokens for voting. type Currency: LockableCurrency; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The vote lock identifier. #[pallet::constant] @@ -69,10 +69,7 @@ mod pallet { type GlobalDisputesPalletId: Get; /// To reference the market id type. - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - >; + type MarketCommons: MarketCommonsPalletApi; /// The maximum numbers of distinct markets /// on which one account can simultaneously vote on outcomes. diff --git a/zrml/global-disputes/src/mock.rs b/zrml/global-disputes/src/mock.rs index 94c87681d..82750e2ed 100644 --- a/zrml/global-disputes/src/mock.rs +++ b/zrml/global-disputes/src/mock.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -63,7 +63,7 @@ parameter_types! { impl crate::Config for Runtime { type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type GlobalDisputeLockId = GlobalDisputeLockId; type GlobalDisputesPalletId = GlobalDisputesPalletId; type MarketCommons = MarketCommons; @@ -83,9 +83,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -94,7 +94,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -106,7 +106,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/global-disputes/src/tests.rs b/zrml/global-disputes/src/tests.rs index 8c46b357d..d3efbfd30 100644 --- a/zrml/global-disputes/src/tests.rs +++ b/zrml/global-disputes/src/tests.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // @@ -79,11 +79,11 @@ fn add_vote_outcome_works() { 10 * BASE, ) .unwrap(); - let free_balance_alice_before = Balances::free_balance(&ALICE); + let free_balance_alice_before = Balances::free_balance(ALICE); let free_balance_reward_account = Balances::free_balance(GlobalDisputes::reward_account(&market_id)); assert_ok!(GlobalDisputes::add_vote_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), )); @@ -96,7 +96,7 @@ fn add_vote_outcome_works() { .into(), ); assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), free_balance_alice_before - VotingOutcomeFee::get() ); assert_eq!( @@ -112,7 +112,7 @@ fn add_vote_outcome_fails_if_no_global_dispute_present() { let market_id = 0u128; assert_noop!( GlobalDisputes::add_vote_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), ), @@ -131,7 +131,7 @@ fn add_vote_outcome_fails_if_global_dispute_finished() { assert_noop!( GlobalDisputes::add_vote_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), ), @@ -158,7 +158,7 @@ fn add_vote_outcome_fails_if_outcome_already_exists() { ); assert_noop!( GlobalDisputes::add_vote_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), ), @@ -180,7 +180,7 @@ fn add_vote_outcome_fails_if_balance_too_low() { .unwrap(); assert_noop!( GlobalDisputes::add_vote_outcome( - Origin::signed(POOR_PAUL), + RuntimeOrigin::signed(POOR_PAUL), market_id, OutcomeReport::Scalar(20), ), @@ -212,15 +212,15 @@ fn reward_outcome_owner_works_for_multiple_owners() { }; >::insert(market_id, winner_info); - let free_balance_alice_before = Balances::free_balance(&ALICE); - let free_balance_bob_before = Balances::free_balance(&BOB); - let free_balance_charlie_before = Balances::free_balance(&CHARLIE); + let free_balance_alice_before = Balances::free_balance(ALICE); + let free_balance_bob_before = Balances::free_balance(BOB); + let free_balance_charlie_before = Balances::free_balance(CHARLIE); - assert_ok!(GlobalDisputes::purge_outcomes(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::purge_outcomes(RuntimeOrigin::signed(ALICE), market_id,)); System::assert_last_event(Event::::OutcomesFullyCleaned { market_id }.into()); - assert_ok!(GlobalDisputes::reward_outcome_owner(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::reward_outcome_owner(RuntimeOrigin::signed(ALICE), market_id,)); System::assert_last_event( Event::::OutcomeOwnersRewarded { @@ -230,12 +230,12 @@ fn reward_outcome_owner_works_for_multiple_owners() { .into(), ); assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), free_balance_alice_before + VotingOutcomeFee::get() ); - assert_eq!(Balances::free_balance(&BOB), free_balance_bob_before + VotingOutcomeFee::get()); + assert_eq!(Balances::free_balance(BOB), free_balance_bob_before + VotingOutcomeFee::get()); assert_eq!( - Balances::free_balance(&CHARLIE), + Balances::free_balance(CHARLIE), free_balance_charlie_before + VotingOutcomeFee::get() ); assert!(Balances::free_balance(GlobalDisputes::reward_account(&market_id)).is_zero()); @@ -264,9 +264,9 @@ fn reward_outcome_owner_has_dust() { }; >::insert(market_id, winner_info); - assert_ok!(GlobalDisputes::purge_outcomes(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::purge_outcomes(RuntimeOrigin::signed(ALICE), market_id,)); - assert_ok!(GlobalDisputes::reward_outcome_owner(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::reward_outcome_owner(RuntimeOrigin::signed(ALICE), market_id,)); // 100 * BASE = 1_000_000_000_000 checked_div 6 = 166_666_666_666 // 166_666_666_666 * 6 = 999_999_999_996 so 4 left @@ -297,20 +297,20 @@ fn reward_outcome_owner_works_for_one_owner() { }; >::insert(market_id, winner_info); - assert_ok!(GlobalDisputes::purge_outcomes(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::purge_outcomes(RuntimeOrigin::signed(ALICE), market_id,)); System::assert_last_event(Event::::OutcomesFullyCleaned { market_id }.into()); - let free_balance_alice_before = Balances::free_balance(&ALICE); + let free_balance_alice_before = Balances::free_balance(ALICE); - assert_ok!(GlobalDisputes::reward_outcome_owner(Origin::signed(ALICE), market_id)); + assert_ok!(GlobalDisputes::reward_outcome_owner(RuntimeOrigin::signed(ALICE), market_id)); System::assert_last_event( Event::::OutcomeOwnersRewarded { market_id, owners: vec![ALICE] }.into(), ); assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), free_balance_alice_before + 3 * VotingOutcomeFee::get() ); assert!(Balances::free_balance(GlobalDisputes::reward_account(&market_id)).is_zero()); @@ -332,25 +332,25 @@ fn reward_outcome_owner_works_for_no_reward_funds() { }; >::insert(market_id, winner_info); - assert_ok!(GlobalDisputes::purge_outcomes(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::purge_outcomes(RuntimeOrigin::signed(ALICE), market_id,)); System::assert_last_event(Event::::OutcomesFullyCleaned { market_id }.into()); - let free_balance_alice_before = Balances::free_balance(&ALICE); + let free_balance_alice_before = Balances::free_balance(ALICE); let reward_account_free_balance = - Balances::free_balance(&GlobalDisputes::reward_account(&market_id)); + Balances::free_balance(GlobalDisputes::reward_account(&market_id)); // this case happens, when add_vote_outcome wasn't called // so no loosers, who provided the VotingOutcomeFee assert!(reward_account_free_balance.is_zero()); - assert_ok!(GlobalDisputes::reward_outcome_owner(Origin::signed(ALICE), market_id)); + assert_ok!(GlobalDisputes::reward_outcome_owner(RuntimeOrigin::signed(ALICE), market_id)); System::assert_last_event( Event::::OutcomeOwnersRewardedWithNoFunds { market_id }.into(), ); - assert_eq!(Balances::free_balance(&ALICE), free_balance_alice_before); + assert_eq!(Balances::free_balance(ALICE), free_balance_alice_before); assert!(Balances::free_balance(GlobalDisputes::reward_account(&market_id)).is_zero()); assert!(>::iter_prefix(market_id).next().is_none()); }); @@ -391,7 +391,7 @@ fn vote_fails_if_amount_below_min_outcome_vote_amount() { assert_noop!( GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(40), MinOutcomeVoteAmount::get() - 1, @@ -422,7 +422,7 @@ fn vote_fails_for_insufficient_funds() { // Paul does not have 50 * BASE assert_noop!( GlobalDisputes::vote_on_outcome( - Origin::signed(POOR_PAUL), + RuntimeOrigin::signed(POOR_PAUL), market_id, OutcomeReport::Scalar(0), 50 * BASE @@ -440,28 +440,28 @@ fn determine_voting_winner_sets_the_last_outcome_for_same_vote_balances_as_the_c setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(0), 42 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(20), 42 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(40), 42 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(60), 42 * BASE @@ -485,7 +485,7 @@ fn vote_on_outcome_check_event() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(60), 42 * BASE @@ -537,7 +537,7 @@ fn reserve_before_init_vote_outcome_is_not_allowed_for_voting() { assert_noop!( GlobalDisputes::vote_on_outcome( - Origin::signed(*disputor), + RuntimeOrigin::signed(*disputor), market_id, OutcomeReport::Scalar(0), arbitrary_amount + 1 @@ -546,7 +546,7 @@ fn reserve_before_init_vote_outcome_is_not_allowed_for_voting() { ); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(*disputor), + RuntimeOrigin::signed(*disputor), market_id, OutcomeReport::Scalar(0), arbitrary_amount @@ -573,7 +573,7 @@ fn transfer_fails_with_fully_locked_balance() { let arbitrary_amount = 42 * BASE; assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(*disputor), + RuntimeOrigin::signed(*disputor), market_id, OutcomeReport::Scalar(0), free_balance_disputor_before - arbitrary_amount @@ -586,10 +586,10 @@ fn transfer_fails_with_fully_locked_balance() { ); assert_noop!( - Balances::transfer(Origin::signed(*disputor), BOB, arbitrary_amount + 1), + Balances::transfer(RuntimeOrigin::signed(*disputor), BOB, arbitrary_amount + 1), pallet_balances::Error::::LiquidityRestrictions ); - assert_ok!(Balances::transfer(Origin::signed(*disputor), BOB, arbitrary_amount)); + assert_ok!(Balances::transfer(RuntimeOrigin::signed(*disputor), BOB, arbitrary_amount)); }); } @@ -605,7 +605,7 @@ fn reserve_fails_with_fully_locked_balance() { let arbitrary_amount = 42 * BASE; assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(*disputor), + RuntimeOrigin::signed(*disputor), market_id, OutcomeReport::Scalar(0), free_balance_disputor_before - arbitrary_amount @@ -633,26 +633,26 @@ fn determine_voting_winner_works_four_outcome_votes() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(0), 10 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(20), 10 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(40), 11 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(60), 10 * BASE @@ -680,25 +680,25 @@ fn determine_voting_winner_works_three_outcome_votes() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), 30 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(40), 50 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(0), 10 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(0), 41 * BASE @@ -724,25 +724,25 @@ fn determine_voting_winner_works_two_outcome_votes() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(60), 10 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(20), 50 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(60), 20 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(60), 21 * BASE @@ -768,7 +768,7 @@ fn determine_voting_winner_works_with_accumulated_votes_for_alice() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), BASE @@ -776,7 +776,7 @@ fn determine_voting_winner_works_with_accumulated_votes_for_alice() { check_outcome_sum(&market_id, OutcomeReport::Scalar(20), BASE); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(0), 10 * BASE @@ -784,7 +784,7 @@ fn determine_voting_winner_works_with_accumulated_votes_for_alice() { check_outcome_sum(&market_id, OutcomeReport::Scalar(0), 10 * BASE); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), 10 * BASE @@ -792,7 +792,7 @@ fn determine_voting_winner_works_with_accumulated_votes_for_alice() { check_outcome_sum(&market_id, OutcomeReport::Scalar(20), 11 * BASE); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(0), 40 * BASE @@ -802,7 +802,7 @@ fn determine_voting_winner_works_with_accumulated_votes_for_alice() { // Now Alice wins again assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(20), 40 * BASE @@ -826,14 +826,14 @@ fn reward_outcome_owner_cleans_outcome_info() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(0), 10 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(20), 10 * BASE @@ -845,14 +845,14 @@ fn reward_outcome_owner_cleans_outcome_info() { assert!(GlobalDisputes::determine_voting_winner(&market_id).is_some()); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); - assert_ok!(GlobalDisputes::purge_outcomes(Origin::signed(ALICE), market_id,)); + assert_ok!(GlobalDisputes::purge_outcomes(RuntimeOrigin::signed(ALICE), market_id,)); System::assert_last_event(Event::::OutcomesFullyCleaned { market_id }.into()); - assert_ok!(GlobalDisputes::reward_outcome_owner(Origin::signed(BOB), market_id,)); + assert_ok!(GlobalDisputes::reward_outcome_owner(RuntimeOrigin::signed(BOB), market_id,)); assert_eq!(>::iter_prefix(market_id).next(), None); }); @@ -866,7 +866,7 @@ fn unlock_clears_lock_info() { setup_vote_outcomes_with_hundred(&market_id); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(0), 50 * BASE @@ -876,7 +876,7 @@ fn unlock_clears_lock_info() { assert_eq!(>::get(ALICE), vec![(market_id, 50 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![]); }); @@ -917,7 +917,7 @@ fn vote_fails_if_outcome_does_not_exist() { assert_noop!( GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(42), 50 * BASE @@ -944,25 +944,25 @@ fn locking_works_for_one_market() { assert!(Balances::locks(EVE).is_empty()); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id, OutcomeReport::Scalar(0), 50 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Scalar(20), 40 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Scalar(40), 30 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), market_id, OutcomeReport::Scalar(60), 20 * BASE @@ -982,7 +982,7 @@ fn locking_works_for_one_market() { assert_eq!(>::get(ALICE), vec![(market_id, 50 * BASE)]); assert_eq!(Balances::locks(ALICE), vec![the_lock(50 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![]); assert!(Balances::locks(ALICE).is_empty()); @@ -993,7 +993,7 @@ fn locking_works_for_one_market() { assert_eq!(>::get(EVE), vec![(market_id, 20 * BASE)]); assert_eq!(Balances::locks(EVE), vec![the_lock(20 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); assert_eq!(>::get(BOB), vec![]); assert!(Balances::locks(BOB).is_empty()); assert_eq!(>::get(CHARLIE), vec![(market_id, 30 * BASE)]); @@ -1001,13 +1001,13 @@ fn locking_works_for_one_market() { assert_eq!(>::get(EVE), vec![(market_id, 20 * BASE)]); assert_eq!(Balances::locks(EVE), vec![the_lock(20 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(CHARLIE), CHARLIE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(CHARLIE), CHARLIE)); assert_eq!(>::get(CHARLIE), vec![]); assert!(Balances::locks(CHARLIE).is_empty()); assert_eq!(>::get(EVE), vec![(market_id, 20 * BASE)]); assert_eq!(Balances::locks(EVE), vec![the_lock(20 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(EVE), EVE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(EVE), EVE)); assert_eq!(>::get(EVE), vec![]); assert!(Balances::locks(EVE).is_empty()); }); @@ -1028,26 +1028,26 @@ fn locking_works_for_two_markets_with_stronger_first_unlock() { assert!(Balances::locks(BOB).is_empty()); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id_1, OutcomeReport::Scalar(0), 50 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id_1, OutcomeReport::Scalar(20), 40 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id_2, OutcomeReport::Scalar(0), 30 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id_2, OutcomeReport::Scalar(20), 20 * BASE @@ -1072,7 +1072,7 @@ fn locking_works_for_two_markets_with_stronger_first_unlock() { vec![(market_id_1, 50 * BASE), (market_id_2, 30 * BASE)] ); assert_eq!(Balances::locks(ALICE), vec![the_lock(50 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![(market_id_2, 30 * BASE)]); assert_eq!(Balances::locks(ALICE), vec![the_lock(30 * BASE)]); assert_eq!( @@ -1081,7 +1081,7 @@ fn locking_works_for_two_markets_with_stronger_first_unlock() { ); assert_eq!(Balances::locks(BOB), vec![the_lock(40 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); assert_eq!(>::get(BOB), vec![(market_id_2, 20 * BASE)]); assert_eq!(Balances::locks(BOB), vec![the_lock(20 * BASE)]); assert_eq!(>::get(ALICE), vec![(market_id_2, 30 * BASE)]); @@ -1090,14 +1090,14 @@ fn locking_works_for_two_markets_with_stronger_first_unlock() { assert!(GlobalDisputes::determine_voting_winner(&market_id_2).is_some()); assert_eq!(>::get(ALICE), vec![(market_id_2, 30 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![]); assert!(Balances::locks(ALICE).is_empty()); assert_eq!(>::get(BOB), vec![(market_id_2, 20 * BASE)]); assert_eq!(Balances::locks(BOB), vec![the_lock(20 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); assert_eq!(>::get(BOB), vec![]); assert!(Balances::locks(BOB).is_empty()); }); @@ -1118,26 +1118,26 @@ fn locking_works_for_two_markets_with_weaker_first_unlock() { assert!(Balances::locks(BOB).is_empty()); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id_1, OutcomeReport::Scalar(0), 50 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id_1, OutcomeReport::Scalar(20), 40 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), market_id_2, OutcomeReport::Scalar(0), 30 * BASE )); assert_ok!(GlobalDisputes::vote_on_outcome( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id_2, OutcomeReport::Scalar(20), 20 * BASE @@ -1162,7 +1162,7 @@ fn locking_works_for_two_markets_with_weaker_first_unlock() { vec![(market_id_1, 50 * BASE), (market_id_2, 30 * BASE)] ); assert_eq!(Balances::locks(ALICE), vec![the_lock(50 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![(market_id_1, 50 * BASE)]); assert_eq!(Balances::locks(ALICE), vec![the_lock(50 * BASE)]); assert_eq!( @@ -1171,7 +1171,7 @@ fn locking_works_for_two_markets_with_weaker_first_unlock() { ); assert_eq!(Balances::locks(BOB), vec![the_lock(40 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); assert_eq!(>::get(BOB), vec![(market_id_1, 40 * BASE)]); assert_eq!(Balances::locks(BOB), vec![the_lock(40 * BASE)]); assert_eq!(>::get(ALICE), vec![(market_id_1, 50 * BASE)]); @@ -1181,14 +1181,14 @@ fn locking_works_for_two_markets_with_weaker_first_unlock() { assert_eq!(>::get(ALICE), vec![(market_id_1, 50 * BASE)]); assert_eq!(Balances::locks(ALICE), vec![the_lock(50 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(ALICE), ALICE)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(ALICE), ALICE)); assert_eq!(>::get(ALICE), vec![]); assert!(Balances::locks(ALICE).is_empty()); assert_eq!(>::get(BOB), vec![(market_id_1, 40 * BASE)]); assert_eq!(Balances::locks(BOB), vec![the_lock(40 * BASE)]); - assert_ok!(GlobalDisputes::unlock_vote_balance(Origin::signed(BOB), BOB)); + assert_ok!(GlobalDisputes::unlock_vote_balance(RuntimeOrigin::signed(BOB), BOB)); assert_eq!(>::get(BOB), vec![]); assert!(Balances::locks(BOB).is_empty()); }); diff --git a/zrml/global-disputes/src/types.rs b/zrml/global-disputes/src/types.rs index 3801890b5..63b7c42e7 100644 --- a/zrml/global-disputes/src/types.rs +++ b/zrml/global-disputes/src/types.rs @@ -1,3 +1,20 @@ +// Copyright 2022 Forecasting Technologies LTD. +// +// This file is part of Zeitgeist. +// +// Zeitgeist 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. +// +// Zeitgeist 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 Zeitgeist. If not, see . + use frame_support::pallet_prelude::{Decode, Encode, MaxEncodedLen, TypeInfo}; use sp_runtime::traits::Saturating; use zeitgeist_primitives::types::OutcomeReport; diff --git a/zrml/global-disputes/src/weights.rs b/zrml/global-disputes/src/weights.rs index a549c252f..25780ae75 100644 --- a/zrml/global-disputes/src/weights.rs +++ b/zrml/global-disputes/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_global_disputes //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -62,80 +63,82 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: GlobalDisputes Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_on_outcome(o: u32, v: u32) -> Weight { - (77_234_000 as Weight) - // Standard Error: 4_000 - .saturating_add((122_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 0 - .saturating_add((108_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(78_692_161) + // Standard Error: 15_119 + .saturating_add(Weight::from_ref_time(59_007).saturating_mul(o.into())) + // Standard Error: 2_748 + .saturating_add(Weight::from_ref_time(87_375).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: GlobalDisputes Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:0) // Storage: GlobalDisputes Winners (r:5 w:0) fn unlock_vote_balance_set(l: u32, o: u32) -> Weight { - (21_110_000 as Weight) - // Standard Error: 3_000 - .saturating_add((6_327_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 20_000 - .saturating_add((1_976_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(l as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(47_121_043) + // Standard Error: 10_506 + .saturating_add(Weight::from_ref_time(3_575_177).saturating_mul(l.into())) + // Standard Error: 58_814 + .saturating_add(Weight::from_ref_time(1_025_080).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into()))) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: GlobalDisputes Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:0) // Storage: GlobalDisputes Winners (r:5 w:0) fn unlock_vote_balance_remove(l: u32, o: u32) -> Weight { - (18_940_000 as Weight) - // Standard Error: 3_000 - .saturating_add((6_247_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 19_000 - .saturating_add((1_822_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(l as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(45_059_975) + // Standard Error: 9_769 + .saturating_add(Weight::from_ref_time(3_392_794).saturating_mul(l.into())) + // Standard Error: 54_688 + .saturating_add(Weight::from_ref_time(856_867).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into()))) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: GlobalDisputes Winners (r:1 w:1) // Storage: GlobalDisputes Outcomes (r:1 w:1) // Storage: System Account (r:1 w:1) - fn add_vote_outcome(_w: u32) -> Weight { - (91_053_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn add_vote_outcome(w: u32) -> Weight { + Weight::from_ref_time(85_081_228) + // Standard Error: 23_929 + .saturating_add(Weight::from_ref_time(247_830).saturating_mul(w.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: GlobalDisputes Outcomes (r:1 w:0) // Storage: GlobalDisputes Winners (r:1 w:0) // Storage: System Account (r:2 w:2) fn reward_outcome_owner_with_funds(o: u32) -> Weight { - (51_857_000 as Weight) - // Standard Error: 27_000 - .saturating_add((33_805_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(o as Weight))) + Weight::from_ref_time(69_114_969) + // Standard Error: 102_841 + .saturating_add(Weight::from_ref_time(27_858_004).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(o.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(o.into()))) } // Storage: GlobalDisputes Outcomes (r:1 w:0) // Storage: GlobalDisputes Winners (r:1 w:0) // Storage: System Account (r:1 w:0) fn reward_outcome_owner_no_funds(o: u32) -> Weight { - (39_929_000 as Weight) - // Standard Error: 3_000 - .saturating_add((13_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + Weight::from_ref_time(43_940_716) + // Standard Error: 11_242 + .saturating_add(Weight::from_ref_time(322_069).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(3)) } // Storage: GlobalDisputes Winners (r:1 w:1) // Storage: GlobalDisputes Outcomes (r:3 w:2) fn purge_outcomes(k: u32, _o: u32) -> Weight { - (0 as Weight) - // Standard Error: 11_000 - .saturating_add((23_452_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + Weight::from_ref_time(134_980_974) + // Standard Error: 24_117 + .saturating_add(Weight::from_ref_time(17_002_999).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) } } diff --git a/zrml/liquidity-mining/Cargo.toml b/zrml/liquidity-mining/Cargo.toml index b96c9a1a2..20902ca2c 100644 --- a/zrml/liquidity-mining/Cargo.toml +++ b/zrml/liquidity-mining/Cargo.toml @@ -1,18 +1,18 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -serde = { default-features = false, optional = true, version = "1.0.137" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +serde = { default-features = false, optional = true, version = "1.0.144" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-market-commons = { default-features = false, path = "../market-commons" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -40,4 +40,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-liquidity-mining" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/liquidity-mining/src/benchmarks.rs b/zrml/liquidity-mining/src/benchmarks.rs index b710d21fd..05e32b749 100644 --- a/zrml/liquidity-mining/src/benchmarks.rs +++ b/zrml/liquidity-mining/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "runtime-benchmarks")] diff --git a/zrml/liquidity-mining/src/lib.rs b/zrml/liquidity-mining/src/lib.rs index 76cc13ac2..57d4220a7 100644 --- a/zrml/liquidity-mining/src/lib.rs +++ b/zrml/liquidity-mining/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -100,13 +101,13 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - MarketId = Self::MarketId, - >; + AccountId = Self::AccountId, + BlockNumber = Self::BlockNumber, + MarketId = Self::MarketId, + >; type MarketId: MarketId; diff --git a/zrml/liquidity-mining/src/mock.rs b/zrml/liquidity-mining/src/mock.rs index b4660ff92..f11b7e2db 100644 --- a/zrml/liquidity-mining/src/mock.rs +++ b/zrml/liquidity-mining/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -56,7 +57,7 @@ construct_runtime!( ); impl crate::Config for Runtime { - type Event = (); + type RuntimeEvent = (); type MarketCommons = MarketCommons; type MarketId = MarketId; type PalletId = LiquidityMiningPalletId; @@ -71,9 +72,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -82,7 +83,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -95,7 +96,7 @@ impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); type ReserveIdentifier = [u8; 8]; - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = ExistentialDeposit; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; diff --git a/zrml/liquidity-mining/src/tests.rs b/zrml/liquidity-mining/src/tests.rs index 323172b8d..c4c2deb76 100644 --- a/zrml/liquidity-mining/src/tests.rs +++ b/zrml/liquidity-mining/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ #![cfg(test)] use crate::{ - mock::{Balances, ExtBuilder, LiquidityMining, Origin, Runtime, System, ALICE, BOB}, + mock::{Balances, ExtBuilder, LiquidityMining, Runtime, RuntimeOrigin, System, ALICE, BOB}, track_incentives_based_on_bought_shares::TrackIncentivesBasedOnBoughtShares, track_incentives_based_on_sold_shares::TrackIncentivesBasedOnSoldShares, BlockBoughtShares, BlockSoldShares, LiquidityMiningPalletApi as _, OwnedValues, @@ -31,7 +32,7 @@ use frame_support::{ }; use frame_system::RawOrigin; use zeitgeist_primitives::types::{ - Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, ScoringRule, }; use zrml_market_commons::Markets; @@ -192,7 +193,7 @@ fn only_sudo_can_change_per_block_distribution() { ExtBuilder::default().build().execute_with(|| { assert_ok!(LiquidityMining::set_per_block_distribution(RawOrigin::Root.into(), 100)); assert_err!( - LiquidityMining::set_per_block_distribution(Origin::signed(ALICE), 100), + LiquidityMining::set_per_block_distribution(RuntimeOrigin::signed(ALICE), 100), DispatchError::BadOrigin ); }); @@ -202,6 +203,7 @@ fn create_default_market(market_id: u128, period: Range) { Markets::::insert( market_id, Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: 0, diff --git a/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs b/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs index 877fd8f60..b62893e30 100644 --- a/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs +++ b/zrml/liquidity-mining/src/track_incentives_based_on_bought_shares.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs b/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs index eb6af7b38..1efbacf0d 100644 --- a/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs +++ b/zrml/liquidity-mining/src/track_incentives_based_on_sold_shares.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/zrml/liquidity-mining/src/weights.rs b/zrml/liquidity-mining/src/weights.rs index 0ada8b83d..8d10b58c5 100644 --- a/zrml/liquidity-mining/src/weights.rs +++ b/zrml/liquidity-mining/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_liquidity_mining //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -53,6 +54,6 @@ pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { // Storage: LiquidityMining PerBlockIncentive (r:0 w:1) fn set_per_block_distribution() -> Weight { - (6_620_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_270_000).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/market-commons/Cargo.toml b/zrml/market-commons/Cargo.toml index c2d9abb39..05f519393 100644 --- a/zrml/market-commons/Cargo.toml +++ b/zrml/market-commons/Cargo.toml @@ -1,16 +1,16 @@ [dependencies] -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-arithmetic = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-arithmetic = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -31,4 +31,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-market-commons" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/market-commons/src/lib.rs b/zrml/market-commons/src/lib.rs index 622032d0b..a5894c1e7 100644 --- a/zrml/market-commons/src/lib.rs +++ b/zrml/market-commons/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -47,10 +48,10 @@ mod pallet { }, ArithmeticError, DispatchError, SaturatedConversion, }; - use zeitgeist_primitives::types::{Market, PoolId}; + use zeitgeist_primitives::types::{Asset, Market, PoolId}; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(6); type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -59,7 +60,9 @@ mod pallet { BalanceOf, ::BlockNumber, MomentOf, + Asset>, >; + pub type MarketIdOf = ::MarketId; pub type MomentOf = <::Timestamp as frame_support::traits::Time>::Moment; #[pallet::call] diff --git a/zrml/market-commons/src/migrations.rs b/zrml/market-commons/src/migrations.rs index 16887b73b..361b3949a 100644 --- a/zrml/market-commons/src/migrations.rs +++ b/zrml/market-commons/src/migrations.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -14,3 +15,61 @@ // // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . + +// We use these utilities to prevent having to make the swaps pallet a dependency of +// prediciton-markets. The calls are based on the implementation of `StorageVersion`, found here: +// https://github.com/paritytech/substrate/blob/bc7a1e6c19aec92bfa247d8ca68ec63e07061032/frame/support/src/traits/metadata.rs#L168-L230 +// and previous migrations. +mod utility { + use alloc::vec::Vec; + use frame_support::{ + storage::{storage_prefix, unhashed}, + traits::StorageVersion, + StorageHasher, + }; + use parity_scale_codec::Encode; + + #[allow(unused)] + pub fn storage_prefix_of_market_common_pallet() -> [u8; 32] { + storage_prefix(b"MarketCommons", b":__STORAGE_VERSION__:") + } + + #[allow(unused)] + pub fn get_on_chain_storage_version_of_market_commons_pallet() -> StorageVersion { + let key = storage_prefix_of_market_common_pallet(); + unhashed::get_or_default(&key) + } + + #[allow(unused)] + pub fn put_storage_version_of_market_commons_pallet(value: u16) { + let key = storage_prefix_of_market_common_pallet(); + unhashed::put(&key, &StorageVersion::new(value)); + } + + #[allow(unused)] + const SWAPS: &[u8] = b"Swaps"; + #[allow(unused)] + const POOLS: &[u8] = b"Pools"; + #[allow(unused)] + fn storage_prefix_of_swaps_pallet() -> [u8; 32] { + storage_prefix(b"Swaps", b":__STORAGE_VERSION__:") + } + #[allow(unused)] + pub fn key_to_hash(key: K) -> Vec + where + H: StorageHasher, + K: Encode, + { + key.using_encoded(H::hash).as_ref().to_vec() + } + #[allow(unused)] + pub fn get_on_chain_storage_version_of_swaps_pallet() -> StorageVersion { + let key = storage_prefix_of_swaps_pallet(); + unhashed::get_or_default(&key) + } + #[allow(unused)] + pub fn put_storage_version_of_swaps_pallet(value: u16) { + let key = storage_prefix_of_swaps_pallet(); + unhashed::put(&key, &StorageVersion::new(value)); + } +} diff --git a/zrml/market-commons/src/mock.rs b/zrml/market-commons/src/mock.rs index 46f374882..1f929435d 100644 --- a/zrml/market-commons/src/mock.rs +++ b/zrml/market-commons/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -60,9 +61,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -71,7 +72,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -83,7 +84,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/market-commons/src/tests.rs b/zrml/market-commons/src/tests.rs index f54664819..2d027bb95 100644 --- a/zrml/market-commons/src/tests.rs +++ b/zrml/market-commons/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -26,12 +27,14 @@ use sp_runtime::DispatchError; use zeitgeist_primitives::{ traits::MarketCommonsPalletApi, types::{ - AccountIdTest, Balance, BlockNumber, Deadlines, Market, MarketBonds, MarketCreation, - MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, Moment, ScoringRule, + AccountIdTest, Asset, Balance, BlockNumber, Deadlines, Market, MarketBonds, MarketCreation, + MarketDisputeMechanism, MarketId, MarketPeriod, MarketStatus, MarketType, Moment, + ScoringRule, }, }; -const MARKET_DUMMY: Market = Market { +const MARKET_DUMMY: Market> = Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: 0, @@ -45,7 +48,7 @@ const MARKET_DUMMY: Market = Market resolved_outcome: None, scoring_rule: ScoringRule::CPMM, status: MarketStatus::Disputed, - bonds: MarketBonds { creation: None, oracle: None }, + bonds: MarketBonds { creation: None, oracle: None, outsider: None }, }; #[test] @@ -335,7 +338,8 @@ fn market_counter_interacts_correctly_with_push_market_and_remove_market() { fn market_mock( id: AccountIdTest, -) -> zeitgeist_primitives::types::Market { +) -> zeitgeist_primitives::types::Market> +{ let mut market = MARKET_DUMMY; market.oracle = id; market diff --git a/zrml/orderbook-v1/Cargo.toml b/zrml/orderbook-v1/Cargo.toml index b323ade71..7328f2765 100644 --- a/zrml/orderbook-v1/Cargo.toml +++ b/zrml/orderbook-v1/Cargo.toml @@ -1,18 +1,18 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } # Mock -orml-tokens = { branch = "polkadot-v0.9.26", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +orml-tokens = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } [dev-dependencies] zrml-orderbook-v1 = { features = ["mock"], path = "." } @@ -47,4 +47,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-orderbook-v1" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/orderbook-v1/fuzz/Cargo.toml b/zrml/orderbook-v1/fuzz/Cargo.toml index 1472e91d7..fcde37c37 100644 --- a/zrml/orderbook-v1/fuzz/Cargo.toml +++ b/zrml/orderbook-v1/fuzz/Cargo.toml @@ -6,7 +6,7 @@ test = false [dependencies] arbitrary = { features = ["derive"], version = "1.0" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } libfuzzer-sys = "0.4" zeitgeist-primitives = { path = "../../../primitives" } zrml-orderbook-v1 = { features = ["mock"], path = ".." } diff --git a/zrml/orderbook-v1/fuzz/orderbook_v1_full_workflow.rs b/zrml/orderbook-v1/fuzz/orderbook_v1_full_workflow.rs index c624197df..7f43e5f9f 100644 --- a/zrml/orderbook-v1/fuzz/orderbook_v1_full_workflow.rs +++ b/zrml/orderbook-v1/fuzz/orderbook_v1_full_workflow.rs @@ -21,7 +21,7 @@ use frame_system::ensure_signed; use libfuzzer_sys::fuzz_target; use zeitgeist_primitives::types::{Asset, ScalarPosition, SerdeWrapper}; use zrml_orderbook_v1::{ - mock::{ExtBuilder, Orderbook, Origin}, + mock::{ExtBuilder, Orderbook, RuntimeOrigin}, OrderSide, }; @@ -34,31 +34,32 @@ fuzz_target!(|data: Data| { // Make arbitrary order and attempt to fill let order_asset = asset(data.make_fill_order_asset); let order_hash = Orderbook::order_hash( - &ensure_signed(Origin::signed(data.make_fill_order_origin.into())).unwrap(), + &ensure_signed(RuntimeOrigin::signed(data.make_fill_order_origin.into())).unwrap(), order_asset, Orderbook::nonce(), ); let _ = Orderbook::make_order( - Origin::signed(data.make_fill_order_origin.into()), + RuntimeOrigin::signed(data.make_fill_order_origin.into()), order_asset, orderside(data.make_fill_order_side), data.make_fill_order_amount, data.make_fill_order_price, ); - let _ = Orderbook::fill_order(Origin::signed(data.fill_order_origin.into()), order_hash); + let _ = + Orderbook::fill_order(RuntimeOrigin::signed(data.fill_order_origin.into()), order_hash); // Make arbitrary order and attempt to cancel let order_asset = asset(data.make_cancel_order_asset); let order_hash = Orderbook::order_hash( - &ensure_signed(Origin::signed(data.make_cancel_order_origin.into())).unwrap(), + &ensure_signed(RuntimeOrigin::signed(data.make_cancel_order_origin.into())).unwrap(), order_asset, Orderbook::nonce(), ); let _ = Orderbook::make_order( - Origin::signed(data.make_cancel_order_origin.into()), + RuntimeOrigin::signed(data.make_cancel_order_origin.into()), order_asset, orderside(data.make_cancel_order_side), data.make_cancel_order_amount, @@ -66,7 +67,7 @@ fuzz_target!(|data: Data| { ); let _ = Orderbook::cancel_order( - Origin::signed(data.make_cancel_order_origin.into()), + RuntimeOrigin::signed(data.make_cancel_order_origin.into()), order_asset, order_hash, ); diff --git a/zrml/orderbook-v1/src/benchmarks.rs b/zrml/orderbook-v1/src/benchmarks.rs index d6e63dd92..e60585e88 100644 --- a/zrml/orderbook-v1/src/benchmarks.rs +++ b/zrml/orderbook-v1/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "runtime-benchmarks")] #![allow(clippy::type_complexity)] diff --git a/zrml/orderbook-v1/src/lib.rs b/zrml/orderbook-v1/src/lib.rs index 61cf64ad7..3934d1318 100644 --- a/zrml/orderbook-v1/src/lib.rs +++ b/zrml/orderbook-v1/src/lib.rs @@ -80,19 +80,19 @@ mod pallet { let mut bid = true; if let Some(order_data) = Self::order_data(order_hash) { - let maker = order_data.maker.clone(); - ensure!(sender == maker, Error::::NotOrderCreator); + let maker = &order_data.maker; + ensure!(sender == *maker, Error::::NotOrderCreator); match order_data.side { OrderSide::Bid => { let cost = order_data.cost()?; - T::Currency::unreserve(&maker, cost); + T::Currency::unreserve(maker, cost); let mut bids = Self::bids(asset); remove_item::(&mut bids, order_hash); >::insert(asset, bids); } OrderSide::Ask => { - T::Shares::unreserve(order_data.asset, &maker, order_data.total); + T::Shares::unreserve(order_data.asset, maker, order_data.total); let mut asks = Self::asks(asset); remove_item::(&mut asks, order_hash); >::insert(asset, asks); @@ -256,15 +256,15 @@ mod pallet { pub trait Config: frame_system::Config { type Currency: ReservableCurrency; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type MarketId: MarketId; type Shares: MultiReservableCurrency< - Self::AccountId, - Balance = BalanceOf, - CurrencyId = Asset, - >; + Self::AccountId, + Balance = BalanceOf, + CurrencyId = Asset, + >; type WeightInfo: WeightInfoZeitgeist; } diff --git a/zrml/orderbook-v1/src/mock.rs b/zrml/orderbook-v1/src/mock.rs index 6b71f3c2d..d7570fc83 100644 --- a/zrml/orderbook-v1/src/mock.rs +++ b/zrml/orderbook-v1/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -52,7 +53,7 @@ construct_runtime!( impl crate::Config for Runtime { type Currency = Balances; - type Event = (); + type RuntimeEvent = (); type MarketId = MarketId; type Shares = Tokens; type WeightInfo = orderbook_v1::weights::WeightInfo; @@ -66,9 +67,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -77,7 +78,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -90,13 +91,11 @@ impl orml_tokens::Config for Runtime { type Balance = Balance; type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; - type Event = (); + type RuntimeEvent = (); type ExistentialDeposits = ExistentialDeposits; type MaxLocks = (); type MaxReserves = MaxReserves; - type OnDust = (); - type OnKilledTokenAccount = (); - type OnNewTokenAccount = (); + type CurrencyHooks = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } @@ -105,7 +104,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = ExistentialDeposit; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; diff --git a/zrml/orderbook-v1/src/tests.rs b/zrml/orderbook-v1/src/tests.rs index e448ba140..4bbbd31af 100644 --- a/zrml/orderbook-v1/src/tests.rs +++ b/zrml/orderbook-v1/src/tests.rs @@ -34,7 +34,7 @@ fn it_makes_orders() { // Make an order from Alice to buy shares. assert_ok!(Orderbook::make_order( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Asset::CategoricalOutcome(0, 2), OrderSide::Bid, 25, @@ -47,7 +47,7 @@ fn it_makes_orders() { // Make an order from Bob to sell shares. assert_ok!(Orderbook::make_order( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), Asset::CategoricalOutcome(0, 1), OrderSide::Ask, 10, @@ -67,7 +67,7 @@ fn it_takes_orders() { // Make an order from Bob to sell shares. assert_ok!(Orderbook::make_order( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), Asset::CategoricalOutcome(0, 1), OrderSide::Ask, 10, @@ -75,7 +75,7 @@ fn it_takes_orders() { )); let order_hash = Orderbook::order_hash(&BOB, Asset::CategoricalOutcome(0, 1), 0); - assert_ok!(Orderbook::fill_order(Origin::signed(ALICE), order_hash)); + assert_ok!(Orderbook::fill_order(RuntimeOrigin::signed(ALICE), order_hash)); let alice_bal = >::free_balance(&ALICE); let alice_shares = Tokens::free_balance(Asset::CategoricalOutcome(0, 1), &ALICE); @@ -94,15 +94,21 @@ fn it_cancels_orders() { ExtBuilder::default().build().execute_with(|| { // Make an order from Alice to buy shares. let share_id = Asset::CategoricalOutcome(0, 2); - assert_ok!(Orderbook::make_order(Origin::signed(ALICE), share_id, OrderSide::Bid, 25, 10)); + assert_ok!(Orderbook::make_order( + RuntimeOrigin::signed(ALICE), + share_id, + OrderSide::Bid, + 25, + 10 + )); let order_hash = Orderbook::order_hash(&ALICE, share_id, 0); assert_noop!( - Orderbook::cancel_order(Origin::signed(BOB), share_id, order_hash), + Orderbook::cancel_order(RuntimeOrigin::signed(BOB), share_id, order_hash), Error::::NotOrderCreator, ); - assert_ok!(Orderbook::cancel_order(Origin::signed(ALICE), share_id, order_hash)); + assert_ok!(Orderbook::cancel_order(RuntimeOrigin::signed(ALICE), share_id, order_hash)); }); } diff --git a/zrml/orderbook-v1/src/weights.rs b/zrml/orderbook-v1/src/weights.rs index f572f3fb1..4d02a09ba 100644 --- a/zrml/orderbook-v1/src/weights.rs +++ b/zrml/orderbook-v1/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -45,6 +46,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] use core::marker::PhantomData; use frame_support::{traits::Get, weights::Weight}; @@ -64,33 +66,33 @@ pub trait WeightInfoZeitgeist { pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { fn cancel_order_ask() -> Weight { - (53_301_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(53_301_000) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } fn cancel_order_bid() -> Weight { - (49_023_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(49_023_000) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } fn fill_order_ask() -> Weight { - (119_376_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(119_376_000) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } fn fill_order_bid() -> Weight { - (119_917_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(119_917_000) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } fn make_order_ask() -> Weight { - (80_092_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(80_092_000) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } fn make_order_bid() -> Weight { - (62_027_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(62_027_000) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/zrml/prediction-markets/Cargo.toml b/zrml/prediction-markets/Cargo.toml index 0720f9b84..228bdb4f8 100644 --- a/zrml/prediction-markets/Cargo.toml +++ b/zrml/prediction-markets/Cargo.toml @@ -1,12 +1,13 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-arithmetic = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +serde = { version = "1.0.144", default-features = false, optional = true } +sp-arithmetic = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-authorized = { default-features = false, path = "../authorized" } zrml-court = { default-features = false, path = "../court" } @@ -15,17 +16,20 @@ zrml-liquidity-mining = { default-features = false, path = "../liquidity-mining" zrml-market-commons = { default-features = false, path = "../market-commons" } zrml-simple-disputes = { default-features = false, path = "../simple-disputes" } + # Mock -orml-currencies = { branch = "polkadot-v0.9.26", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-tokens = { branch = "polkadot-v0.9.26", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -pallet-randomness-collective-flip = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -pallet-timestamp = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } -pallet-treasury = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +orml-asset-registry = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-currencies = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-tokens = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +pallet-randomness-collective-flip = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +pallet-timestamp = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate", optional = true } +pallet-treasury = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } substrate-fixed = { optional = true, git = "https://github.com/encointer/substrate-fixed" } +xcm = { branch = "release-v0.9.32", git = "https://github.com/paritytech/polkadot", optional = true, default-features = false } zrml-prediction-markets-runtime-api = { features = ["std"], optional = true, path = "./runtime-api" } zrml-rikiddo = { optional = true, path = "../rikiddo" } zrml-swaps = { optional = true, path = "../swaps" } @@ -44,6 +48,7 @@ mock = [ "pallet-randomness-collective-flip", "pallet-timestamp/std", "pallet-treasury", + "serde", "sp-api", "sp-io", "substrate-fixed", @@ -51,7 +56,10 @@ mock = [ "zrml-prediction-markets-runtime-api", "zrml-rikiddo", "zrml-swaps", + "xcm", + "orml-asset-registry", ] +parachain = [] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", @@ -63,8 +71,11 @@ std = [ "frame-benchmarking?/std", "frame-support/std", "frame-system/std", + "orml-asset-registry?/std", "orml-traits/std", "parity-scale-codec/std", + 'scale-info/std', + "serde?/std", "sp-arithmetic/std", "sp-runtime/std", "zeitgeist-primitives/std", @@ -74,6 +85,7 @@ std = [ "zrml-market-commons/std", "zrml-simple-disputes/std", "zrml-global-disputes?/std", + "xcm?/std", ] try-runtime = [ "frame-support/try-runtime", @@ -86,4 +98,4 @@ with-global-disputes = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-prediction-markets" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/prediction-markets/fuzz/Cargo.toml b/zrml/prediction-markets/fuzz/Cargo.toml index 53c2e7c64..e35beb6a4 100644 --- a/zrml/prediction-markets/fuzz/Cargo.toml +++ b/zrml/prediction-markets/fuzz/Cargo.toml @@ -6,7 +6,7 @@ test = false [dependencies] arbitrary = { features = ["derive"], version = "1.0" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } libfuzzer-sys = "0.4" zeitgeist-primitives = { features = ["arbitrary", "mock"], default-features = false, path = "../../../primitives" } zrml-prediction-markets = { features = ["mock"], path = ".." } diff --git a/zrml/prediction-markets/fuzz/pm_full_workflow.rs b/zrml/prediction-markets/fuzz/pm_full_workflow.rs index e6025f9f5..edddb77ac 100644 --- a/zrml/prediction-markets/fuzz/pm_full_workflow.rs +++ b/zrml/prediction-markets/fuzz/pm_full_workflow.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -22,10 +23,10 @@ use core::ops::{Range, RangeInclusive}; use frame_support::traits::Hooks; use libfuzzer_sys::fuzz_target; use zeitgeist_primitives::types::{ - Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketType, MultiHash, + Asset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketType, MultiHash, OutcomeReport, ScoringRule, }; -use zrml_prediction_markets::mock::{ExtBuilder, Origin, PredictionMarkets, System}; +use zrml_prediction_markets::mock::{ExtBuilder, PredictionMarkets, RuntimeOrigin, System}; fuzz_target!(|data: Data| { let mut ext = ExtBuilder::default().build(); @@ -39,7 +40,8 @@ fuzz_target!(|data: Data| { dispute_duration: 3_u32.into(), }; let _ = PredictionMarkets::create_market( - Origin::signed(data.create_scalar_market_origin.into()), + RuntimeOrigin::signed(data.create_scalar_market_origin.into()), + Asset::Ztg, data.create_scalar_market_oracle.into(), MarketPeriod::Block(data.create_scalar_market_period), deadlines, @@ -54,7 +56,7 @@ fuzz_target!(|data: Data| { System::set_block_number(2); let _ = PredictionMarkets::buy_complete_set( - Origin::signed(data.buy_complete_set_origin.into()), + RuntimeOrigin::signed(data.buy_complete_set_origin.into()), data.buy_complete_set_market_id.into(), data.buy_complete_set_amount, ); @@ -62,7 +64,7 @@ fuzz_target!(|data: Data| { System::set_block_number(3); let _ = PredictionMarkets::report( - Origin::signed(data.report_origin.into()), + RuntimeOrigin::signed(data.report_origin.into()), data.report_market_id.into(), outcome(data.report_outcome), ); @@ -72,7 +74,7 @@ fuzz_target!(|data: Data| { let dispute_market_id = data.dispute_market_id.into(); let _ = PredictionMarkets::dispute( - Origin::signed(data.report_origin.into()), + RuntimeOrigin::signed(data.report_origin.into()), dispute_market_id, outcome(data.report_outcome), ); @@ -81,7 +83,7 @@ fuzz_target!(|data: Data| { System::set_block_number(5); let _ = PredictionMarkets::redeem_shares( - Origin::signed(data.redeem_origin.into()), + RuntimeOrigin::signed(data.redeem_origin.into()), data.redeem_market_id.into(), ); diff --git a/zrml/prediction-markets/runtime-api/Cargo.toml b/zrml/prediction-markets/runtime-api/Cargo.toml index faba7beae..e651a6769 100644 --- a/zrml/prediction-markets/runtime-api/Cargo.toml +++ b/zrml/prediction-markets/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [dependencies] parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } -sp-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../../primitives" } [features] @@ -15,4 +15,4 @@ std = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-prediction-markets-runtime-api" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/prediction-markets/src/benchmarks.rs b/zrml/prediction-markets/src/benchmarks.rs index 1a383d395..62fa3e6a0 100644 --- a/zrml/prediction-markets/src/benchmarks.rs +++ b/zrml/prediction-markets/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies Ltd. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![allow(clippy::type_complexity)] #![cfg(feature = "runtime-benchmarks")] @@ -35,7 +36,7 @@ use frame_system::RawOrigin; use orml_traits::MultiCurrency; use sp_runtime::traits::{One, SaturatedConversion, Saturating, Zero}; use zeitgeist_primitives::{ - constants::mock::{MaxSwapFee, MinLiquidity, MinWeight, BASE, MILLISECS_PER_BLOCK}, + constants::mock::{MaxSwapFee, MinWeight, BASE, MILLISECS_PER_BLOCK}, traits::Swaps, types::{ Asset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, @@ -48,10 +49,12 @@ use zrml_market_commons::MarketCommonsPalletApi; use frame_support::{traits::Hooks, BoundedVec}; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } +const LIQUIDITY: u128 = 100 * BASE; + // Get default values for market creation. Also spawns an account with maximum // amount of native currency fn create_market_common_parameters( @@ -61,8 +64,7 @@ fn create_market_common_parameters( &'static str, > { let caller: T::AccountId = whitelisted_caller(); - T::AssetManager::deposit(Asset::Ztg, &caller, (100 * MinLiquidity::get()).saturated_into()) - .unwrap(); + T::AssetManager::deposit(Asset::Ztg, &caller, (100u128 * LIQUIDITY).saturated_into()).unwrap(); let oracle = caller.clone(); let deadlines = Deadlines:: { grace_period: 1_u32.into(), @@ -77,18 +79,20 @@ fn create_market_common_parameters( } // Create a market based on common parameters -fn create_market_common( +fn create_market_common( permission: MarketCreation, options: MarketType, scoring_rule: ScoringRule, period: Option>>, ) -> Result<(T::AccountId, MarketIdOf), &'static str> { + pallet_timestamp::Pallet::::set_timestamp(0u32.into()); let range_start: MomentOf = 100_000u64.saturated_into(); let range_end: MomentOf = 1_000_000u64.saturated_into(); let period = period.unwrap_or(MarketPeriod::Timestamp(range_start..range_end)); let (caller, oracle, deadlines, metadata, creation) = create_market_common_parameters::(permission)?; Call::::create_market { + base_asset: Asset::Ztg, oracle, period, deadlines, @@ -147,14 +151,10 @@ fn setup_redeem_shares_common( } else if let MarketType::Scalar(range) = market_type { outcome = OutcomeReport::Scalar(*range.end()); } else { - panic!("setup_redeem_shares_common: Unsupported market type: {:?}", market_type); + panic!("setup_redeem_shares_common: Unsupported market type: {market_type:?}"); } - Pallet::::do_buy_complete_set( - caller.clone(), - market_id, - MinLiquidity::get().saturated_into(), - )?; + Pallet::::do_buy_complete_set(caller.clone(), market_id, LIQUIDITY.saturated_into())?; let close_origin = T::CloseOrigin::successful_origin(); let resolve_origin = T::ResolveOrigin::successful_origin(); Call::::admin_move_market_to_closed { market_id }.dispatch_bypass_filter(close_origin)?; @@ -187,7 +187,7 @@ fn setup_reported_categorical_market_with_pool = MaxSwapFee::get().saturated_into(); - let min_liquidity: BalanceOf = MinLiquidity::get().saturated_into(); + let min_liquidity: BalanceOf = LIQUIDITY.saturated_into(); Call::::buy_complete_set { market_id, amount: min_liquidity } .dispatch_bypass_filter(RawOrigin::Signed(caller.clone()).into())?; let weight_len: usize = MaxRuntimeUsize::from(categories).into(); @@ -450,7 +450,6 @@ benchmarks! { admin_move_market_to_resolved_scalar_disputed { let r in 0..63; - let d in 1..T::MaxDisputes::get(); let (_, market_id) = create_close_and_report_market::( MarketCreation::Permissionless, @@ -464,23 +463,16 @@ benchmarks! { })?; let market = >::market(&market_id)?; - if let MarketType::Scalar(range) = market.market_type { - assert!((d as u128) < *range.end()); - } else { - panic!("Must create scalar market"); - } - for i in 0..d { - let outcome = OutcomeReport::Scalar((i % 2).into()); - let disputor = account("disputor", i + 1, 0); - let dispute_bond = crate::pallet::default_dispute_bond::(i as usize); - T::AssetManager::deposit( - Asset::Ztg, - &disputor, - dispute_bond, - )?; - Pallet::::dispute(RawOrigin::Signed(disputor).into(), market_id, outcome)?; - } + let outcome = OutcomeReport::Scalar(0); + let disputor = account("disputor", 1, 0); + let dispute_bond = crate::pallet::default_dispute_bond::(0_usize); + T::AssetManager::deposit( + Asset::Ztg, + &disputor, + dispute_bond, + )?; + Pallet::::dispute(RawOrigin::Signed(disputor).into(), market_id, outcome)?; let disputes = Disputes::::get(market_id); // Authorize the outcome with the highest number of correct reporters to maximize the // number of transfers required (0 has (d+1)//2 reports, 1 has d//2 reports). @@ -513,7 +505,6 @@ benchmarks! { admin_move_market_to_resolved_categorical_disputed { let r in 0..63; - let d in 1..T::MaxDisputes::get(); let categories = T::MaxCategories::get(); let (caller, market_id) = @@ -527,17 +518,16 @@ benchmarks! { Ok(()) })?; - for i in 0..d { - let outcome = OutcomeReport::Categorical((i % 2).saturated_into::()); - let disputor = account("disputor", i + 1, 0); - let dispute_bond = crate::pallet::default_dispute_bond::(i as usize); - T::AssetManager::deposit( - Asset::Ztg, - &disputor, - dispute_bond, - )?; - Pallet::::dispute(RawOrigin::Signed(disputor).into(), market_id, outcome)?; - } + let outcome = OutcomeReport::Categorical(0u16); + let disputor = account("disputor", 1, 0); + let dispute_bond = crate::pallet::default_dispute_bond::(0_usize); + T::AssetManager::deposit( + Asset::Ztg, + &disputor, + dispute_bond, + )?; + Pallet::::dispute(RawOrigin::Signed(disputor).into(), market_id, outcome)?; + let disputes = Disputes::::get(market_id); // Authorize the outcome with the highest number of correct reporters to maximize the // number of transfers required (0 has (d+1)//2 reports, 1 has d//2 reports). @@ -625,6 +615,7 @@ benchmarks! { } }: _( RawOrigin::Signed(caller), + Asset::Ztg, oracle, period, deadlines, @@ -647,6 +638,7 @@ benchmarks! { let (caller, oracle, deadlines, metadata, creation) = create_market_common_parameters::(MarketCreation::Advised)?; Call::::create_market { + base_asset: Asset::Ztg, oracle: oracle.clone(), period: period.clone(), deadlines, @@ -677,6 +669,7 @@ benchmarks! { }; }: _( RawOrigin::Signed(caller), + Asset::Ztg, market_id, oracle, period, @@ -716,7 +709,7 @@ benchmarks! { Pallet::::calculate_time_frame_of_moment(range_start)).len(); let max_swap_fee: BalanceOf:: = MaxSwapFee::get().saturated_into(); - let min_liquidity: BalanceOf:: = MinLiquidity::get().saturated_into(); + let min_liquidity: BalanceOf:: = LIQUIDITY.saturated_into(); Pallet::::buy_complete_set( RawOrigin::Signed(caller.clone()).into(), market_id, @@ -759,7 +752,7 @@ benchmarks! { let market = >::market(&market_id.saturated_into())?; let max_swap_fee: BalanceOf:: = MaxSwapFee::get().saturated_into(); - let min_liquidity: BalanceOf:: = MinLiquidity::get().saturated_into(); + let min_liquidity: BalanceOf:: = LIQUIDITY.saturated_into(); Pallet::::buy_complete_set( RawOrigin::Signed(caller.clone()).into(), market_id, @@ -778,13 +771,15 @@ benchmarks! { }: { call.dispatch_bypass_filter(RawOrigin::Signed(caller).into())?; } verify { - let market_pool_id = >::market_pool(&market_id.saturated_into())?; + let market_pool_id = + >::market_pool(&market_id.saturated_into())?; let pool = T::Swaps::pool(market_pool_id)?; assert_eq!(pool.pool_status, PoolStatus::Active); } start_global_dispute { let m in 1..CacheSize::get(); + let n in 1..CacheSize::get(); // no benchmarking component for max disputes here, // because MaxDisputes is enforced for the extrinsic @@ -794,11 +789,16 @@ benchmarks! { OutcomeReport::Scalar(u128::MAX), )?; + >::mutate_market(&market_id, |market| { + market.dispute_mechanism = MarketDisputeMechanism::SimpleDisputes; + Ok(()) + })?; + // first element is the market id from above - let mut market_ids = BoundedVec::try_from(vec![market_id]).unwrap(); + let mut market_ids_1: BoundedVec, CacheSize> = Default::default(); assert_eq!(market_id, 0u128.saturated_into()); for i in 1..m { - market_ids.try_push(i.saturated_into()).unwrap(); + market_ids_1.try_push(i.saturated_into()).unwrap(); } let max_dispute_len = T::MaxDisputes::get(); @@ -815,11 +815,28 @@ benchmarks! { .dispatch_bypass_filter(RawOrigin::Signed(disputor.clone()).into())?; } + let market = >::market(&market_id.saturated_into()).unwrap(); + let disputes = Disputes::::get(market_id); + let last_dispute = disputes.last().unwrap(); + let dispute_duration_ends_at_block = last_dispute.at + market.deadlines.dispute_duration; + let mut market_ids_2: BoundedVec, CacheSize> = BoundedVec::try_from( + vec![market_id], + ).unwrap(); + for i in 1..n { + market_ids_2.try_push(i.saturated_into()).unwrap(); + } + MarketIdsPerDisputeBlock::::insert(dispute_duration_ends_at_block, market_ids_2); + let current_block: T::BlockNumber = (max_dispute_len + 1).saturated_into(); >::set_block_number(current_block); - // the complexity depends on MarketIdsPerDisputeBlock at the current block - // this is because a variable number of market ids need to be decoded from the storage - MarketIdsPerDisputeBlock::::insert(current_block, market_ids); + + #[cfg(feature = "with-global-disputes")] + { + let global_dispute_end = current_block + T::GlobalDisputePeriod::get(); + // the complexity depends on MarketIdsPerDisputeBlock at the current block + // this is because a variable number of market ids need to be decoded from the storage + MarketIdsPerDisputeBlock::::insert(global_dispute_end, market_ids_1); + } let call = Call::::start_global_dispute { market_id }; }: { @@ -830,9 +847,6 @@ benchmarks! { } dispute_authorized { - let d in 0..(T::MaxDisputes::get() - 1); - let b in 0..63; - let report_outcome = OutcomeReport::Scalar(u128::MAX); let (caller, market_id) = create_close_and_report_market::( MarketCreation::Permissionless, @@ -846,28 +860,9 @@ benchmarks! { })?; let market = >::market(&market_id)?; - if let MarketType::Scalar(range) = market.market_type { - assert!((d as u128) < *range.end()); - } else { - panic!("Must create scalar market"); - } - for i in 0..d { - let outcome = OutcomeReport::Scalar(i.into()); - let disputor = account("disputor", i, 0); - T::AssetManager::deposit(Asset::Ztg, &disputor, (u128::MAX).saturated_into())?; - Pallet::::dispute(RawOrigin::Signed(disputor).into(), market_id, outcome)?; - } - - let now = frame_system::Pallet::::block_number(); - let resolves_at = now.saturating_add(market.deadlines.dispute_duration); - for i in 0..b { - MarketIdsPerDisputeBlock::::try_mutate( - resolves_at, - |ids| ids.try_push(i.into()), - ).unwrap(); - } - let dispute_outcome = OutcomeReport::Scalar((d + 1).into()); + // only one dispute allowed for authorized mdm + let dispute_outcome = OutcomeReport::Scalar(1u128); let call = Call::::dispute { market_id, outcome: dispute_outcome }; }: { call.dispatch_bypass_filter(RawOrigin::Signed(caller).into())?; @@ -902,9 +897,6 @@ benchmarks! { } internal_resolve_categorical_disputed { - // d = num. disputes - let d in 1..T::MaxDisputes::get(); - let categories = T::MaxCategories::get(); let (caller, market_id) = setup_reported_categorical_market_with_pool::( @@ -916,14 +908,11 @@ benchmarks! { Ok(()) })?; - for i in 0..d { - let origin = caller.clone(); - Pallet::::dispute( - RawOrigin::Signed(origin).into(), - market_id, - OutcomeReport::Categorical((i % 2).saturated_into::()), - )?; - } + Pallet::::dispute( + RawOrigin::Signed(caller).into(), + market_id, + OutcomeReport::Categorical(0), + )?; // Authorize the outcome with the highest number of correct reporters to maximize the // number of transfers required (0 has (d+1)//2 reports, 1 has d//2 reports). AuthorizedPallet::::authorize_market_outcome( @@ -954,8 +943,6 @@ benchmarks! { } internal_resolve_scalar_disputed { - let d in 1..T::MaxDisputes::get(); - let (caller, market_id) = create_close_and_report_market::( MarketCreation::Permissionless, MarketType::Scalar(0u128..=u128::MAX), @@ -966,19 +953,11 @@ benchmarks! { Ok(()) })?; let market = >::market(&market_id)?; - if let MarketType::Scalar(range) = market.market_type { - assert!((d as u128) < *range.end()); - } else { - panic!("Must create scalar market"); - } - for i in 0..d { - let origin = caller.clone(); - Pallet::::dispute( - RawOrigin::Signed(origin).into(), - market_id, - OutcomeReport::Scalar((i % 2).into()) - )?; - } + Pallet::::dispute( + RawOrigin::Signed(caller).into(), + market_id, + OutcomeReport::Scalar(1) + )?; // Authorize the outcome with the highest number of correct reporters to maximize the // number of transfers required (0 has (d+1)//2 reports, 1 has d//2 reports). AuthorizedPallet::::authorize_market_outcome( @@ -1116,7 +1095,7 @@ benchmarks! { ScoringRule::CPMM, None, )?; - let amount: BalanceOf = MinLiquidity::get().saturated_into(); + let amount: BalanceOf = LIQUIDITY.saturated_into(); Pallet::::buy_complete_set( RawOrigin::Signed(caller.clone()).into(), market_id, diff --git a/zrml/prediction-markets/src/lib.rs b/zrml/prediction-markets/src/lib.rs index 045ec7e0c..e4390ed3e 100644 --- a/zrml/prediction-markets/src/lib.rs +++ b/zrml/prediction-markets/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -24,6 +25,7 @@ extern crate alloc; mod benchmarks; pub mod migrations; pub mod mock; +pub mod orml_asset_registry; mod tests; pub mod weights; @@ -35,19 +37,21 @@ mod pallet { use alloc::{format, vec, vec::Vec}; use core::{cmp, marker::PhantomData}; use frame_support::{ - dispatch::{DispatchResultWithPostInfo, Weight}, + dispatch::{DispatchResultWithPostInfo, Pays, Weight}, ensure, log, pallet_prelude::{ConstU32, StorageMap, StorageValue, ValueQuery}, storage::{with_transaction, TransactionOutcome}, traits::{ - Currency, EnsureOrigin, Get, Hooks, Imbalance, IsType, NamedReservableCurrency, - OnUnbalanced, StorageVersion, + tokens::BalanceStatus, Currency, EnsureOrigin, Get, Hooks, Imbalance, IsType, + NamedReservableCurrency, OnUnbalanced, StorageVersion, }, - transactional, - weights::Pays, - Blake2_128Concat, BoundedVec, PalletId, Twox64Concat, + transactional, Blake2_128Concat, BoundedVec, PalletId, Twox64Concat, }; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; + + #[cfg(feature = "parachain")] + use {orml_traits::asset_registry::Inspect, zeitgeist_primitives::types::CustomMetadata}; + use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; use sp_arithmetic::per_things::{Perbill, Percent}; use sp_runtime::{ @@ -56,7 +60,7 @@ mod pallet { }; use zeitgeist_primitives::{ constants::MILLISECS_PER_BLOCK, - traits::{DisputeApi, Swaps, ZeitgeistAssetManager}, + traits::{DisputeApi, DisputeResolutionApi, Swaps, ZeitgeistAssetManager}, types::{ Asset, Bond, Deadlines, Market, MarketBonds, MarketCreation, MarketDispute, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, MultiHash, @@ -70,7 +74,7 @@ mod pallet { use zrml_market_commons::MarketCommonsPalletApi; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(6); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(7); pub(crate) type BalanceOf = <::AssetManager as MultiCurrency< ::AccountId, @@ -87,6 +91,7 @@ mod pallet { BalanceOf, ::BlockNumber, MomentOf, + Asset>, >; pub type CacheSize = ConstU32<64>; pub type EditReason = BoundedVec::MaxEditReasonLen>; @@ -190,6 +195,108 @@ mod pallet { }; } + macro_rules! impl_repatriate_bond { + ($fn_name:ident, $bond_type:ident) => { + /// Settle the $bond_type bond by repatriating it to free balance of beneficiary. + /// + /// This function **should** only be called if the bond is not yet settled, and calling + /// it if the bond is settled is most likely a logic error. If the bond is already + /// settled, storage is not changed, a warning is raised and `Ok(())` is returned. + fn $fn_name(market_id: &MarketIdOf, beneficiary: &T::AccountId) -> DispatchResult { + let market = >::market(market_id)?; + let bond = market.bonds.$bond_type.as_ref().ok_or(Error::::MissingBond)?; + if bond.is_settled { + let warning = format!( + "Attempting to settle the {} bond of market {:?} multiple times", + stringify!($bond_type), + market_id, + ); + log::warn!("{}", warning); + debug_assert!(false, "{}", warning); + return Ok(()); + } + let res = >::repatriate_reserved_named( + &Self::reserve_id(), + &bond.who, + beneficiary, + bond.value, + BalanceStatus::Free, + ); + // If there's an error or missing balance, + // there's nothing we can do, so we don't count this as error + // and log a warning instead. + match res { + Ok(missing) if missing != >::zero() => { + let warning = format!( + "Failed to repatriate all of the {} bond of market {:?} (missing \ + balance {:?}).", + stringify!($bond_type), + market_id, + missing, + ); + log::warn!("{}", warning); + debug_assert!(false, "{}", warning); + } + Ok(_) => (), + Err(_err) => { + let warning = format!( + "Failed to settle the {} bond of market {:?} (error: {}).", + stringify!($bond_type), + market_id, + stringify!(_err), + ); + log::warn!("{}", warning); + debug_assert!(false, "{}", warning); + } + } + >::mutate_market(market_id, |m| { + m.bonds.$bond_type = Some(Bond { is_settled: true, ..bond.clone() }); + Ok(()) + })?; + Ok(()) + } + }; + } + + macro_rules! impl_is_bond_pending { + ($fn_name:ident, $bond_type:ident) => { + /// Check whether the $bond_type is present (ready to get unreserved or slashed). + /// Set the flag `with_warning` to `true`, when warnings should be logged + /// in case the bond is not present or already settled. + /// + /// Return `true` if the bond is present and not settled, `false` otherwise. + fn $fn_name( + market_id: &MarketIdOf, + market: &MarketOf, + with_warning: bool, + ) -> bool { + if let Some(bond) = &market.bonds.$bond_type { + if !bond.is_settled { + return true; + } else if with_warning { + let warning = format!( + "[PredictionMarkets] The {} bond is already settled for market {:?}.", + stringify!($bond_type), + market_id, + ); + log::warn!("{}", warning); + debug_assert!(false, "{}", warning); + } + } else if with_warning { + let warning = format!( + "[PredictionMarkets] The {} bond is not present for market {:?}.", + stringify!($bond_type), + market_id, + ); + log::warn!("{}", warning); + debug_assert!(false, "{}", warning); + } + + false + } + }; + } + #[pallet::call] impl Pallet { /// Destroy a market, including its outcome assets, market account and pool account. @@ -228,16 +335,7 @@ mod pallet { // Slash outstanding bonds; see // https://github.com/zeitgeistpm/runtime-audit-1/issues/34#issuecomment-1120187097 for // details. - if let Some(bond) = market.bonds.creation { - if !bond.is_settled { - Self::slash_creation_bond(&market_id, None)?; - } - } - if let Some(bond) = market.bonds.oracle { - if !bond.is_settled { - Self::slash_oracle_bond(&market_id, None)?; - } - } + Self::slash_pending_bonds(&market_id, &market)?; if market_status == MarketStatus::Proposed { MarketIdsForEdit::::remove(market_id); @@ -246,9 +344,9 @@ mod pallet { // NOTE: Currently we don't clean up outcome assets. // TODO(#792): Remove outcome assets for accounts! Delete "resolved" assets of `orml_tokens` with storage migration. T::AssetManager::slash( - Asset::Ztg, + market.base_asset, &market_account, - T::AssetManager::free_balance(Asset::Ztg, &market_account), + T::AssetManager::free_balance(market.base_asset, &market_account), ); let mut category_count = 0u32; if let Ok(pool_id) = >::market_pool(&market_id) { @@ -261,6 +359,18 @@ mod pallet { let open_ids_len = Self::clear_auto_open(&market_id)?; let close_ids_len = Self::clear_auto_close(&market_id)?; let (ids_len, disputes_len) = Self::clear_auto_resolve(&market_id)?; + // `Disputes` is emtpy unless the market is disputed, so this is just a defensive + // check. + if market.status == MarketStatus::Disputed { + for (index, dispute) in Disputes::::take(market_id).iter().enumerate() { + T::AssetManager::unreserve_named( + &Self::reserve_id(), + Asset::Ztg, + &dispute.by, + default_dispute_bond::(index), + ); + } + } >::remove_market(&market_id)?; Disputes::::remove(market_id); @@ -292,7 +402,7 @@ mod pallet { ) .into()) } else { - Ok((None, Pays::No).into()) + Ok((Option::::None, Pays::No).into()) } } @@ -326,6 +436,7 @@ mod pallet { let open_ids_len = Self::clear_auto_open(&market_id)?; let close_ids_len = Self::clear_auto_close(&market_id)?; Self::close_market(&market_id)?; + Self::set_market_end(&market_id)?; // The CloseOrigin should not pay fees for providing this service Ok(( Some(T::WeightInfo::admin_move_market_to_closed(open_ids_len, close_ids_len)), @@ -346,15 +457,9 @@ mod pallet { .max( T::WeightInfo::admin_move_market_to_resolved_categorical_reported(CacheSize::get()) ).max( - T::WeightInfo::admin_move_market_to_resolved_scalar_disputed( - CacheSize::get(), - T::MaxDisputes::get() - ) + T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(CacheSize::get()) ).max( - T::WeightInfo::admin_move_market_to_resolved_categorical_disputed( - CacheSize::get(), - T::MaxDisputes::get() - ) + T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(CacheSize::get()) ), Pays::No, ))] @@ -370,7 +475,7 @@ mod pallet { market.status == MarketStatus::Reported || market.status == MarketStatus::Disputed, Error::::InvalidMarketStatus, ); - let (ids_len, disputes_len) = Self::clear_auto_resolve(&market_id)?; + let (ids_len, _) = Self::clear_auto_resolve(&market_id)?; let market = >::market(&market_id)?; let _ = Self::on_resolution(&market_id, &market)?; let weight = match market.market_type { @@ -379,10 +484,7 @@ mod pallet { T::WeightInfo::admin_move_market_to_resolved_scalar_reported(ids_len) } MarketStatus::Disputed => { - T::WeightInfo::admin_move_market_to_resolved_scalar_disputed( - ids_len, - disputes_len, - ) + T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(ids_len) } _ => return Err(Error::::InvalidMarketStatus.into()), }, @@ -391,10 +493,7 @@ mod pallet { T::WeightInfo::admin_move_market_to_resolved_categorical_reported(ids_len) } MarketStatus::Disputed => { - T::WeightInfo::admin_move_market_to_resolved_categorical_disputed( - ids_len, - disputes_len, - ) + T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(ids_len) } _ => return Err(Error::::InvalidMarketStatus.into()), }, @@ -421,7 +520,7 @@ mod pallet { ) -> DispatchResultWithPostInfo { // TODO(#787): Handle Rikiddo benchmarks! T::ApproveOrigin::ensure_origin(origin)?; - let mut extra_weight = 0; + let mut extra_weight = Weight::zero(); let mut status = MarketStatus::Active; >::mutate_market(&market_id, |m| { @@ -526,10 +625,7 @@ mod pallet { /// # Weight /// /// Complexity: `O(n)`, where `n` is the number of outstanding disputes. - #[pallet::weight(T::WeightInfo::dispute_authorized( - T::MaxDisputes::get(), - CacheSize::get() - ))] + #[pallet::weight(T::WeightInfo::dispute_authorized())] #[transactional] pub fn dispute( origin: OriginFor, @@ -552,6 +648,7 @@ mod pallet { &who, default_dispute_bond::(disputes.len()), )?; + // TODO(#782): use multiple benchmarks paths for different dispute mechanisms match market.dispute_mechanism { MarketDisputeMechanism::Authorized => { T::Authorized::on_dispute(&disputes, &market_id, &market)? @@ -563,26 +660,18 @@ mod pallet { T::SimpleDisputes::on_dispute(&disputes, &market_id, &market)? } } - Self::remove_last_dispute_from_market_ids_per_dispute_block(&disputes, &market_id)?; + Self::set_market_as_disputed(&market, &market_id)?; let market_dispute = MarketDispute { at: curr_block_num, by: who, outcome }; >::try_mutate(market_id, |disputes| { disputes.try_push(market_dispute.clone()).map_err(|_| >::StorageOverflow) })?; - // each dispute resets dispute_duration - let dispute_duration_ends_at_block = - curr_block_num.saturating_add(market.deadlines.dispute_duration); - >::try_mutate(dispute_duration_ends_at_block, |ids| { - ids.try_push(market_id).map_err(|_| >::StorageOverflow) - })?; - Self::deposit_event(Event::MarketDisputed( market_id, MarketStatus::Disputed, market_dispute, )); - // TODO(#782): add court benchmark - Ok((Some(T::WeightInfo::dispute_authorized(num_disputes, CacheSize::get()))).into()) + Ok((Some(T::WeightInfo::dispute_authorized())).into()) } /// Create a permissionless market, buy complete sets and deploy a pool with specified @@ -625,6 +714,7 @@ mod pallet { #[transactional] pub fn create_cpmm_market_and_deploy_assets( origin: OriginFor, + base_asset: Asset>, oracle: T::AccountId, period: MarketPeriod>, deadlines: Deadlines, @@ -639,6 +729,7 @@ mod pallet { let create_market_weight = Self::create_market( origin.clone(), + base_asset, oracle, period, deadlines, @@ -676,6 +767,7 @@ mod pallet { #[transactional] pub fn create_market( origin: OriginFor, + base_asset: Asset>, oracle: T::AccountId, period: MarketPeriod>, deadlines: Deadlines, @@ -692,14 +784,17 @@ mod pallet { MarketCreation::Advised => MarketBonds { creation: Some(Bond::new(sender.clone(), T::AdvisoryBond::get())), oracle: Some(Bond::new(sender.clone(), T::OracleBond::get())), + ..Default::default() }, MarketCreation::Permissionless => MarketBonds { creation: Some(Bond::new(sender.clone(), T::ValidityBond::get())), oracle: Some(Bond::new(sender.clone(), T::OracleBond::get())), + ..Default::default() }, }; let market = Self::construct_market( + base_asset, sender.clone(), 0_u8, oracle, @@ -724,7 +819,7 @@ mod pallet { let market_id = >::push_market(market.clone())?; let market_account = >::market_account(market_id); - let mut extra_weight = 0; + let mut extra_weight = Weight::zero(); if market.status == MarketStatus::CollectingSubsidy { extra_weight = Self::start_subsidy(&market, market_id)?; @@ -760,6 +855,7 @@ mod pallet { #[transactional] pub fn edit_market( origin: OriginFor, + base_asset: Asset>, market_id: MarketIdOf, oracle: T::AccountId, period: MarketPeriod>, @@ -781,6 +877,7 @@ mod pallet { Self::clear_auto_close(&market_id)?; let edited_market = Self::construct_market( + base_asset, old_market.creator, old_market.creator_fee, oracle, @@ -910,8 +1007,7 @@ mod pallet { // this could stall the chain, because a malicious user puts a large vector in ensure!(weights.len() == assets.len(), Error::::WeightsLenMustEqualAssetsLen); - let base_asset = Asset::Ztg; - assets.push(base_asset); + assets.push(market.base_asset); let base_asset_weight = weights.iter().fold(0u128, |acc, val| acc.saturating_add(*val)); weights.push(base_asset_weight); @@ -919,7 +1015,7 @@ mod pallet { let pool_id = T::Swaps::create_pool( sender, assets, - base_asset, + market.base_asset, market_id, ScoringRule::CPMM, Some(swap_fee), @@ -1019,7 +1115,7 @@ mod pallet { // Ensure the market account has enough to pay out - if this is // ever not true then we have an accounting problem. ensure!( - T::AssetManager::free_balance(Asset::Ztg, &market_account) + T::AssetManager::free_balance(market.base_asset, &market_account) >= winning_balance, Error::::InsufficientFundsInMarketAccount, ); @@ -1073,7 +1169,7 @@ mod pallet { // Ensure the market account has enough to pay out - if this is // ever not true then we have an accounting problem. ensure!( - T::AssetManager::free_balance(Asset::Ztg, &market_account) + T::AssetManager::free_balance(market.base_asset, &market_account) >= long_payout.saturating_add(short_payout), Error::::InsufficientFundsInMarketAccount, ); @@ -1090,10 +1186,16 @@ mod pallet { T::AssetManager::slash(currency_id, &sender, balance); // Pay out the winner. - let remaining_bal = T::AssetManager::free_balance(Asset::Ztg, &market_account); + let remaining_bal = + T::AssetManager::free_balance(market.base_asset, &market_account); let actual_payout = payout.min(remaining_bal); - T::AssetManager::transfer(Asset::Ztg, &market_account, &sender, actual_payout)?; + T::AssetManager::transfer( + market.base_asset, + &market_account, + &sender, + actual_payout, + )?; // The if-check prevents scalar markets to emit events even if sender only owns one // of the outcome tokens. if balance != >::zero() { @@ -1114,7 +1216,8 @@ mod pallet { return Ok(Some(T::WeightInfo::redeem_shares_scalar()).into()); } - Ok(None.into()) + let default_weight: Option = None; + Ok((default_weight, Pays::No).into()) } /// Rejects a market that is waiting for approval from the advisory committee. @@ -1220,13 +1323,26 @@ mod pallet { } } + let sender_is_oracle = sender == market.oracle; + let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok(); + let sender_is_outsider = !sender_is_oracle && !origin_has_permission; + if should_check_origin { - let sender_is_oracle = sender == market.oracle; - let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok(); ensure!( sender_is_oracle || origin_has_permission, Error::::ReporterNotOracle ); + } else if sender_is_outsider { + let outsider_bond = T::OutsiderBond::get(); + + market.bonds.outsider = Some(Bond::new(sender.clone(), outsider_bond)); + + T::AssetManager::reserve_named( + &Self::reserve_id(), + Asset::Ztg, + &sender, + outsider_bond, + )?; } market.report = Some(market_report.clone()); @@ -1279,7 +1395,7 @@ mod pallet { let market_account = >::market_account(market_id); ensure!( - T::AssetManager::free_balance(Asset::Ztg, &market_account) >= amount, + T::AssetManager::free_balance(market.base_asset, &market_account) >= amount, "Market account does not have sufficient reserves.", ); @@ -1300,7 +1416,7 @@ mod pallet { T::AssetManager::slash(*asset, &sender, amount); } - T::AssetManager::transfer(Asset::Ztg, &market_account, &sender, amount)?; + T::AssetManager::transfer(market.base_asset, &market_account, &sender, amount)?; Self::deposit_event(Event::SoldCompleteSet(market_id, amount, sender)); let assets_len: u32 = assets.len().saturated_into(); @@ -1318,7 +1434,7 @@ mod pallet { /// The outcomes of the disputes and the report outcome /// are added to the global dispute voting outcomes. /// The bond of each dispute is the initial vote amount. - #[pallet::weight(T::WeightInfo::start_global_dispute(CacheSize::get()))] + #[pallet::weight(T::WeightInfo::start_global_dispute(CacheSize::get(), CacheSize::get()))] #[transactional] pub fn start_global_dispute( origin: OriginFor, @@ -1350,10 +1466,10 @@ mod pallet { ); // add report outcome to voting choices - if let Some(report) = market.report { + if let Some(report) = &market.report { T::GlobalDisputes::push_voting_outcome( &market_id, - report.outcome, + report.outcome.clone(), &report.by, >::zero(), )?; @@ -1369,9 +1485,12 @@ mod pallet { )?; } + // TODO(#372): Allow court with global disputes. // ensure, that global disputes controls the resolution now // it does not end after the dispute period now, but after the global dispute end - Self::remove_last_dispute_from_market_ids_per_dispute_block(&disputes, &market_id)?; + + // ignore first of tuple because we always have max disputes + let (_, ids_len_2) = Self::clear_auto_resolve(&market_id)?; let now = >::block_number(); let global_dispute_end = now.saturating_add(T::GlobalDisputePeriod::get()); @@ -1385,7 +1504,7 @@ mod pallet { Self::deposit_event(Event::GlobalDisputeStarted(market_id)); - Ok(Some(T::WeightInfo::start_global_dispute(market_ids_len)).into()) + Ok(Some(T::WeightInfo::start_global_dispute(market_ids_len, ids_len_2)).into()) } #[cfg(not(feature = "with-global-disputes"))] @@ -1405,41 +1524,48 @@ mod pallet { type AdvisoryBondSlashPercentage: Get; /// The origin that is allowed to approve / reject pending advised markets. - type ApproveOrigin: EnsureOrigin; + type ApproveOrigin: EnsureOrigin; /// Shares of outcome assets and native currency type AssetManager: ZeitgeistAssetManager< - Self::AccountId, - Balance = as Currency>::Balance, - CurrencyId = Asset>, - ReserveIdentifier = [u8; 8], - >; + Self::AccountId, + Balance = as Currency>::Balance, + CurrencyId = Asset>, + ReserveIdentifier = [u8; 8], + >; + + #[cfg(feature = "parachain")] + type AssetRegistry: Inspect< + AssetId = Asset>, + Balance = BalanceOf, + CustomMetadata = CustomMetadata, + >; /// See [`zrml_authorized::AuthorizedPalletApi`]. type Authorized: zrml_authorized::AuthorizedPalletApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - Moment = MomentOf, - Origin = Self::Origin, - >; + AccountId = Self::AccountId, + Balance = BalanceOf, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + Origin = Self::RuntimeOrigin, + >; /// The origin that is allowed to close markets. - type CloseOrigin: EnsureOrigin; + type CloseOrigin: EnsureOrigin; /// See [`zrml_court::CourtPalletApi`]. type Court: zrml_court::CourtPalletApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - Moment = MomentOf, - Origin = Self::Origin, - >; + AccountId = Self::AccountId, + Balance = BalanceOf, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + Origin = Self::RuntimeOrigin, + >; /// The origin that is allowed to destroy markets. - type DestroyOrigin: EnsureOrigin; + type DestroyOrigin: EnsureOrigin; /// The base amount of currency that must be bonded in order to create a dispute. #[pallet::constant] @@ -1451,26 +1577,22 @@ mod pallet { type DisputeFactor: Get>; /// Event - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// See [`GlobalDisputesPalletApi`]. #[cfg(feature = "with-global-disputes")] - type GlobalDisputes: GlobalDisputesPalletApi< - MarketIdOf, - Self::AccountId, - BalanceOf, - >; + type GlobalDisputes: GlobalDisputesPalletApi, Self::AccountId, BalanceOf>; /// The number of blocks the global dispute period remains open. #[cfg(feature = "with-global-disputes")] type GlobalDisputePeriod: Get; type LiquidityMining: LiquidityMiningPalletApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - >; + AccountId = Self::AccountId, + Balance = BalanceOf, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + >; /// The maximum number of categories available for categorical markets. #[pallet::constant] @@ -1521,19 +1643,23 @@ mod pallet { #[pallet::constant] type MaxRejectReasonLen: Get; - /// The maximum allowed timepoint for the market period (timestamp or blocknumber). - type MaxMarketPeriod: Get; + /// The maximum allowed duration of a market from creation to market close in blocks. + #[pallet::constant] + type MaxMarketLifetime: Get; /// The maximum number of bytes allowed as edit reason. #[pallet::constant] type MaxEditReasonLen: Get; + #[pallet::constant] + type OutsiderBond: Get>; + /// The module identifier. #[pallet::constant] type PalletId: Get; /// The origin that is allowed to reject pending advised markets. - type RejectOrigin: EnsureOrigin; + type RejectOrigin: EnsureOrigin; /// The base amount of currency that must be bonded to ensure the oracle reports /// in a timely manner. @@ -1541,20 +1667,20 @@ mod pallet { type OracleBond: Get>; /// The origin that is allowed to request edits in pending advised markets. - type RequestEditOrigin: EnsureOrigin; + type RequestEditOrigin: EnsureOrigin; /// The origin that is allowed to resolve markets. - type ResolveOrigin: EnsureOrigin; + type ResolveOrigin: EnsureOrigin; /// See [`DisputeApi`]. type SimpleDisputes: DisputeApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - Moment = MomentOf, - Origin = Self::Origin, - >; + AccountId = Self::AccountId, + Balance = BalanceOf, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + Origin = Self::RuntimeOrigin, + >; /// Handler for slashed funds. type Slash: OnUnbalanced>; @@ -1596,6 +1722,8 @@ mod pallet { NotEnoughBalance, /// Market is already reported on. MarketAlreadyReported, + /// The market duration is longer than allowed. + MarketDurationTooLong, /// Market edit request is already in progress. MarketEditRequestAlreadyInProgress, /// Market is not requested for edit. @@ -1666,6 +1794,10 @@ mod pallet { WeightsLenMustEqualAssetsLen, /// The start of the global dispute for this market happened already. GlobalDisputeAlreadyStarted, + /// Provided base_asset is not allowed to be used as base_asset. + InvalidBaseAsset, + /// A foreign asset in not registered in AssetRegistry. + UnregisteredForeignAsset, } #[pallet::event] @@ -1674,13 +1806,13 @@ mod pallet { where T: Config, { - /// Custom addition block initialization logic wasn't successful + /// Custom addition block initialization logic wasn't successful. BadOnInitialize, - /// A complete set of assets has been bought \[market_id, amount_per_asset, buyer\] + /// A complete set of assets has been bought. \[market_id, amount_per_asset, buyer\] BoughtCompleteSet(MarketIdOf, BalanceOf, ::AccountId), - /// A market has been approved \[market_id, new_market_status\] + /// A market has been approved. \[market_id, new_market_status\] MarketApproved(MarketIdOf, MarketStatus), - /// A market has been created \[market_id, market_account, market\] + /// A market has been created. \[market_id, market_account, market\] MarketCreated(MarketIdOf, T::AccountId, MarketOf), /// A market has been destroyed. \[market_id\] MarketDestroyed(MarketIdOf), @@ -1689,25 +1821,26 @@ mod pallet { /// A market was discarded after failing to gather enough subsidy. /// \[market_id, new_market_status\] MarketInsufficientSubsidy(MarketIdOf, MarketStatus), - /// A market has been closed \[market_id\] + /// A market has been closed. \[market_id\] MarketClosed(MarketIdOf), - /// A market has been disputed \[market_id, new_market_status, new_outcome\] + /// A market has been disputed. \[market_id, new_market_status, new_outcome\] MarketDisputed(MarketIdOf, MarketStatus, MarketDispute), /// An advised market has ended before it was approved or rejected. \[market_id\] MarketExpired(MarketIdOf), - /// A pending market has been rejected as invalid with a reason. \[market_id, reject_reason\] + /// A pending market has been rejected as invalid with a reason. + /// \[market_id, reject_reason\] MarketRejected(MarketIdOf, RejectReason), - /// A market has been reported on \[market_id, new_market_status, reported_outcome\] + /// A market has been reported on. \[market_id, new_market_status, reported_outcome\] MarketReported(MarketIdOf, MarketStatus, Report), - /// A market has been resolved \[market_id, new_market_status, real_outcome\] + /// A market has been resolved. \[market_id, new_market_status, real_outcome\] MarketResolved(MarketIdOf, MarketStatus, OutcomeReport), /// A proposed market has been requested edit by advisor. \[market_id, edit_reason\] MarketRequestedEdit(MarketIdOf, EditReason), - /// A proposed market has been edited by the market creator \[market_id\] + /// A proposed market has been edited by the market creator. \[market_id, new_market\] MarketEdited(MarketIdOf, MarketOf), - /// A complete set of assets has been sold \[market_id, amount_per_asset, seller\] + /// A complete set of assets has been sold. \[market_id, amount_per_asset, seller\] SoldCompleteSet(MarketIdOf, BalanceOf, ::AccountId), - /// An amount of winning outcomes have been redeemed + /// An amount of winning outcomes have been redeemed. /// \[market_id, currency_id, amount_redeemed, payout, who\] TokensRedeemed( MarketIdOf, @@ -1724,7 +1857,7 @@ mod pallet { impl Hooks for Pallet { // TODO(#792): Remove outcome assets for accounts! Delete "resolved" assets of `orml_tokens` with storage migration. fn on_initialize(now: T::BlockNumber) -> Weight { - let mut total_weight: Weight = 0u64; + let mut total_weight: Weight = Weight::zero(); // TODO(#808): Use weight when Rikiddo is ready let _ = Self::process_subsidy_collecting_markets( @@ -1930,8 +2063,27 @@ mod pallet { impl Pallet { impl_unreserve_bond!(unreserve_creation_bond, creation); impl_unreserve_bond!(unreserve_oracle_bond, oracle); + impl_unreserve_bond!(unreserve_outsider_bond, outsider); impl_slash_bond!(slash_creation_bond, creation); impl_slash_bond!(slash_oracle_bond, oracle); + impl_slash_bond!(slash_outsider_bond, outsider); + impl_repatriate_bond!(repatriate_oracle_bond, oracle); + impl_is_bond_pending!(is_creation_bond_pending, creation); + impl_is_bond_pending!(is_oracle_bond_pending, oracle); + impl_is_bond_pending!(is_outsider_bond_pending, outsider); + + fn slash_pending_bonds(market_id: &MarketIdOf, market: &MarketOf) -> DispatchResult { + if Self::is_creation_bond_pending(market_id, market, false) { + Self::slash_creation_bond(market_id, None)?; + } + if Self::is_oracle_bond_pending(market_id, market, false) { + Self::slash_oracle_bond(market_id, None)?; + } + if Self::is_outsider_bond_pending(market_id, market, false) { + Self::slash_outsider_bond(market_id, None)?; + } + Ok(()) + } pub fn outcome_assets( market_id: MarketIdOf, @@ -2054,17 +2206,24 @@ mod pallet { } MarketStatus::Disputed => { let disputes = Disputes::::get(market_id); - let last_dispute = disputes.last().ok_or(Error::::MarketIsNotDisputed)?; - let dispute_duration_ends_at_block = - last_dispute.at.saturating_add(market.deadlines.dispute_duration); - MarketIdsPerDisputeBlock::::mutate( - dispute_duration_ends_at_block, - |ids| -> (u32, u32) { - let ids_len = ids.len() as u32; - remove_item::, _>(ids, market_id); - (ids_len, disputes.len() as u32) - }, - ) + // TODO(#782): use multiple benchmarks paths for different dispute mechanisms + let auto_resolve_block_opt = match market.dispute_mechanism { + MarketDisputeMechanism::Authorized => { + T::Authorized::get_auto_resolve(&disputes, market_id, &market)? + } + MarketDisputeMechanism::Court => { + T::Court::get_auto_resolve(&disputes, market_id, &market)? + } + MarketDisputeMechanism::SimpleDisputes => { + T::SimpleDisputes::get_auto_resolve(&disputes, market_id, &market)? + } + }; + if let Some(auto_resolve_block) = auto_resolve_block_opt { + let ids_len = remove_auto_resolve::(market_id, auto_resolve_block); + (ids_len, disputes.len() as u32) + } else { + (0u32, disputes.len() as u32) + } } _ => (0u32, 0u32), }; @@ -2078,17 +2237,16 @@ mod pallet { amount: BalanceOf, ) -> DispatchResultWithPostInfo { ensure!(amount != BalanceOf::::zero(), Error::::ZeroAmount); + let market = >::market(&market_id)?; ensure!( - T::AssetManager::free_balance(Asset::Ztg, &who) >= amount, + T::AssetManager::free_balance(market.base_asset, &who) >= amount, Error::::NotEnoughBalance ); - - let market = >::market(&market_id)?; ensure!(market.scoring_rule == ScoringRule::CPMM, Error::::InvalidScoringRule); Self::ensure_market_is_active(&market)?; let market_account = >::market_account(market_id); - T::AssetManager::transfer(Asset::Ztg, &who, &market_account, amount)?; + T::AssetManager::transfer(market.base_asset, &who, &market_account, amount)?; let assets = Self::outcome_assets(market_id, &market); for asset in assets.iter() { @@ -2135,17 +2293,17 @@ mod pallet { time.saturated_into::().saturating_div(MILLISECS_PER_BLOCK.into()) } - fn calculate_internal_resolve_weight(market: &MarketOf, total_disputes: u32) -> Weight { + fn calculate_internal_resolve_weight(market: &MarketOf) -> Weight { if let MarketType::Categorical(_) = market.market_type { if let MarketStatus::Reported = market.status { T::WeightInfo::internal_resolve_categorical_reported() } else { - T::WeightInfo::internal_resolve_categorical_disputed(total_disputes) + T::WeightInfo::internal_resolve_categorical_disputed() } } else if let MarketStatus::Reported = market.status { T::WeightInfo::internal_resolve_scalar_reported() } else { - T::WeightInfo::internal_resolve_scalar_disputed(total_disputes) + T::WeightInfo::internal_resolve_scalar_disputed() } } @@ -2182,28 +2340,29 @@ mod pallet { // frame in the future. match period { MarketPeriod::Block(ref range) => { - ensure!( - >::block_number() < range.end, - Error::::InvalidMarketPeriod - ); + let now = >::block_number(); + ensure!(now < range.end, Error::::InvalidMarketPeriod); ensure!(range.start < range.end, Error::::InvalidMarketPeriod); + let lifetime = range.end.saturating_sub(now); // Never saturates! ensure!( - range.end <= T::MaxMarketPeriod::get().saturated_into(), - Error::::InvalidMarketPeriod + lifetime <= T::MaxMarketLifetime::get(), + Error::::MarketDurationTooLong, ); } MarketPeriod::Timestamp(ref range) => { // Ensure that the market lasts at least one time frame into the future. - let now_frame = Self::calculate_time_frame_of_moment( - >::now(), - ); + let now = >::now(); + let now_frame = Self::calculate_time_frame_of_moment(now); let end_frame = Self::calculate_time_frame_of_moment(range.end); ensure!(now_frame < end_frame, Error::::InvalidMarketPeriod); ensure!(range.start < range.end, Error::::InvalidMarketPeriod); - ensure!( - range.end <= T::MaxMarketPeriod::get().saturated_into::>(), - Error::::InvalidMarketPeriod - ); + // Verify that the number of frames that the market is open doesn't exceed the + // maximum allowed lifetime in blocks. + let lifetime = end_frame.saturating_sub(now_frame); // Never saturates! + // If this conversion saturates, we're dealing with a market with excessive + // lifetime: + let lifetime_max: TimeFrame = T::MaxMarketLifetime::get().saturated_into(); + ensure!(lifetime <= lifetime_max, Error::::MarketDurationTooLong); } }; Ok(()) @@ -2315,6 +2474,23 @@ mod pallet { Ok(total_weight) } + pub(crate) fn set_market_end(market_id: &MarketIdOf) -> Result { + >::mutate_market(market_id, |market| { + market.period = match market.period { + MarketPeriod::Block(ref range) => { + let current_block = >::block_number(); + MarketPeriod::Block(range.start..current_block) + } + MarketPeriod::Timestamp(ref range) => { + let now = >::now(); + MarketPeriod::Timestamp(range.start..now) + } + }; + Ok(()) + })?; + Ok(T::DbWeight::get().reads_writes(1, 1)) + } + /// Handle market state transitions at the end of its active phase. fn on_market_close( market_id: &MarketIdOf, @@ -2336,16 +2512,11 @@ mod pallet { if report.by == market.oracle { Self::unreserve_oracle_bond(market_id)?; } else { - let negative_imbalance = Self::slash_oracle_bond(market_id, None)?; - - // deposit only to the real reporter what actually was slashed - if let Err(err) = - T::AssetManager::deposit(Asset::Ztg, &report.by, negative_imbalance.peek()) - { - log::warn!( - "[PredictionMarkets] Cannot deposit to the reporter. error: {:?}", - err - ); + // reward outsider reporter with oracle bond + Self::repatriate_oracle_bond(market_id, &report.by)?; + + if Self::is_outsider_bond_pending(market_id, market, true) { + Self::unreserve_outsider_bond(market_id)?; } } @@ -2366,6 +2537,8 @@ mod pallet { resolved_outcome_option = Some(o); } + // TODO(#782): use multiple benchmarks paths for different dispute mechanisms + // Try to get the outcome of the MDM. If the MDM failed to resolve, default to // the oracle's report. if resolved_outcome_option.is_none() { @@ -2390,11 +2563,44 @@ mod pallet { // If the oracle reported right, return the OracleBond, otherwise slash it to // pay the correct reporters. let mut overall_imbalance = NegativeImbalanceOf::::zero(); - if report.by == market.oracle && report.outcome == resolved_outcome { - Self::unreserve_oracle_bond(market_id)?; + + let report_by_oracle = report.by == market.oracle; + let is_correct = report.outcome == resolved_outcome; + + let unreserve_outsider = || -> DispatchResult { + if Self::is_outsider_bond_pending(market_id, market, true) { + Self::unreserve_outsider_bond(market_id)?; + } + Ok(()) + }; + + let slash_outsider = || -> Result, DispatchError> { + if Self::is_outsider_bond_pending(market_id, market, true) { + let imbalance = Self::slash_outsider_bond(market_id, None)?; + return Ok(imbalance); + } + Ok(NegativeImbalanceOf::::zero()) + }; + + if report_by_oracle { + if is_correct { + Self::unreserve_oracle_bond(market_id)?; + } else { + let negative_imbalance = Self::slash_oracle_bond(market_id, None)?; + overall_imbalance.subsume(negative_imbalance); + } } else { - let imbalance = Self::slash_oracle_bond(market_id, None)?; - overall_imbalance.subsume(imbalance); + // outsider report + if is_correct { + // reward outsider reporter with oracle bond + Self::repatriate_oracle_bond(market_id, &report.by)?; + unreserve_outsider()?; + } else { + let oracle_imbalance = Self::slash_oracle_bond(market_id, None)?; + let outsider_imbalance = slash_outsider()?; + overall_imbalance.subsume(oracle_imbalance); + overall_imbalance.subsume(outsider_imbalance); + } } for (i, dispute) in disputes.iter().enumerate() { @@ -2438,13 +2644,12 @@ mod pallet { pub fn on_resolution( market_id: &MarketIdOf, market: &MarketOf, - ) -> Result { + ) -> Result { if market.creation == MarketCreation::Permissionless { Self::unreserve_creation_bond(market_id)?; } - let mut total_weight = 0; - let disputes = Disputes::::get(market_id); + let mut total_weight: Weight = Weight::zero(); let resolved_outcome = match market.status { MarketStatus::Reported => Self::resolve_reported_market(market_id, market)?, @@ -2470,17 +2675,14 @@ mod pallet { MarketStatus::Resolved, resolved_outcome, )); - Ok(total_weight.saturating_add(Self::calculate_internal_resolve_weight( - market, - disputes.len().saturated_into(), - ))) + Ok(total_weight.saturating_add(Self::calculate_internal_resolve_weight(market))) } pub(crate) fn process_subsidy_collecting_markets( current_block: T::BlockNumber, current_time: MomentOf, ) -> Weight { - let mut total_weight = 0; + let mut total_weight: Weight = Weight::zero(); let dbweight = T::DbWeight::get(); let one_read = T::DbWeight::get().reads(1); let one_write = T::DbWeight::get().writes(1); @@ -2620,7 +2822,7 @@ mod pallet { true }; - let mut weight_basis = 0; + let mut weight_basis = Weight::zero(); >::mutate( |e: &mut BoundedVec< SubsidyUntil, MarketIdOf>, @@ -2636,21 +2838,6 @@ mod pallet { weight_basis.saturating_add(total_weight) } - fn remove_last_dispute_from_market_ids_per_dispute_block( - disputes: &[MarketDispute], - market_id: &MarketIdOf, - ) -> DispatchResult { - if let Some(last_dispute) = disputes.last() { - let market = >::market(market_id)?; - let dispute_duration_ends_at_block = - last_dispute.at.saturating_add(market.deadlines.dispute_duration); - MarketIdsPerDisputeBlock::::mutate(dispute_duration_ends_at_block, |ids| { - remove_item::, _>(ids, market_id); - }); - } - Ok(()) - } - /// The reserve ID of the prediction-markets pallet. #[inline] pub fn reserve_id() -> [u8; 8] { @@ -2666,15 +2853,15 @@ mod pallet { where F: FnMut(&MarketIdOf, MarketOf) -> DispatchResult, MarketIdsPerBlock: frame_support::StorageMap< - T::BlockNumber, - BoundedVec, CacheSize>, - Query = BoundedVec, CacheSize>, - >, + T::BlockNumber, + BoundedVec, CacheSize>, + Query = BoundedVec, CacheSize>, + >, MarketIdsPerTimeFrame: frame_support::StorageMap< - TimeFrame, - BoundedVec, CacheSize>, - Query = BoundedVec, CacheSize>, - >, + TimeFrame, + BoundedVec, CacheSize>, + Query = BoundedVec, CacheSize>, + >, { let market_ids_per_block = MarketIdsPerBlock::get(block_number); for market_id in market_ids_per_block.iter() { @@ -2780,14 +2967,13 @@ mod pallet { ); let mut assets = Self::outcome_assets(market_id, market); - let base_asset = Asset::Ztg; - assets.push(base_asset); + assets.push(market.base_asset); let total_assets = assets.len(); let pool_id = T::Swaps::create_pool( market.creator.clone(), assets, - base_asset, + market.base_asset, market_id, market.scoring_rule, None, @@ -2820,6 +3006,7 @@ mod pallet { } fn construct_market( + base_asset: Asset>, creator: T::AccountId, creator_fee: u8, oracle: T::AccountId, @@ -2834,6 +3021,20 @@ mod pallet { resolved_outcome: Option, bonds: MarketBonds>, ) -> Result, DispatchError> { + let valid_base_asset = match base_asset { + Asset::Ztg => true, + #[cfg(feature = "parachain")] + Asset::ForeignAsset(fa) => { + if let Some(metadata) = T::AssetRegistry::metadata(&Asset::ForeignAsset(fa)) { + metadata.additional.allow_as_base_asset + } else { + return Err(Error::::UnregisteredForeignAsset.into()); + } + } + _ => false, + }; + + ensure!(valid_base_asset, Error::::InvalidBaseAsset); let MultiHash::Sha3_384(multihash) = metadata; ensure!(multihash[0] == 0x15 && multihash[1] == 0x30, >::InvalidMultihash); Self::ensure_market_period_is_valid(&period)?; @@ -2851,6 +3052,7 @@ mod pallet { MarketCreation::Advised => MarketStatus::Proposed, }; Ok(Market { + base_asset, creation, creator_fee, creator, @@ -2884,4 +3086,63 @@ mod pallet { items.swap_remove(pos); } } + + fn remove_auto_resolve( + market_id: &MarketIdOf, + resolve_at: T::BlockNumber, + ) -> u32 { + MarketIdsPerDisputeBlock::::mutate(resolve_at, |ids| -> u32 { + let ids_len = ids.len() as u32; + remove_item::, _>(ids, market_id); + ids_len + }) + } + + impl DisputeResolutionApi for Pallet + where + T: Config, + { + type AccountId = T::AccountId; + type Balance = BalanceOf; + type BlockNumber = T::BlockNumber; + type MarketId = MarketIdOf; + type MaxDisputes = T::MaxDisputes; + type Moment = MomentOf; + + fn resolve( + market_id: &Self::MarketId, + market: &MarketOf, + ) -> Result { + Self::on_resolution(market_id, market) + } + + fn add_auto_resolve( + market_id: &Self::MarketId, + resolve_at: Self::BlockNumber, + ) -> Result { + let ids_len = >::try_mutate( + resolve_at, + |ids| -> Result { + ids.try_push(*market_id).map_err(|_| >::StorageOverflow)?; + Ok(ids.len() as u32) + }, + )?; + Ok(ids_len) + } + + fn auto_resolve_exists(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> bool { + >::get(resolve_at).contains(market_id) + } + + fn remove_auto_resolve(market_id: &Self::MarketId, resolve_at: Self::BlockNumber) -> u32 { + remove_auto_resolve::(market_id, resolve_at) + } + + fn get_disputes( + market_id: &Self::MarketId, + ) -> BoundedVec, Self::MaxDisputes> + { + Disputes::::get(market_id) + } + } } diff --git a/zrml/prediction-markets/src/migrations.rs b/zrml/prediction-markets/src/migrations.rs index 08b190343..3bc5ddb7c 100644 --- a/zrml/prediction-markets/src/migrations.rs +++ b/zrml/prediction-markets/src/migrations.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -14,468 +15,3 @@ // // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . - -#[cfg(feature = "try-runtime")] -use crate::MarketIdOf; -use crate::{Config, MarketOf, MomentOf}; -#[cfg(feature = "try-runtime")] -use alloc::collections::BTreeMap; -#[cfg(feature = "try-runtime")] -use alloc::format; -use alloc::vec::Vec; -#[cfg(feature = "try-runtime")] -use frame_support::traits::OnRuntimeUpgradeHelpersExt; -use frame_support::{ - dispatch::Weight, - log, - migration::{put_storage_value, storage_iter}, - pallet_prelude::PhantomData, - traits::{Get, OnRuntimeUpgrade, StorageVersion}, - RuntimeDebug, -}; -use parity_scale_codec::{Decode, Encode}; -use scale_info::TypeInfo; -use zeitgeist_primitives::types::{ - Bond, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, - MarketStatus, MarketType, OutcomeReport, Report, ScoringRule, -}; -#[cfg(feature = "try-runtime")] -use zrml_market_commons::MarketCommonsPalletApi; -use zrml_market_commons::Pallet as MarketCommonsPallet; - -const MARKET_COMMONS: &[u8] = b"MarketCommons"; -const MARKETS: &[u8] = b"Markets"; -const MARKET_COMMONS_REQUIRED_STORAGE_VERSION: u16 = 4; -const MARKET_COMMONS_NEXT_STORAGE_VERSION: u16 = 5; - -#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct OldMarket { - pub creator: AI, - pub creation: MarketCreation, - pub creator_fee: u8, - pub oracle: AI, - pub metadata: Vec, - pub market_type: MarketType, - pub period: MarketPeriod, - pub deadlines: Deadlines, - pub scoring_rule: ScoringRule, - pub status: MarketStatus, - pub report: Option>, - pub resolved_outcome: Option, - pub dispute_mechanism: MarketDisputeMechanism, -} - -type OldMarketOf = OldMarket< - ::AccountId, - ::BlockNumber, - MomentOf, ->; - -pub struct RecordBonds(PhantomData); - -impl OnRuntimeUpgrade for RecordBonds { - fn on_runtime_upgrade() -> Weight { - let mut total_weight = T::DbWeight::get().reads(1); - let market_commons_version = StorageVersion::get::>(); - if market_commons_version != MARKET_COMMONS_REQUIRED_STORAGE_VERSION { - log::info!( - "RecordBonds: market-commons version is {:?}, but {:?} is required", - market_commons_version, - MARKET_COMMONS_REQUIRED_STORAGE_VERSION, - ); - return total_weight; - } - log::info!("RecordBonds: Starting..."); - - let new_markets = storage_iter::>(MARKET_COMMONS, MARKETS) - .map(|(key, old_market)| { - total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); - let creation = Some(match old_market.creation { - MarketCreation::Advised => Bond { - who: old_market.creator.clone(), - value: T::AdvisoryBond::get(), - is_settled: old_market.status != MarketStatus::Proposed, - }, - MarketCreation::Permissionless => Bond { - who: old_market.creator.clone(), - value: T::ValidityBond::get(), - is_settled: matches!( - old_market.status, - MarketStatus::Resolved | MarketStatus::InsufficientSubsidy, - ), - }, - }); - let oracle = Some(Bond { - who: old_market.creator.clone(), - value: T::OracleBond::get(), - is_settled: matches!( - old_market.status, - MarketStatus::Resolved | MarketStatus::InsufficientSubsidy, - ), - }); - let new_market = Market { - creator: old_market.creator, - creation: old_market.creation, - creator_fee: old_market.creator_fee, - oracle: old_market.oracle, - metadata: old_market.metadata, - market_type: old_market.market_type, - period: old_market.period, - scoring_rule: old_market.scoring_rule, - status: old_market.status, - report: old_market.report, - resolved_outcome: old_market.resolved_outcome, - dispute_mechanism: old_market.dispute_mechanism, - deadlines: old_market.deadlines, - bonds: MarketBonds { creation, oracle }, - }; - (key, new_market) - }) - .collect::>(); - - for (key, new_market) in new_markets { - put_storage_value::>(MARKET_COMMONS, MARKETS, &key, new_market); - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - } - - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION).put::>(); - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - log::info!("RecordBonds: Done!"); - total_weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::{migration::storage_key_iter, pallet_prelude::Blake2_128Concat}; - - let old_markets = storage_key_iter::, OldMarketOf, Blake2_128Concat>( - MARKET_COMMONS, - MARKETS, - ) - .collect::>(); - Self::set_temp_storage(old_markets, "old_markets"); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - let old_markets: BTreeMap, OldMarketOf> = - Self::get_temp_storage("old_markets").unwrap(); - let new_market_count = >::market_iter().count(); - assert_eq!(old_markets.len(), new_market_count); - for (market_id, new_market) in >::market_iter() { - let old_market = old_markets - .get(&market_id) - .expect(&format!("Market {:?} not found", market_id)[..]); - assert_eq!(new_market.creator, old_market.creator); - assert_eq!(new_market.creation, old_market.creation); - assert_eq!(new_market.creator_fee, old_market.creator_fee); - assert_eq!(new_market.oracle, old_market.oracle); - assert_eq!(new_market.metadata, old_market.metadata); - assert_eq!(new_market.market_type, old_market.market_type); - assert_eq!(new_market.period, old_market.period); - assert_eq!(new_market.deadlines, old_market.deadlines); - assert_eq!(new_market.scoring_rule, old_market.scoring_rule); - assert_eq!(new_market.status, old_market.status); - assert_eq!(new_market.report, old_market.report); - assert_eq!(new_market.resolved_outcome, old_market.resolved_outcome); - assert_eq!(new_market.dispute_mechanism, old_market.dispute_mechanism); - assert_eq!(new_market.bonds.oracle.unwrap().value, T::OracleBond::get()); - let expected_creation_bond = match new_market.creation { - MarketCreation::Advised => T::AdvisoryBond::get(), - MarketCreation::Permissionless => T::ValidityBond::get(), - }; - assert_eq!(new_market.bonds.creation.unwrap().value, expected_creation_bond); - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - mock::{ExtBuilder, Runtime}, - MarketIdOf, - }; - use frame_support::{dispatch::fmt::Debug, Blake2_128Concat, StorageHasher}; - use zrml_market_commons::MarketCommonsPalletApi; - - #[test] - fn on_runtime_upgrade_increments_the_storage_version() { - ExtBuilder::default().build().execute_with(|| { - set_up_version(); - RecordBonds::::on_runtime_upgrade(); - assert_eq!( - StorageVersion::get::>(), - MARKET_COMMONS_NEXT_STORAGE_VERSION - ); - }); - } - - #[test] - fn on_runtime_upgrade_is_noop_if_versions_are_not_correct() { - ExtBuilder::default().build().execute_with(|| { - // Don't set up chain to signal that storage is already up to date. - let test_vector = construct_test_vector(); - let new_markets = - test_vector.into_iter().map(|(_, new_market)| new_market).collect::>(); - populate_test_data::, MarketOf>( - MARKET_COMMONS, - MARKETS, - new_markets.clone(), - ); - RecordBonds::::on_runtime_upgrade(); - for (market_id, expected) in new_markets.iter().enumerate() { - let actual = - >::market(&(market_id as u128)).unwrap(); - assert_eq!(actual, *expected); - } - }); - } - - #[test] - fn on_runtime_upgrade_correctly_updates_markets() { - ExtBuilder::default().build().execute_with(|| { - set_up_version(); - let test_vector = construct_test_vector(); - let (old_markets, new_markets): (_, Vec>) = - test_vector.into_iter().unzip(); - populate_test_data::, OldMarketOf>( - MARKET_COMMONS, - MARKETS, - old_markets, - ); - RecordBonds::::on_runtime_upgrade(); - for (market_id, expected) in new_markets.iter().enumerate() { - let actual = - >::market(&(market_id as u128)).unwrap(); - assert_eq!(actual, *expected); - } - }); - } - - fn set_up_version() { - StorageVersion::new(MARKET_COMMONS_REQUIRED_STORAGE_VERSION) - .put::>(); - } - - fn construct_test_vector() -> Vec<(OldMarketOf, MarketOf)> { - let creator = 999; - let construct_markets = |creation: MarketCreation, status, bonds| { - let creator_fee = 1; - let oracle = 2; - let metadata = vec![3, 4, 5]; - let market_type = MarketType::Categorical(6); - let period = MarketPeriod::Block(7..8); - let scoring_rule = ScoringRule::CPMM; - let report = None; - let resolved_outcome = None; - let dispute_mechanism = MarketDisputeMechanism::Authorized; - let deadlines = Deadlines::default(); - - let old_market = OldMarket { - creator, - creation: creation.clone(), - creator_fee, - oracle, - metadata: metadata.clone(), - market_type: market_type.clone(), - period: period.clone(), - scoring_rule, - status, - report: report.clone(), - resolved_outcome: resolved_outcome.clone(), - dispute_mechanism: dispute_mechanism.clone(), - deadlines, - }; - let new_market = Market { - creator, - creation, - creator_fee, - oracle, - metadata, - market_type, - period, - scoring_rule, - status, - report, - resolved_outcome, - dispute_mechanism, - deadlines, - bonds, - }; - (old_market, new_market) - }; - vec![ - construct_markets( - MarketCreation::Permissionless, - MarketStatus::Disputed, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::ValidityBond::get(), - is_settled: false, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: false, - }), - }, - ), - construct_markets( - MarketCreation::Permissionless, - MarketStatus::Resolved, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::ValidityBond::get(), - is_settled: true, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: true, - }), - }, - ), - construct_markets( - MarketCreation::Advised, - MarketStatus::Proposed, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::AdvisoryBond::get(), - is_settled: false, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: false, - }), - }, - ), - construct_markets( - MarketCreation::Advised, - MarketStatus::Active, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::AdvisoryBond::get(), - is_settled: true, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: false, - }), - }, - ), - construct_markets( - MarketCreation::Advised, - MarketStatus::Resolved, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::AdvisoryBond::get(), - is_settled: true, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: true, - }), - }, - ), - // Technically, the market below has the wrong scoring rule, but that's irrelevant to - // the test. - construct_markets( - MarketCreation::Permissionless, - MarketStatus::InsufficientSubsidy, - MarketBonds { - creation: Some(Bond { - who: creator, - value: ::ValidityBond::get(), - is_settled: true, - }), - oracle: Some(Bond { - who: creator, - value: ::OracleBond::get(), - is_settled: true, - }), - }, - ), - ] - } - - #[allow(unused)] - fn populate_test_data(pallet: &[u8], prefix: &[u8], data: Vec) - where - H: StorageHasher, - K: TryFrom + Encode, - V: Encode + Clone, - >::Error: Debug, - { - for (key, value) in data.iter().enumerate() { - let storage_hash = utility::key_to_hash::(K::try_from(key).unwrap()); - put_storage_value::(pallet, prefix, &storage_hash, (*value).clone()); - } - } -} - -// We use these utilities to prevent having to make the swaps pallet a dependency of -// prediciton-markets. The calls are based on the implementation of `StorageVersion`, found here: -// https://github.com/paritytech/substrate/blob/bc7a1e6c19aec92bfa247d8ca68ec63e07061032/frame/support/src/traits/metadata.rs#L168-L230 -// and previous migrations. -mod utility { - use crate::{BalanceOf, Config, MarketIdOf}; - use alloc::vec::Vec; - use frame_support::{ - migration::{get_storage_value, put_storage_value}, - storage::{storage_prefix, unhashed}, - traits::StorageVersion, - Blake2_128Concat, StorageHasher, - }; - use parity_scale_codec::Encode; - use zeitgeist_primitives::types::{Pool, PoolId}; - - #[allow(unused)] - const SWAPS: &[u8] = b"Swaps"; - #[allow(unused)] - const POOLS: &[u8] = b"Pools"; - #[allow(unused)] - fn storage_prefix_of_swaps_pallet() -> [u8; 32] { - storage_prefix(b"Swaps", b":__STORAGE_VERSION__:") - } - #[allow(unused)] - pub fn key_to_hash(key: K) -> Vec - where - H: StorageHasher, - K: Encode, - { - key.using_encoded(H::hash).as_ref().to_vec() - } - #[allow(unused)] - pub fn get_on_chain_storage_version_of_swaps_pallet() -> StorageVersion { - let key = storage_prefix_of_swaps_pallet(); - unhashed::get_or_default(&key) - } - #[allow(unused)] - pub fn put_storage_version_of_swaps_pallet(value: u16) { - let key = storage_prefix_of_swaps_pallet(); - unhashed::put(&key, &StorageVersion::new(value)); - } - #[allow(unused)] - pub fn get_pool(pool_id: PoolId) -> Option, MarketIdOf>> { - let hash = key_to_hash::(pool_id); - let pool_maybe = - get_storage_value::, MarketIdOf>>>(SWAPS, POOLS, &hash); - pool_maybe.unwrap_or(None) - } - #[allow(unused)] - pub fn set_pool(pool_id: PoolId, pool: Pool, MarketIdOf>) { - let hash = key_to_hash::(pool_id); - put_storage_value(SWAPS, POOLS, &hash, Some(pool)); - } -} diff --git a/zrml/prediction-markets/src/mock.rs b/zrml/prediction-markets/src/mock.rs index 709f75167..f5d81641f 100644 --- a/zrml/prediction-markets/src/mock.rs +++ b/zrml/prediction-markets/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "mock")] @@ -27,6 +28,8 @@ use frame_support::{ traits::{Everything, NeverEnsureOrigin, OnFinalize, OnInitialize}, }; use frame_system::EnsureSignedBy; +#[cfg(feature = "parachain")] +use orml_asset_registry::AssetMetadata; use sp_arithmetic::per_things::Percent; use sp_runtime::{ testing::Header, @@ -35,15 +38,15 @@ use sp_runtime::{ use substrate_fixed::{types::extra::U33, FixedI128, FixedU128}; use zeitgeist_primitives::{ constants::mock::{ - AuthorizedPalletId, BalanceFractionalDecimals, BlockHashCount, CourtCaseDuration, - CourtPalletId, DisputeFactor, ExistentialDeposit, ExistentialDeposits, ExitFee, - GetNativeCurrencyId, LiquidityMiningPalletId, MaxApprovals, MaxAssets, MaxCategories, - MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGracePeriod, MaxInRatio, - MaxMarketPeriod, MaxOracleDuration, MaxOutRatio, MaxRejectReasonLen, MaxReserves, - MaxSubsidyPeriod, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, MinCategories, - MinDisputeDuration, MinLiquidity, MinOracleDuration, MinSubsidy, MinSubsidyPeriod, - MinWeight, MinimumPeriod, PmPalletId, SimpleDisputesPalletId, StakeWeight, SwapsPalletId, - TreasuryPalletId, BASE, CENT, MILLISECS_PER_BLOCK, + AuthorizedPalletId, BalanceFractionalDecimals, BlockHashCount, CorrectionPeriod, + CourtCaseDuration, CourtPalletId, DisputeFactor, ExistentialDeposit, ExistentialDeposits, + ExitFee, GetNativeCurrencyId, LiquidityMiningPalletId, MaxApprovals, MaxAssets, + MaxCategories, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGracePeriod, + MaxInRatio, MaxMarketLifetime, MaxOracleDuration, MaxOutRatio, MaxRejectReasonLen, + MaxReserves, MaxSubsidyPeriod, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, + MinCategories, MinDisputeDuration, MinOracleDuration, MinSubsidy, MinSubsidyPeriod, + MinWeight, MinimumPeriod, OutsiderBond, PmPalletId, SimpleDisputesPalletId, StakeWeight, + SwapsPalletId, TreasuryPalletId, BASE, CENT, MILLISECS_PER_BLOCK, }, types::{ AccountIdTest, Amount, Asset, Balance, BasicCurrencyAdapter, BlockNumber, BlockTest, @@ -101,7 +104,7 @@ construct_runtime!( SimpleDisputes: zrml_simple_disputes::{Event, Pallet, Storage}, GlobalDisputes: zrml_global_disputes::{Event, Pallet, Storage}, Swaps: zrml_swaps::{Call, Event, Pallet}, - System: frame_system::{Config, Event, Pallet, Storage}, + System: frame_system::{Call, Config, Event, Pallet, Storage}, Timestamp: pallet_timestamp::{Pallet}, Tokens: orml_tokens::{Config, Event, Pallet, Storage}, Treasury: pallet_treasury::{Call, Event, Pallet, Storage}, @@ -127,7 +130,7 @@ construct_runtime!( RikiddoSigmoidFeeMarketEma: zrml_rikiddo::{Pallet, Storage}, SimpleDisputes: zrml_simple_disputes::{Event, Pallet, Storage}, Swaps: zrml_swaps::{Call, Event, Pallet}, - System: frame_system::{Config, Event, Pallet, Storage}, + System: frame_system::{Call, Config, Event, Pallet, Storage}, Timestamp: pallet_timestamp::{Pallet}, Tokens: orml_tokens::{Config, Event, Pallet, Storage}, Treasury: pallet_treasury::{Call, Event, Pallet, Storage}, @@ -138,13 +141,15 @@ impl crate::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; type ApproveOrigin = EnsureSignedBy; + #[cfg(feature = "parachain")] + type AssetRegistry = MockRegistry; type Authorized = Authorized; type CloseOrigin = EnsureSignedBy; type Court = Court; type DestroyOrigin = EnsureSignedBy; type DisputeBond = DisputeBond; type DisputeFactor = DisputeFactor; - type Event = Event; + type RuntimeEvent = RuntimeEvent; #[cfg(feature = "with-global-disputes")] type GlobalDisputes = GlobalDisputes; #[cfg(feature = "with-global-disputes")] @@ -158,12 +163,13 @@ impl crate::Config for Runtime { type MaxGracePeriod = MaxGracePeriod; type MaxOracleDuration = MaxOracleDuration; type MaxSubsidyPeriod = MaxSubsidyPeriod; - type MaxMarketPeriod = MaxMarketPeriod; + type MaxMarketLifetime = MaxMarketLifetime; type MinCategories = MinCategories; type MinSubsidyPeriod = MinSubsidyPeriod; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; type OracleBond = OracleBond; + type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; type RejectOrigin = EnsureSignedBy; type RequestEditOrigin = EnsureSignedBy; @@ -184,9 +190,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -196,7 +202,7 @@ impl frame_system::Config for Runtime { type OnKilledAccount = (); type OnNewAccount = (); type OnSetCode = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -215,22 +221,28 @@ impl orml_tokens::Config for Runtime { type Balance = Balance; type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; type MaxLocks = (); type MaxReserves = MaxReserves; - type OnDust = (); - type OnKilledTokenAccount = (); - type OnNewTokenAccount = (); + type CurrencyHooks = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } +#[cfg(feature = "parachain")] +crate::orml_asset_registry::impl_mock_registry! { + MockRegistry, + CurrencyId, + Balance, + zeitgeist_primitives::types::CustomMetadata +} + impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = (); type MaxReserves = MaxReserves; @@ -252,17 +264,20 @@ ord_parameter_types! { } impl zrml_authorized::Config for Runtime { - type Event = Event; - type MarketCommons = MarketCommons; type AuthorizedDisputeResolutionOrigin = EnsureSignedBy; + type CorrectionPeriod = CorrectionPeriod; + type RuntimeEvent = RuntimeEvent; + type DisputeResolution = prediction_markets::Pallet; + type MarketCommons = MarketCommons; type PalletId = AuthorizedPalletId; type WeightInfo = zrml_authorized::weights::WeightInfo; } impl zrml_court::Config for Runtime { type CourtCaseDuration = CourtCaseDuration; - type Event = Event; + type DisputeResolution = prediction_markets::Pallet; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type PalletId = CourtPalletId; type Random = RandomnessCollectiveFlip; @@ -272,7 +287,7 @@ impl zrml_court::Config for Runtime { } impl zrml_liquidity_mining::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type MarketId = MarketId; type PalletId = LiquidityMiningPalletId; @@ -302,14 +317,15 @@ impl zrml_rikiddo::Config for Runtime { } impl zrml_simple_disputes::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; + type DisputeResolution = prediction_markets::Pallet; type MarketCommons = MarketCommons; type PalletId = SimpleDisputesPalletId; } #[cfg(feature = "with-global-disputes")] impl zrml_global_disputes::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type Currency = Balances; type GlobalDisputeLockId = GlobalDisputeLockId; @@ -323,7 +339,7 @@ impl zrml_global_disputes::Config for Runtime { } impl zrml_swaps::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExitFee = ExitFee; type FixedTypeU = ::FixedTypeU; type FixedTypeS = ::FixedTypeS; @@ -336,7 +352,6 @@ impl zrml_swaps::Config for Runtime { type MaxTotalWeight = MaxTotalWeight; type MaxWeight = MaxWeight; type MinAssets = MinAssets; - type MinLiquidity = MinLiquidity; type MinSubsidy = MinSubsidy; type MinSubsidyPerAccount = MinSubsidyPerAccount; type MinWeight = MinWeight; @@ -351,7 +366,7 @@ impl pallet_treasury::Config for Runtime { type Burn = (); type BurnDestination = (); type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxApprovals = MaxApprovals; type OnSlash = (); type PalletId = TreasuryPalletId; @@ -392,7 +407,50 @@ impl ExtBuilder { pallet_balances::GenesisConfig:: { balances: self.balances } .assimilate_storage(&mut t) .unwrap(); - + #[cfg(feature = "parachain")] + use frame_support::traits::GenesisBuild; + #[cfg(feature = "parachain")] + orml_tokens::GenesisConfig:: { + balances: (0..69) + .map(|idx| (idx, CurrencyId::ForeignAsset(100), INITIAL_BALANCE)) + .collect(), + } + .assimilate_storage(&mut t) + .unwrap(); + #[cfg(feature = "parachain")] + let custom_metadata = zeitgeist_primitives::types::CustomMetadata { + allow_as_base_asset: true, + ..Default::default() + }; + #[cfg(feature = "parachain")] + orml_asset_registry_mock::GenesisConfig { + metadata: vec![ + ( + CurrencyId::ForeignAsset(100), + AssetMetadata { + decimals: 18, + name: "ACALA USD".as_bytes().to_vec(), + symbol: "AUSD".as_bytes().to_vec(), + existential_deposit: 0, + location: None, + additional: custom_metadata, + }, + ), + ( + CurrencyId::ForeignAsset(420), + AssetMetadata { + decimals: 18, + name: "FANCY_TOKEN".as_bytes().to_vec(), + symbol: "FTK".as_bytes().to_vec(), + existential_deposit: 0, + location: None, + additional: zeitgeist_primitives::types::CustomMetadata::default(), + }, + ), + ], + } + .assimilate_storage(&mut t) + .unwrap(); t.into() } } diff --git a/zrml/prediction-markets/src/orml_asset_registry.rs b/zrml/prediction-markets/src/orml_asset_registry.rs new file mode 100644 index 000000000..ebabafa10 --- /dev/null +++ b/zrml/prediction-markets/src/orml_asset_registry.rs @@ -0,0 +1,257 @@ +// Copyright 2023 Forecasting Technologies Ltd. +// Copyright 2021 Centrifuge Foundation (centrifuge.io). +// +// This file is part of Zeitgeist. +// +// Zeitgeist 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. +// +// Zeitgeist 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 Zeitgeist. If not, see . + +#![cfg(all(feature = "mock", feature = "parachain"))] + +#[macro_export] +macro_rules! impl_mock_registry { + ($name:ident, $asset_id:ty, $balance:ty, $custom_metadata:ty) => { + pub use orml_asset_registry_mock::$name; + + mod orml_asset_registry_mock { + use frame_support::{ + dispatch::{DispatchError, DispatchResult}, + traits::GenesisBuild, + }; + use orml_traits::asset_registry::{AssetMetadata, Inspect, Mutate}; + use xcm::{latest::prelude::MultiLocation, VersionedMultiLocation}; + + use super::*; + + pub struct $name; + + impl Inspect for $name { + type AssetId = $asset_id; + type Balance = $balance; + type CustomMetadata = $custom_metadata; + + fn asset_id(location: &MultiLocation) -> Option { + __private::STATE.with(|s| s.borrow().get_asset_from_location(location)) + } + + fn metadata( + asset_id: &Self::AssetId, + ) -> Option> { + __private::STATE.with(|s| s.borrow().get_meta(asset_id)) + } + + fn metadata_by_location( + location: &MultiLocation, + ) -> Option> { + __private::STATE.with(|s| s.borrow().get_meta_from_location(location)) + } + + fn location( + asset_id: &Self::AssetId, + ) -> Result, DispatchError> { + let maybe_location = + __private::STATE.with(|s| s.borrow().get_location(asset_id)); + + Ok(maybe_location) + } + } + + impl Mutate for $name { + fn register_asset( + asset_id: Option, + metadata: AssetMetadata, + ) -> DispatchResult { + if let Some(asset_id) = asset_id { + __private::STATE.with(|s| s.borrow_mut().insert_meta(&asset_id, metadata)) + } else { + Err(DispatchError::Other("Mock can only register metadata with asset_id")) + } + } + + fn update_asset( + asset_id: Self::AssetId, + decimals: Option, + name: Option>, + symbol: Option>, + existential_deposit: Option, + location: Option>, + additional: Option, + ) -> DispatchResult { + __private::STATE.with(|s| { + s.borrow_mut().update_asset( + asset_id, + decimals, + name, + symbol, + existential_deposit, + location, + additional, + ) + }) + } + } + + #[derive(Default)] + pub struct GenesisConfig { + pub metadata: Vec<($asset_id, AssetMetadata<$balance, $custom_metadata>)>, + } + + use serde::{ + de::{Deserialize, Deserializer}, + ser::{Serialize, SerializeStruct, Serializer}, + }; + + impl GenesisBuild<()> for GenesisConfig { + fn build(&self) { + for (asset, metadata) in &self.metadata { + __private::STATE + .with(|s| s.borrow_mut().insert_meta(asset, metadata.clone())) + .expect("Genesis must not fail") + } + } + } + + // NOTE: We need this dummy impl as `AssetMetadata` does NOT derive + // serialize in std + impl Serialize for GenesisConfig { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let state = serializer.serialize_struct("GenesisConfig", 1)?; + state.end() + } + } + + // NOTE: We need this dummy impl as `AssetMetadata` does NOT derive + // deserialize in std + impl<'de> Deserialize<'de> for GenesisConfig { + fn deserialize(_deserializer: D) -> Result + where + D: Deserializer<'de>, + { + Ok(GenesisConfig::default()) + } + } + + mod __private { + use std::{cell::RefCell, vec::Vec}; + + use super::*; + + // TODO(#936): This will not be required post polkadot v0.9.29 upgrade. + pub struct RegistryState { + pub location_to_asset: Vec<(MultiLocation, $asset_id)>, + pub metadata: Vec<($asset_id, AssetMetadata<$balance, $custom_metadata>)>, + } + + impl RegistryState { + pub fn get_meta( + &self, + asset_id: &$asset_id, + ) -> Option> { + for (curr_id, meta) in &self.metadata { + if curr_id == asset_id { + return Some(meta.clone()); + } + } + + None + } + + pub fn insert_meta( + &mut self, + asset_id: &$asset_id, + meta: AssetMetadata<$balance, $custom_metadata>, + ) -> DispatchResult { + for (curr_id, curr_meta) in &mut self.metadata { + if curr_id == asset_id { + *curr_meta = meta; + return Ok(()); + } + } + + self.metadata.push((asset_id.clone(), meta)); + Ok(()) + } + + pub fn get_location(&self, asset_id: &$asset_id) -> Option { + for (curr_id, meta) in &self.metadata { + if curr_id == asset_id { + return meta + .location + .as_ref() + .map(|versioned| versioned.clone().try_into().ok()) + .flatten(); + } + } + + None + } + + pub fn get_asset_from_location( + &self, + location: &MultiLocation, + ) -> Option<$asset_id> { + for (curr_location, asset_id) in &self.location_to_asset { + if curr_location == location { + return Some(asset_id.clone()); + } + } + + None + } + + pub fn get_meta_from_location( + &self, + location: &MultiLocation, + ) -> Option> { + let asset_id = self.get_asset_from_location(location)?; + self.get_meta(&asset_id) + } + + pub fn update_asset( + &mut self, + asset_id: $asset_id, + _decimals: Option, + _name: Option>, + _symbol: Option>, + _existential_deposit: Option<$balance>, + _location: Option>, + _additional: Option<$custom_metadata>, + ) -> DispatchResult { + if let Some(_meta) = self.get_meta(&asset_id) { + Ok(()) + } else { + Err(DispatchError::Other("Asset not registered")) + } + } + } + + impl RegistryState { + fn new() -> Self { + Self { location_to_asset: Vec::new(), metadata: Vec::new() } + } + } + + thread_local! { + pub static STATE: RefCell< + RegistryState, + > = RefCell::new(RegistryState::new()); + } + } + } + }; +} + +pub use impl_mock_registry; diff --git a/zrml/prediction-markets/src/tests.rs b/zrml/prediction-markets/src/tests.rs index 7848524dc..83e772fb7 100644 --- a/zrml/prediction-markets/src/tests.rs +++ b/zrml/prediction-markets/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies Ltd. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -19,8 +20,9 @@ #![allow(clippy::reversed_empty_ranges)] use crate::{ - mock::*, Config, Error, Event, LastTimeFrame, MarketIdsForEdit, MarketIdsPerCloseBlock, - MarketIdsPerDisputeBlock, MarketIdsPerOpenBlock, MarketIdsPerReportBlock, + default_dispute_bond, mock::*, Config, Disputes, Error, Event, LastTimeFrame, MarketIdsForEdit, + MarketIdsPerCloseBlock, MarketIdsPerDisputeBlock, MarketIdsPerOpenBlock, + MarketIdsPerReportBlock, TimeFrame, }; use core::ops::{Range, RangeInclusive}; use frame_support::{ @@ -30,21 +32,23 @@ use frame_support::{ }; use test_case::test_case; -use orml_traits::MultiCurrency; +use orml_traits::{MultiCurrency, MultiReservableCurrency}; use sp_runtime::traits::{AccountIdConversion, SaturatedConversion, Zero}; use zeitgeist_primitives::{ - constants::mock::{DisputeFactor, BASE, CENT, MILLISECS_PER_BLOCK}, + constants::mock::{DisputeFactor, OutsiderBond, BASE, CENT, MILLISECS_PER_BLOCK}, traits::Swaps as SwapsPalletApi, types::{ AccountIdTest, Asset, Balance, BlockNumber, Bond, Deadlines, Market, MarketBonds, - MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, Moment, - MultiHash, OutcomeReport, PoolStatus, ScalarPosition, ScoringRule, + MarketCreation, MarketDisputeMechanism, MarketId, MarketPeriod, MarketStatus, MarketType, + Moment, MultiHash, OutcomeReport, PoolStatus, ScalarPosition, ScoringRule, }, }; +use zrml_authorized::Error as AuthorizedError; use zrml_market_commons::MarketCommonsPalletApi; use zrml_swaps::Pools; const SENTINEL_AMOUNT: u128 = BASE; +const LIQUIDITY: u128 = 100 * BASE; fn get_deadlines() -> Deadlines<::BlockNumber> { Deadlines { @@ -61,13 +65,39 @@ fn gen_metadata(byte: u8) -> MultiHash { MultiHash::Sha3_384(metadata) } +fn reserve_sentinel_amounts() { + // Reserve a sentinel amount to check that we don't unreserve too much. + assert_ok!(Balances::reserve_named(&PredictionMarkets::reserve_id(), &ALICE, SENTINEL_AMOUNT)); + assert_ok!(Balances::reserve_named(&PredictionMarkets::reserve_id(), &BOB, SENTINEL_AMOUNT)); + assert_ok!(Balances::reserve_named( + &PredictionMarkets::reserve_id(), + &CHARLIE, + SENTINEL_AMOUNT + )); + assert_ok!(Balances::reserve_named(&PredictionMarkets::reserve_id(), &DAVE, SENTINEL_AMOUNT)); + assert_ok!(Balances::reserve_named(&PredictionMarkets::reserve_id(), &EVE, SENTINEL_AMOUNT)); + assert_ok!(Balances::reserve_named(&PredictionMarkets::reserve_id(), &FRED, SENTINEL_AMOUNT)); + assert_eq!(Balances::reserved_balance(ALICE), SENTINEL_AMOUNT); + assert_eq!(Balances::reserved_balance(BOB), SENTINEL_AMOUNT); + assert_eq!(Balances::reserved_balance(CHARLIE), SENTINEL_AMOUNT); + assert_eq!(Balances::reserved_balance(DAVE), SENTINEL_AMOUNT); + assert_eq!(Balances::reserved_balance(EVE), SENTINEL_AMOUNT); + assert_eq!(Balances::reserved_balance(FRED), SENTINEL_AMOUNT); +} + +fn check_reserve(account: &AccountIdTest, expected: Balance) { + assert_eq!(Balances::reserved_balance(account), SENTINEL_AMOUNT + expected); +} + fn simple_create_categorical_market( + base_asset: Asset, creation: MarketCreation, period: Range, scoring_rule: ScoringRule, ) { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(period), get_deadlines(), @@ -80,12 +110,14 @@ fn simple_create_categorical_market( } fn simple_create_scalar_market( + base_asset: Asset, creation: MarketCreation, period: Range, scoring_rule: ScoringRule, ) { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(period), get_deadlines(), @@ -98,14 +130,72 @@ fn simple_create_scalar_market( } #[test] -fn admin_move_market_to_closed_successfully_closes_market() { +fn admin_move_market_to_closed_successfully_closes_market_and_sets_end_blocknumber() { ExtBuilder::default().build().execute_with(|| { - frame_system::Pallet::::set_block_number(1); - simple_create_categorical_market(MarketCreation::Permissionless, 0..2, ScoringRule::CPMM); + run_blocks(7); + let now = frame_system::Pallet::::block_number(); + let end = 42; + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + now..end, + ScoringRule::CPMM, + ); + run_blocks(3); + let market_id = 0; + assert_ok!(PredictionMarkets::admin_move_market_to_closed( + RuntimeOrigin::signed(SUDO), + market_id + )); + let market = MarketCommons::market(&market_id).unwrap(); + assert_eq!(market.status, MarketStatus::Closed); + let new_end = now + 3; + assert_eq!(market.period, MarketPeriod::Block(now..new_end)); + assert_ne!(new_end, end); + System::assert_last_event(Event::MarketClosed(market_id).into()); + }); +} + +#[test] +fn admin_move_market_to_closed_successfully_closes_market_and_sets_end_timestamp() { + ExtBuilder::default().build().execute_with(|| { + let start_block = 7; + set_timestamp_for_on_initialize(start_block * MILLISECS_PER_BLOCK as u64); + run_blocks(start_block); + let start = >::now(); + + let end = start + 42.saturated_into::() * MILLISECS_PER_BLOCK as u64; + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Timestamp(start..end), + get_deadlines(), + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(::MinCategories::get()), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM + )); let market_id = 0; - assert_ok!(PredictionMarkets::admin_move_market_to_closed(Origin::signed(SUDO), market_id)); + let market = MarketCommons::market(&market_id).unwrap(); + assert_eq!(market.period, MarketPeriod::Timestamp(start..end)); + + let shift_blocks = 3; + let shift = shift_blocks * MILLISECS_PER_BLOCK as u64; + // millisecs per block is substracted inside the function + set_timestamp_for_on_initialize(start + shift + MILLISECS_PER_BLOCK as u64); + run_blocks(shift_blocks); + + assert_ok!(PredictionMarkets::admin_move_market_to_closed( + RuntimeOrigin::signed(SUDO), + market_id + )); let market = MarketCommons::market(&market_id).unwrap(); assert_eq!(market.status, MarketStatus::Closed); + let new_end = start + shift; + assert_eq!(market.period, MarketPeriod::Timestamp(start..new_end)); + assert_ne!(new_end, end); System::assert_last_event(Event::MarketClosed(market_id).into()); }); } @@ -114,7 +204,7 @@ fn admin_move_market_to_closed_successfully_closes_market() { fn admin_move_market_to_closed_fails_if_market_does_not_exist() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - PredictionMarkets::admin_move_market_to_closed(Origin::signed(SUDO), 0), + PredictionMarkets::admin_move_market_to_closed(RuntimeOrigin::signed(SUDO), 0), zrml_market_commons::Error::::MarketDoesNotExist ); }); @@ -129,15 +219,20 @@ fn admin_move_market_to_closed_fails_if_market_does_not_exist() { #[test_case(MarketStatus::InsufficientSubsidy; "insufficient subsidy")] fn admin_move_market_to_closed_fails_if_market_is_not_active(market_status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); let market_id = 0; assert_ok!(MarketCommons::mutate_market(&market_id, |market| { market.status = market_status; Ok(()) })); assert_noop!( - PredictionMarkets::admin_move_market_to_closed(Origin::signed(SUDO), market_id), - crate::Error::::MarketIsNotActive, + PredictionMarkets::admin_move_market_to_closed(RuntimeOrigin::signed(SUDO), market_id), + Error::::MarketIsNotActive, ); }); } @@ -147,7 +242,8 @@ fn admin_move_market_to_closed_correctly_clears_auto_open_and_close_blocks() { ExtBuilder::default().build().execute_with(|| { let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(22..66), get_deadlines(), @@ -155,11 +251,12 @@ fn admin_move_market_to_closed_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(33..66), get_deadlines(), @@ -167,11 +264,12 @@ fn admin_move_market_to_closed_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(22..33), get_deadlines(), @@ -179,10 +277,10 @@ fn admin_move_market_to_closed_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); - assert_ok!(PredictionMarkets::admin_move_market_to_closed(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::admin_move_market_to_closed(RuntimeOrigin::signed(SUDO), 0)); let auto_close = MarketIdsPerCloseBlock::::get(66); assert_eq!(auto_close.len(), 1); @@ -200,7 +298,8 @@ fn create_scalar_market_fails_on_invalid_range(range: RangeInclusive) { ExtBuilder::default().build().execute_with(|| { assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), get_deadlines(), @@ -210,7 +309,7 @@ fn create_scalar_market_fails_on_invalid_range(range: RangeInclusive) { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::InvalidOutcomeRange + Error::::InvalidOutcomeRange ); }); } @@ -225,7 +324,8 @@ fn create_market_fails_on_min_dispute_period() { }; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), deadlines, @@ -235,7 +335,7 @@ fn create_market_fails_on_min_dispute_period() { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::DisputeDurationSmallerThanMinDisputeDuration + Error::::DisputeDurationSmallerThanMinDisputeDuration ); }); } @@ -250,7 +350,8 @@ fn create_market_fails_on_min_oracle_duration() { }; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), deadlines, @@ -260,7 +361,7 @@ fn create_market_fails_on_min_oracle_duration() { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::OracleDurationSmallerThanMinOracleDuration + Error::::OracleDurationSmallerThanMinOracleDuration ); }); } @@ -275,7 +376,8 @@ fn create_market_fails_on_max_dispute_period() { }; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), deadlines, @@ -285,7 +387,7 @@ fn create_market_fails_on_max_dispute_period() { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::DisputeDurationGreaterThanMaxDisputeDuration + Error::::DisputeDurationGreaterThanMaxDisputeDuration ); }); } @@ -300,7 +402,8 @@ fn create_market_fails_on_max_grace_period() { }; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), deadlines, @@ -310,7 +413,7 @@ fn create_market_fails_on_max_grace_period() { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::GracePeriodGreaterThanMaxGracePeriod + Error::::GracePeriodGreaterThanMaxGracePeriod ); }); } @@ -325,7 +428,8 @@ fn create_market_fails_on_max_oracle_duration() { }; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(123..456), deadlines, @@ -335,41 +439,121 @@ fn create_market_fails_on_max_oracle_duration() { MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, ), - crate::Error::::OracleDurationGreaterThanMaxOracleDuration + Error::::OracleDurationGreaterThanMaxOracleDuration ); }); } +#[cfg(feature = "parachain")] #[test] -fn admin_destroy_market_correctly_slashes_permissionless_market_active() { +fn create_market_with_foreign_assets() { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..2, ScoringRule::CPMM); + let deadlines = Deadlines { + grace_period: ::MaxGracePeriod::get(), + oracle_duration: ::MaxOracleDuration::get(), + dispute_duration: ::MaxDisputeDuration::get(), + }; + + // As per Mock asset_registry genesis ForeignAsset(420) has allow_as_base_asset set to false. + + assert_noop!( + PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(420), + BOB, + MarketPeriod::Block(123..456), + deadlines, + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(2), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM, + ), + Error::::InvalidBaseAsset, + ); + // As per Mock asset_registry genesis ForeignAsset(50) is not registered in asset_registry. + assert_noop!( + PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(50), + BOB, + MarketPeriod::Block(123..456), + deadlines, + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(2), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM, + ), + Error::::UnregisteredForeignAsset, + ); + // As per Mock asset_registry genesis ForeignAsset(100) has allow_as_base_asset set to true. + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(100), + BOB, + MarketPeriod::Block(123..456), + deadlines, + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(2), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM, + )); + let market = MarketCommons::market(&0).unwrap(); + assert_eq!(market.base_asset, Asset::ForeignAsset(100)); + }); +} + +#[test] +fn admin_destroy_market_correctly_slashes_permissionless_market_active() { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..2, + ScoringRule::CPMM, + ); assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); assert_ok!(Balances::reserve_named( &PredictionMarkets::reserve_id(), &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_permissionless_market_reported() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2_u64; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); run_to_block(end + market.deadlines.grace_period); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -379,34 +563,47 @@ fn admin_destroy_market_correctly_slashes_permissionless_market_reported() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_permissionless_market_disputed() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; assert_ne!(grace_period, 0); run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); run_to_block(grace_period + 2); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(0) )); @@ -416,27 +613,105 @@ fn admin_destroy_market_correctly_slashes_permissionless_market_disputed() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] -fn admin_destroy_market_correctly_slashes_permissionless_market_resolved() { +fn admin_destroy_market_correctly_unreserves_dispute_bonds() { ExtBuilder::default().build().execute_with(|| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); + let market_id = 0; + let market = MarketCommons::market(&market_id).unwrap(); + let grace_period = end + market.deadlines.grace_period; + assert_ne!(grace_period, 0); + run_to_block(grace_period + 1); + assert_ok!(PredictionMarkets::report( + RuntimeOrigin::signed(BOB), + 0, + OutcomeReport::Categorical(1) + )); + run_to_block(grace_period + 2); + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(0) + )); + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(DAVE), + 0, + OutcomeReport::Categorical(1) + )); + let set_up_account = |account| { + assert_ok!(AssetManager::deposit(Asset::Ztg, account, SENTINEL_AMOUNT)); + assert_ok!(Balances::reserve_named( + &PredictionMarkets::reserve_id(), + account, + SENTINEL_AMOUNT, + )); + }; + set_up_account(&CHARLIE); + set_up_account(&DAVE); + + let balance_free_before_charlie = Balances::free_balance(CHARLIE); + let balance_free_before_dave = Balances::free_balance(DAVE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), market_id)); + assert_eq!( + Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &CHARLIE), + SENTINEL_AMOUNT, + ); + assert_eq!( + Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &DAVE), + SENTINEL_AMOUNT, + ); + assert_eq!( + Balances::free_balance(CHARLIE), + balance_free_before_charlie + default_dispute_bond::(0) + ); + assert_eq!( + Balances::free_balance(DAVE), + balance_free_before_dave + default_dispute_bond::(1), + ); + assert!(Disputes::::get(market_id).is_empty()); + }); +} + +#[test] +fn admin_destroy_market_correctly_slashes_permissionless_market_resolved() { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + let end = 2; + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -448,100 +723,152 @@ fn admin_destroy_market_correctly_slashes_permissionless_market_resolved() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_proposed() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); assert_ok!(Balances::reserve_named( &PredictionMarkets::reserve_id(), &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_proposed_with_edit_request() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); assert_ok!(Balances::reserve_named( &PredictionMarkets::reserve_id(), &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); + let balance_free_before_alice = Balances::free_balance(ALICE); let market = MarketCommons::market(&0); assert_eq!(market.unwrap().status, MarketStatus::Proposed); let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason)); + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); assert!(MarketIdsForEdit::::contains_key(0)); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); assert!(!MarketIdsForEdit::::contains_key(0)); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_active() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); assert_ok!(Balances::reserve_named( &PredictionMarkets::reserve_id(), &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_reported() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Advised, 0..end, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..end, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -551,33 +878,46 @@ fn admin_destroy_market_correctly_slashes_advised_market_reported() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_disputed() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Advised, 0..end, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..end, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(0) )); @@ -587,28 +927,41 @@ fn admin_destroy_market_correctly_slashes_advised_market_disputed() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_destroy_market_correctly_slashes_advised_market_resolved() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Advised, 0..end, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..end, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -620,49 +973,88 @@ fn admin_destroy_market_correctly_slashes_advised_market_resolved() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + let balance_free_before_alice = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!( Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), SENTINEL_AMOUNT ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); assert_eq!(balance_free_before_alice, balance_free_after_alice); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } - #[test] fn admin_destroy_market_correctly_cleans_up_accounts() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { + let alice_ztg_before_market_creation = AssetManager::free_balance(Asset::Ztg, &ALICE); + let alice_base_asset_before_market_creation = + AssetManager::free_balance(base_asset, &ALICE); + let swap_fee = ::MaxSwapFee::get(); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, ALICE, MarketPeriod::Block(0..42), get_deadlines(), gen_metadata(50), MarketType::Categorical(3), MarketDisputeMechanism::SimpleDisputes, - ::MaxSwapFee::get(), - ::MinLiquidity::get(), + swap_fee, + LIQUIDITY, vec![::MinWeight::get(); 3], )); // Buy some outcome tokens for Alice so that we can check that they get destroyed. - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(ALICE), 0, BASE)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(ALICE), 0, BASE)); let market_id = 0; let pool_id = 0; let pool_account = Swaps::pool_account_id(&pool_id); let market_account = MarketCommons::market_account(market_id); - let alice_ztg_before = AssetManager::free_balance(Asset::Ztg, &ALICE); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 0), &pool_account), 0); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 1), &pool_account), 0); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 2), &pool_account), 0); - assert_eq!(AssetManager::free_balance(Asset::Ztg, &pool_account), 0); + assert_eq!(AssetManager::free_balance(base_asset, &pool_account), 0); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 0), &market_account), 0); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 1), &market_account), 0); assert_eq!(AssetManager::free_balance(Asset::CategoricalOutcome(0, 2), &market_account), 0); - assert_eq!(AssetManager::free_balance(Asset::Ztg, &market_account), 0); - assert_eq!(AssetManager::free_balance(Asset::Ztg, &ALICE), alice_ztg_before); + assert_eq!(AssetManager::free_balance(base_asset, &market_account), 0); + // premissionless market so using ValidityBond + let creation_bond = ::ValidityBond::get(); + let oracle_bond = ::OracleBond::get(); + // substract LIQUIDITY twice, one for buy_complete_set() in + // create_cpmm_market_and_deploy_assets() and one in swaps::create_pool() + // then again substract BASE as buy_complete_set() above + let expected_base_asset_value = + alice_base_asset_before_market_creation - LIQUIDITY - LIQUIDITY - BASE; + if base_asset == Asset::Ztg { + let alice_base_asset_balance = AssetManager::free_balance(base_asset, &ALICE); + assert_eq!( + alice_base_asset_balance, + expected_base_asset_value - creation_bond - oracle_bond + ); + } else { + let alice_base_asset_balance = AssetManager::free_balance(base_asset, &ALICE); + assert_eq!(alice_base_asset_balance, expected_base_asset_value); + let alice_ztg_balance = AssetManager::free_balance(Asset::Ztg, &ALICE); + assert_eq!( + alice_ztg_balance, + alice_ztg_before_market_creation - creation_bond - oracle_bond + ); + } + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -671,7 +1063,8 @@ fn admin_destroy_market_correctly_clears_auto_open_and_close_blocks() { ExtBuilder::default().build().execute_with(|| { let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(22..66), get_deadlines(), @@ -679,11 +1072,12 @@ fn admin_destroy_market_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(33..66), get_deadlines(), @@ -691,11 +1085,12 @@ fn admin_destroy_market_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(22..33), get_deadlines(), @@ -703,10 +1098,10 @@ fn admin_destroy_market_correctly_clears_auto_open_and_close_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); let auto_close = MarketIdsPerCloseBlock::::get(66); assert_eq!(auto_close.len(), 1); @@ -720,9 +1115,15 @@ fn admin_destroy_market_correctly_clears_auto_open_and_close_blocks() { #[test] fn admin_move_market_to_resolved_resolves_reported_market() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 33; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market_id = 0; // Give ALICE `SENTINEL_AMOUNT` free and reserved ZTG; we record the free balance to check @@ -733,7 +1134,7 @@ fn admin_move_market_to_resolved_resolves_reported_market() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before = Balances::free_balance(&ALICE); + let balance_free_before = Balances::free_balance(ALICE); let balance_reserved_before = Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE); @@ -743,12 +1144,12 @@ fn admin_move_market_to_resolved_resolves_reported_market() { let category = 1; let outcome_report = OutcomeReport::Categorical(category); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, outcome_report.clone() )); assert_ok!(PredictionMarkets::admin_move_market_to_resolved( - Origin::signed(SUDO), + RuntimeOrigin::signed(SUDO), market_id )); @@ -767,11 +1168,18 @@ fn admin_move_market_to_resolved_resolves_reported_market() { - ::ValidityBond::get() ); assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), balance_free_before + ::OracleBond::get() + ::ValidityBond::get() ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -783,15 +1191,23 @@ fn admin_move_market_to_resovled_fails_if_market_is_not_reported_or_disputed( market_status: MarketStatus, ) { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..33, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..33, + ScoringRule::CPMM, + ); let market_id = 0; assert_ok!(MarketCommons::mutate_market(&market_id, |market| { market.status = market_status; Ok(()) })); assert_noop!( - PredictionMarkets::admin_move_market_to_resolved(Origin::signed(SUDO), market_id,), - crate::Error::::InvalidMarketStatus, + PredictionMarkets::admin_move_market_to_resolved( + RuntimeOrigin::signed(SUDO), + market_id, + ), + Error::::InvalidMarketStatus, ); }); } @@ -799,16 +1215,26 @@ fn admin_move_market_to_resovled_fails_if_market_is_not_reported_or_disputed( #[test] fn it_creates_binary_markets() { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..2, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..2, + ScoringRule::CPMM, + ); // check the correct amount was reserved - let alice_reserved = Balances::reserved_balance(&ALICE); + let alice_reserved = Balances::reserved_balance(ALICE); assert_eq!(alice_reserved, ValidityBond::get() + OracleBond::get()); // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..2, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..2, + ScoringRule::CPMM, + ); - let new_alice_reserved = Balances::reserved_balance(&ALICE); + let new_alice_reserved = Balances::reserved_balance(ALICE); assert_eq!(new_alice_reserved, AdvisoryBond::get() + OracleBond::get() + alice_reserved); // Make sure that the market id has been incrementing @@ -821,7 +1247,12 @@ fn it_creates_binary_markets() { fn create_categorical_market_deposits_the_correct_event() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - simple_create_categorical_market(MarketCreation::Permissionless, 1..2, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 1..2, + ScoringRule::CPMM, + ); let market_id = 0; let market = MarketCommons::market(&market_id).unwrap(); let market_account = MarketCommons::market_account(market_id); @@ -833,7 +1264,12 @@ fn create_categorical_market_deposits_the_correct_event() { fn create_scalar_market_deposits_the_correct_event() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - simple_create_scalar_market(MarketCreation::Permissionless, 1..2, ScoringRule::CPMM); + simple_create_scalar_market( + Asset::Ztg, + MarketCreation::Permissionless, + 1..2, + ScoringRule::CPMM, + ); let market_id = 0; let market = MarketCommons::market(&market_id).unwrap(); let market_account = MarketCommons::market_account(market_id); @@ -846,7 +1282,8 @@ fn it_does_not_create_market_with_too_few_categories() { ExtBuilder::default().build().execute_with(|| { assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -866,7 +1303,8 @@ fn it_does_not_create_market_with_too_many_categories() { ExtBuilder::default().build().execute_with(|| { assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -885,10 +1323,15 @@ fn it_does_not_create_market_with_too_many_categories() { fn it_allows_sudo_to_destroy_markets() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // destroy the market - assert_ok!(PredictionMarkets::admin_destroy_market(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::admin_destroy_market(RuntimeOrigin::signed(SUDO), 0)); assert_noop!( MarketCommons::market(&0), @@ -901,7 +1344,12 @@ fn it_allows_sudo_to_destroy_markets() { fn it_allows_advisory_origin_to_approve_markets() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -909,12 +1357,12 @@ fn it_allows_advisory_origin_to_approve_markets() { // Make sure it fails from the random joe assert_noop!( - PredictionMarkets::approve_market(Origin::signed(BOB), 0), + PredictionMarkets::approve_market(RuntimeOrigin::signed(BOB), 0), DispatchError::BadOrigin ); // Now it should work from SUDO - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); let after_market = MarketCommons::market(&0); assert_eq!(after_market.unwrap().status, MarketStatus::Active); @@ -926,7 +1374,12 @@ fn it_allows_request_edit_origin_to_request_edits_for_markets() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 2..4, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 2..4, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -935,12 +1388,16 @@ fn it_allows_request_edit_origin_to_request_edits_for_markets() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; // Make sure it fails from the random joe assert_noop!( - PredictionMarkets::request_edit(Origin::signed(BOB), 0, edit_reason.clone()), + PredictionMarkets::request_edit(RuntimeOrigin::signed(BOB), 0, edit_reason.clone()), DispatchError::BadOrigin ); // Now it should work from SUDO - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason.clone())); + assert_ok!(PredictionMarkets::request_edit( + RuntimeOrigin::signed(SUDO), + 0, + edit_reason.clone() + )); System::assert_last_event( Event::MarketRequestedEdit( 0, @@ -958,7 +1415,12 @@ fn request_edit_fails_on_bad_origin() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 2..4, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 2..4, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -967,7 +1429,7 @@ fn request_edit_fails_on_bad_origin() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; // Make sure it fails from the random joe assert_noop!( - PredictionMarkets::request_edit(Origin::signed(BOB), 0, edit_reason), + PredictionMarkets::request_edit(RuntimeOrigin::signed(BOB), 0, edit_reason), DispatchError::BadOrigin ); }); @@ -977,7 +1439,12 @@ fn request_edit_fails_on_bad_origin() { fn edit_request_fails_if_edit_reason_is_too_long() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -986,7 +1453,7 @@ fn edit_request_fails_if_edit_reason_is_too_long() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize + 1]; assert_noop!( - PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason), + PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason), Error::::EditReasonLengthExceedsMaxEditReasonLen ); }); @@ -996,7 +1463,12 @@ fn edit_request_fails_if_edit_reason_is_too_long() { fn market_with_edit_request_cannot_be_approved() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -1004,11 +1476,11 @@ fn market_with_edit_request_cannot_be_approved() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason)); + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); assert!(MarketIdsForEdit::::contains_key(0)); assert_noop!( - PredictionMarkets::approve_market(Origin::signed(SUDO), 0), + PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0), Error::::MarketEditRequestAlreadyInProgress ); }); @@ -1019,7 +1491,12 @@ fn it_allows_the_advisory_origin_to_reject_markets() { ExtBuilder::default().build().execute_with(|| { run_to_block(2); // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 4..6, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 4..6, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -1029,7 +1506,7 @@ fn it_allows_the_advisory_origin_to_reject_markets() { vec![0; ::MaxRejectReasonLen::get() as usize]; // Now it should work from SUDO assert_ok!(PredictionMarkets::reject_market( - Origin::signed(SUDO), + RuntimeOrigin::signed(SUDO), 0, reject_reason.clone() )); @@ -1047,7 +1524,12 @@ fn it_allows_the_advisory_origin_to_reject_markets() { fn reject_errors_if_reject_reason_is_too_long() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -1056,7 +1538,7 @@ fn reject_errors_if_reject_reason_is_too_long() { let reject_reason: Vec = vec![0; ::MaxRejectReasonLen::get() as usize + 1]; assert_noop!( - PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason), + PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason), Error::::RejectReasonLengthExceedsMaxRejectReasonLen ); }); @@ -1066,7 +1548,12 @@ fn reject_errors_if_reject_reason_is_too_long() { fn it_allows_the_advisory_origin_to_reject_markets_with_edit_request() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -1075,9 +1562,9 @@ fn it_allows_the_advisory_origin_to_reject_markets_with_edit_request() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; let reject_reason = vec![0_u8; ::MaxRejectReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason)); + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); assert!(MarketIdsForEdit::::contains_key(0)); - assert_ok!(PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason)); + assert_ok!(PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason)); assert!(!MarketIdsForEdit::::contains_key(0)); assert_noop!( @@ -1089,8 +1576,14 @@ fn it_allows_the_advisory_origin_to_reject_markets_with_edit_request() { #[test] fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // Give ALICE `SENTINEL_AMOUNT` free and reserved ZTG; we record the free balance to check // that the AdvisoryBond gets slashed but the OracleBond gets unreserved. @@ -1102,13 +1595,13 @@ fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { )); assert!(Balances::free_balance(Treasury::account_id()).is_zero()); - let balance_free_before_alice = Balances::free_balance(&ALICE); + let balance_free_before_alice = Balances::free_balance(ALICE); let balance_reserved_before_alice = Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE); let reject_reason: Vec = vec![0; ::MaxRejectReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason)); + assert_ok!(PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason)); // AdvisoryBond gets slashed after reject_market // OracleBond gets unreserved after reject_market @@ -1120,7 +1613,7 @@ fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { - ::OracleBond::get() - ::AdvisoryBond::get(), ); - let balance_free_after_alice = Balances::free_balance(&ALICE); + let balance_free_after_alice = Balances::free_balance(ALICE); let slash_amount_advisory_bond = ::AdvisoryBondSlashPercentage::get() .mul_floor(::AdvisoryBond::get()); let advisory_bond_remains = @@ -1135,6 +1628,13 @@ fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { // AdvisoryBond is transferred to the treasury let balance_treasury_after = Balances::free_balance(Treasury::account_id()); assert_eq!(balance_treasury_after, slash_amount_advisory_bond); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -1143,12 +1643,27 @@ fn reject_market_clears_auto_close_blocks() { // We don't have to check that reject market clears the cache for opening pools, since Cpmm pools // can not be deployed on pending advised pools. ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Advised, 33..66, ScoringRule::CPMM); - simple_create_categorical_market(MarketCreation::Advised, 22..66, ScoringRule::CPMM); - simple_create_categorical_market(MarketCreation::Advised, 22..33, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 33..66, + ScoringRule::CPMM, + ); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 22..66, + ScoringRule::CPMM, + ); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 22..33, + ScoringRule::CPMM, + ); let reject_reason: Vec = vec![0; ::MaxRejectReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason)); + assert_ok!(PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason)); let auto_close = MarketIdsPerCloseBlock::::get(66); assert_eq!(auto_close.len(), 1); @@ -1158,7 +1673,8 @@ fn reject_market_clears_auto_close_blocks() { #[test] fn on_market_close_auto_rejects_expired_advised_market() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { // Give ALICE `SENTINEL_AMOUNT` free and reserved ZTG; we record the free balance to check // that the AdvisoryBond and the OracleBond gets unreserved, when the advised market expires. assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); @@ -1167,12 +1683,17 @@ fn on_market_close_auto_rejects_expired_advised_market() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); + let balance_free_before_alice = Balances::free_balance(ALICE); let balance_reserved_before_alice = Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE); let end = 33; - simple_create_categorical_market(MarketCreation::Advised, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..end, + ScoringRule::CPMM, + ); let market_id = 0; run_to_block(end); @@ -1181,18 +1702,25 @@ fn on_market_close_auto_rejects_expired_advised_market() { Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), balance_reserved_before_alice ); - assert_eq!(Balances::free_balance(&ALICE), balance_free_before_alice); + assert_eq!(Balances::free_balance(ALICE), balance_free_before_alice); assert_noop!( MarketCommons::market(&market_id), zrml_market_commons::Error::::MarketDoesNotExist, ); System::assert_has_event(Event::MarketExpired(market_id).into()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { // Give ALICE `SENTINEL_AMOUNT` free and reserved ZTG; we record the free balance to check // that the AdvisoryBond and the OracleBond gets unreserved, when the advised market expires. assert_ok!(AssetManager::deposit(Asset::Ztg, &ALICE, 2 * SENTINEL_AMOUNT)); @@ -1201,12 +1729,17 @@ fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { &ALICE, SENTINEL_AMOUNT )); - let balance_free_before_alice = Balances::free_balance(&ALICE); + let balance_free_before_alice = Balances::free_balance(ALICE); let balance_reserved_before_alice = Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE); let end = 33; - simple_create_categorical_market(MarketCreation::Advised, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Advised, + 0..end, + ScoringRule::CPMM, + ); run_to_block(2); let market_id = 0; let market = MarketCommons::market(&market_id); @@ -1214,7 +1747,11 @@ fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), market_id, edit_reason)); + assert_ok!(PredictionMarkets::request_edit( + RuntimeOrigin::signed(SUDO), + market_id, + edit_reason + )); assert!(MarketIdsForEdit::::contains_key(0)); run_blocks(end); @@ -1224,12 +1761,19 @@ fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { Balances::reserved_balance_named(&PredictionMarkets::reserve_id(), &ALICE), balance_reserved_before_alice ); - assert_eq!(Balances::free_balance(&ALICE), balance_free_before_alice); + assert_eq!(Balances::free_balance(ALICE), balance_free_before_alice); assert_noop!( MarketCommons::market(&market_id), zrml_market_commons::Error::::MarketDoesNotExist, ); System::assert_has_event(Event::MarketExpired(market_id).into()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -1240,7 +1784,8 @@ fn on_market_open_successfully_auto_opens_market_pool_with_blocks() { let end = 66; let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(start..end), get_deadlines(), @@ -1248,7 +1793,7 @@ fn on_market_open_successfully_auto_opens_market_pool_with_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); let market_id = 0; @@ -1270,7 +1815,8 @@ fn on_market_close_successfully_auto_closes_market_with_blocks() { let end = 33; let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(0..end), get_deadlines(), @@ -1278,7 +1824,7 @@ fn on_market_close_successfully_auto_closes_market_with_blocks() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); let market_id = 0; @@ -1307,7 +1853,8 @@ fn on_market_open_successfully_auto_opens_market_with_timestamps() { let end: Moment = (66 * MILLISECS_PER_BLOCK).into(); let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(start..end), get_deadlines(), @@ -1315,7 +1862,7 @@ fn on_market_open_successfully_auto_opens_market_with_timestamps() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); let market_id = 0; @@ -1340,7 +1887,8 @@ fn on_market_close_successfully_auto_closes_market_with_timestamps() { let end: Moment = (2 * MILLISECS_PER_BLOCK).into(); let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(0..end), get_deadlines(), @@ -1348,7 +1896,7 @@ fn on_market_close_successfully_auto_closes_market_with_timestamps() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); let market_id = 0; @@ -1385,7 +1933,8 @@ fn on_market_open_successfully_auto_opens_multiple_markets_after_stall() { let end: Moment = (666 * MILLISECS_PER_BLOCK).into(); let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(start..end), get_deadlines(), @@ -1393,11 +1942,12 @@ fn on_market_open_successfully_auto_opens_multiple_markets_after_stall() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(start..end), get_deadlines(), @@ -1405,7 +1955,7 @@ fn on_market_open_successfully_auto_opens_multiple_markets_after_stall() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); @@ -1428,7 +1978,8 @@ fn on_market_close_successfully_auto_closes_multiple_markets_after_stall() { let end: Moment = (5 * MILLISECS_PER_BLOCK).into(); let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(0..end), get_deadlines(), @@ -1436,11 +1987,12 @@ fn on_market_close_successfully_auto_closes_multiple_markets_after_stall() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(0..end), get_deadlines(), @@ -1448,7 +2000,7 @@ fn on_market_close_successfully_auto_closes_multiple_markets_after_stall() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 0, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); @@ -1478,7 +2030,8 @@ fn on_initialize_skips_the_genesis_block() { ExtBuilder::default().build().execute_with(|| { let category_count = 3; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Timestamp(0..end), get_deadlines(), @@ -1486,7 +2039,7 @@ fn on_initialize_skips_the_genesis_block() { MarketType::Categorical(category_count), MarketDisputeMechanism::SimpleDisputes, 123, - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); category_count.into()], )); @@ -1509,13 +2062,18 @@ fn on_initialize_skips_the_genesis_block() { #[test] fn it_allows_to_buy_a_complete_set() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { frame_system::Pallet::::set_block_number(1); // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Permissionless, 0..2, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..2, + ScoringRule::CPMM, + ); // Allows someone to generate a complete set - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); @@ -1526,14 +2084,20 @@ fn it_allows_to_buy_a_complete_set() { assert_eq!(bal, CENT); } - // also check native balance - let bal = Balances::free_balance(&BOB); + let market_account = MarketCommons::market_account(0); + let bal = AssetManager::free_balance(base_asset, &BOB); assert_eq!(bal, 1_000 * BASE - CENT); - let market_account = MarketCommons::market_account(0); - let market_bal = Balances::free_balance(market_account); + let market_bal = AssetManager::free_balance(base_asset, &market_account); assert_eq!(market_bal, CENT); System::assert_last_event(Event::BoughtCompleteSet(0, CENT, BOB).into()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -1541,9 +2105,14 @@ fn it_allows_to_buy_a_complete_set() { fn it_does_not_allow_to_buy_a_complete_set_on_pending_advised_market() { ExtBuilder::default().build().execute_with(|| { // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); assert_noop!( - PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT), + PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT), Error::::MarketIsNotActive, ); }); @@ -1554,7 +2123,8 @@ fn create_categorical_market_fails_if_market_begin_is_equal_to_end() { ExtBuilder::default().build().execute_with(|| { assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(3..3), get_deadlines(), @@ -1564,23 +2134,15 @@ fn create_categorical_market_fails_if_market_begin_is_equal_to_end() { MarketDisputeMechanism::Authorized, ScoringRule::CPMM, ), - crate::Error::::InvalidMarketPeriod, + Error::::InvalidMarketPeriod, ); }); } #[test_case(MarketPeriod::Block(2..1); "block start greater than end")] #[test_case(MarketPeriod::Block(3..3); "block start equal to end")] -#[test_case( - MarketPeriod::Block(0..::MaxMarketPeriod::get() + 1); - "block end greater than max market period" -)] #[test_case(MarketPeriod::Timestamp(2..1); "timestamp start greater than end")] #[test_case(MarketPeriod::Timestamp(3..3); "timestamp start equal to end")] -#[test_case( - MarketPeriod::Timestamp(0..::MaxMarketPeriod::get() + 1); - "timestamp end greater than max market period" -)] #[test_case( MarketPeriod::Timestamp(0..(MILLISECS_PER_BLOCK - 1).into()); "range shorter than block time" @@ -1591,7 +2153,8 @@ fn create_categorical_market_fails_if_market_period_is_invalid( ExtBuilder::default().build().execute_with(|| { assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, period, get_deadlines(), @@ -1601,7 +2164,7 @@ fn create_categorical_market_fails_if_market_period_is_invalid( MarketDisputeMechanism::Authorized, ScoringRule::CPMM, ), - crate::Error::::InvalidMarketPeriod, + Error::::InvalidMarketPeriod, ); }); } @@ -1613,7 +2176,8 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { run_to_block(end_block); assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..end_block), get_deadlines(), @@ -1623,13 +2187,14 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { MarketDisputeMechanism::Authorized, ScoringRule::CPMM, ), - crate::Error::::InvalidMarketPeriod, + Error::::InvalidMarketPeriod, ); let end_time = MILLISECS_PER_BLOCK as u64 / 2; assert_noop!( PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..end_time), get_deadlines(), @@ -1639,7 +2204,7 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { MarketDisputeMechanism::Authorized, ScoringRule::CPMM, ), - crate::Error::::InvalidMarketPeriod, + Error::::InvalidMarketPeriod, ); }); } @@ -1647,9 +2212,14 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { #[test] fn it_does_not_allow_zero_amounts_in_buy_complete_set() { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); assert_noop!( - PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 0), + PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 0), Error::::ZeroAmount ); }); @@ -1657,57 +2227,85 @@ fn it_does_not_allow_zero_amounts_in_buy_complete_set() { #[test] fn it_does_not_allow_buying_complete_sets_with_insufficient_balance() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); assert_noop!( - PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 10000 * BASE), + PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 10000 * BASE), Error::::NotEnoughBalance ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } - #[test] fn it_allows_to_deploy_a_pool() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 100 * BASE)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 100 * BASE)); assert_ok!(Balances::transfer( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), ::PalletId::get().into_account_truncating(), 100 * BASE )); assert_ok!(PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, ::MaxSwapFee::get(), - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); 2], )); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn deploy_swap_pool_for_market_fails_if_market_has_a_pool() { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 200 * BASE)); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 200 * BASE)); assert_ok!(PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, ::MaxSwapFee::get(), - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); 2], )); assert_noop!( PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, ::MaxSwapFee::get(), - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); 2], ), zrml_market_commons::Error::::PoolAlreadyExists, @@ -1719,14 +2317,19 @@ fn deploy_swap_pool_for_market_fails_if_market_has_a_pool() { fn it_does_not_allow_to_deploy_a_pool_on_pending_advised_market() { ExtBuilder::default().build().execute_with(|| { // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); assert_noop!( PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, ::MaxSwapFee::get(), - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); 2], ), Error::::MarketIsNotActive, @@ -1736,14 +2339,19 @@ fn it_does_not_allow_to_deploy_a_pool_on_pending_advised_market() { #[test] fn it_allows_to_sell_a_complete_set() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { frame_system::Pallet::::set_block_number(1); // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Permissionless, 0..2, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..2, + ScoringRule::CPMM, + ); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT)); - assert_ok!(PredictionMarkets::sell_complete_set(Origin::signed(BOB), 0, CENT)); + assert_ok!(PredictionMarkets::sell_complete_set(RuntimeOrigin::signed(BOB), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); @@ -1755,19 +2363,31 @@ fn it_allows_to_sell_a_complete_set() { } // also check native balance - let bal = Balances::free_balance(&BOB); + let bal = Balances::free_balance(BOB); assert_eq!(bal, 1_000 * BASE); System::assert_last_event(Event::SoldCompleteSet(0, CENT, BOB).into()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn it_does_not_allow_zero_amounts_in_sell_complete_set() { ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); assert_noop!( - PredictionMarkets::sell_complete_set(Origin::signed(BOB), 0, 0), + PredictionMarkets::sell_complete_set(RuntimeOrigin::signed(BOB), 0, 0), Error::::ZeroAmount ); }); @@ -1775,14 +2395,26 @@ fn it_does_not_allow_zero_amounts_in_sell_complete_set() { #[test] fn it_does_not_allow_to_sell_complete_sets_with_insufficient_balance() { - ExtBuilder::default().build().execute_with(|| { - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 2 * CENT)); + let test = |base_asset: Asset| { + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 2 * CENT)); assert_eq!(AssetManager::slash(Asset::CategoricalOutcome(0, 1), &BOB, CENT), 0); assert_noop!( - PredictionMarkets::sell_complete_set(Origin::signed(BOB), 0, 2 * CENT), + PredictionMarkets::sell_complete_set(RuntimeOrigin::signed(BOB), 0, 2 * CENT), Error::::InsufficientShareBalance ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -1790,7 +2422,12 @@ fn it_does_not_allow_to_sell_complete_sets_with_insufficient_balance() { fn it_allows_to_report_the_outcome_of_a_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; @@ -1801,7 +2438,7 @@ fn it_allows_to_report_the_outcome_of_a_market() { assert!(market.report.is_none()); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -1820,7 +2457,7 @@ fn it_allows_to_report_the_outcome_of_a_market() { }); assert_ok!(PredictionMarkets::report( - Origin::signed(SUDO), + RuntimeOrigin::signed(SUDO), 0, OutcomeReport::Categorical(1) )); @@ -1831,7 +2468,12 @@ fn it_allows_to_report_the_outcome_of_a_market() { fn report_fails_before_grace_period_is_over() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); run_to_block(end); @@ -1840,7 +2482,7 @@ fn report_fails_before_grace_period_is_over() { assert!(market.report.is_none()); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::NotAllowedToReportYet ); }); @@ -1850,7 +2492,12 @@ fn report_fails_before_grace_period_is_over() { fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duration_blocks() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; @@ -1861,12 +2508,16 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio assert!(market.report.is_none()); assert_noop!( - PredictionMarkets::report(Origin::signed(CHARLIE), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(1) + ), Error::::ReporterNotOracle ); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -1883,7 +2534,8 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duration_moment() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -1894,7 +2546,7 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio ScoringRule::CPMM )); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT)); // set the timestamp let market = MarketCommons::market(&0).unwrap(); @@ -1906,11 +2558,11 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio Timestamp::set_timestamp(100_000_000 + grace_period); assert_noop!( - PredictionMarkets::report(Origin::signed(EVE), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1)), Error::::ReporterNotOracle ); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -1921,12 +2573,17 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio fn report_fails_on_mismatched_outcome_for_categorical_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Scalar(123)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(123)), Error::::OutcomeMismatch, ); let market = MarketCommons::market(&0).unwrap(); @@ -1939,12 +2596,17 @@ fn report_fails_on_mismatched_outcome_for_categorical_market() { fn report_fails_on_out_of_range_outcome_for_categorical_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(2)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(2)), Error::::OutcomeMismatch, ); let market = MarketCommons::market(&0).unwrap(); @@ -1957,12 +2619,17 @@ fn report_fails_on_out_of_range_outcome_for_categorical_market() { fn report_fails_on_mismatched_outcome_for_scalar_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; - simple_create_scalar_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_scalar_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(0)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0)), Error::::OutcomeMismatch, ); let market = MarketCommons::market(&0).unwrap(); @@ -1975,7 +2642,12 @@ fn report_fails_on_mismatched_outcome_for_scalar_market() { fn it_allows_to_dispute_the_outcome_of_a_market() { ExtBuilder::default().build().execute_with(|| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); // Run to the end of the trading phase. let market = MarketCommons::market(&0).unwrap(); @@ -1983,7 +2655,7 @@ fn it_allows_to_dispute_the_outcome_of_a_market() { run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -1992,7 +2664,7 @@ fn it_allows_to_dispute_the_outcome_of_a_market() { run_to_block(dispute_at); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(0) )); @@ -2015,34 +2687,87 @@ fn it_allows_to_dispute_the_outcome_of_a_market() { } #[test] -fn it_allows_anyone_to_report_an_unreported_market() { +fn dispute_fails_authority_reported_already() { ExtBuilder::default().build().execute_with(|| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Block(0..end), + get_deadlines(), + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(::MinCategories::get()), + MarketDisputeMechanism::Authorized, + ScoringRule::CPMM, + )); + // Run to the end of the trading phase. let market = MarketCommons::market(&0).unwrap(); - // Just skip to waaaay overdue. - run_to_block(end + market.deadlines.grace_period + market.deadlines.oracle_duration + 1); + let grace_period = end + market.deadlines.grace_period; + run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(ALICE), // alice reports her own market now + RuntimeOrigin::signed(BOB), 0, - OutcomeReport::Categorical(1), + OutcomeReport::Categorical(1) )); - let market = MarketCommons::market(&0).unwrap(); - assert_eq!(market.status, MarketStatus::Reported); - assert_eq!(market.report.unwrap().by, ALICE); - // but oracle was bob - assert_eq!(market.oracle, BOB); + let dispute_at = grace_period + 2; + run_to_block(dispute_at); - // make sure it still resolves - run_to_block( - frame_system::Pallet::::block_number() + market.deadlines.dispute_duration, - ); + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(0) + )); - let market_after = MarketCommons::market(&0).unwrap(); - assert_eq!(market_after.status, MarketStatus::Resolved); + assert_noop!( + PredictionMarkets::dispute( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(1) + ), + AuthorizedError::::OnlyOneDisputeAllowed + ); + }); +} + +#[test] +fn it_allows_anyone_to_report_an_unreported_market() { + ExtBuilder::default().build().execute_with(|| { + let end = 2; + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); + + let market = MarketCommons::market(&0).unwrap(); + // Just skip to waaaay overdue. + run_to_block(end + market.deadlines.grace_period + market.deadlines.oracle_duration + 1); + + assert_ok!(PredictionMarkets::report( + RuntimeOrigin::signed(ALICE), // alice reports her own market now + 0, + OutcomeReport::Categorical(1), + )); + + let market = MarketCommons::market(&0).unwrap(); + assert_eq!(market.status, MarketStatus::Reported); + assert_eq!(market.report.unwrap().by, ALICE); + // but oracle was bob + assert_eq!(market.oracle, BOB); + + // make sure it still resolves + run_to_block( + frame_system::Pallet::::block_number() + market.deadlines.dispute_duration, + ); + + let market_after = MarketCommons::market(&0).unwrap(); + assert_eq!(market_after.status, MarketStatus::Resolved); }); } @@ -2050,16 +2775,21 @@ fn it_allows_anyone_to_report_an_unreported_market() { fn it_correctly_resolves_a_market_that_was_reported_on() { ExtBuilder::default().build().execute_with(|| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); let report_at = end + market.deadlines.grace_period + 1; run_to_block(report_at); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -2102,18 +2832,23 @@ fn it_correctly_resolves_a_market_that_was_reported_on() { #[test] fn it_resolves_a_disputed_market() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); let report_at = end + market.deadlines.grace_period + 1; run_to_block(report_at); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); @@ -2122,7 +2857,7 @@ fn it_resolves_a_disputed_market() { run_to_block(dispute_at_0); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(1) )); @@ -2131,7 +2866,7 @@ fn it_resolves_a_disputed_market() { run_to_block(dispute_at_1); assert_ok!(PredictionMarkets::dispute( - Origin::signed(DAVE), + RuntimeOrigin::signed(DAVE), 0, OutcomeReport::Categorical(0) )); @@ -2140,7 +2875,7 @@ fn it_resolves_a_disputed_market() { run_to_block(dispute_at_2); assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1) )); @@ -2149,13 +2884,13 @@ fn it_resolves_a_disputed_market() { assert_eq!(market.status, MarketStatus::Disputed); // check everyone's deposits - let charlie_reserved = Balances::reserved_balance(&CHARLIE); + let charlie_reserved = Balances::reserved_balance(CHARLIE); assert_eq!(charlie_reserved, DisputeBond::get()); - let dave_reserved = Balances::reserved_balance(&DAVE); + let dave_reserved = Balances::reserved_balance(DAVE); assert_eq!(dave_reserved, DisputeBond::get() + DisputeFactor::get()); - let eve_reserved = Balances::reserved_balance(&EVE); + let eve_reserved = Balances::reserved_balance(EVE); assert_eq!(eve_reserved, DisputeBond::get() + 2 * DisputeFactor::get()); // check disputes length @@ -2185,7 +2920,7 @@ fn it_resolves_a_disputed_market() { let disputes = crate::Disputes::::get(0); assert_eq!(disputes.len(), 0); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); // Make sure rewards are right: // @@ -2198,26 +2933,33 @@ fn it_resolves_a_disputed_market() { let dave_reserved = DisputeBond::get() + DisputeFactor::get(); let total_slashed = OracleBond::get() + dave_reserved; - let charlie_balance = Balances::free_balance(&CHARLIE); + let charlie_balance = Balances::free_balance(CHARLIE); assert_eq!(charlie_balance, 1_000 * BASE + total_slashed / 2); - let charlie_reserved_2 = Balances::reserved_balance(&CHARLIE); + let charlie_reserved_2 = Balances::reserved_balance(CHARLIE); assert_eq!(charlie_reserved_2, 0); - let eve_balance = Balances::free_balance(&EVE); + let eve_balance = Balances::free_balance(EVE); assert_eq!(eve_balance, 1_000 * BASE + total_slashed / 2); - let dave_balance = Balances::free_balance(&DAVE); + let dave_balance = Balances::free_balance(DAVE); assert_eq!(dave_balance, 1_000 * BASE - dave_reserved); - let alice_balance = Balances::free_balance(&ALICE); + let alice_balance = Balances::free_balance(ALICE); assert_eq!(alice_balance, 1_000 * BASE - OracleBond::get()); // bob kinda gets away scot-free since Alice is held responsible // for her designated reporter - let bob_balance = Balances::free_balance(&BOB); + let bob_balance = Balances::free_balance(BOB); assert_eq!(bob_balance, 1_000 * BASE); assert!(market_after.bonds.creation.unwrap().is_settled); assert!(market_after.bonds.oracle.unwrap().is_settled); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -2230,7 +2972,12 @@ fn it_resolves_a_disputed_market() { fn dispute_fails_unless_reported_or_disputed_market(status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { // Creates a permissionless market. - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); assert_ok!(MarketCommons::mutate_market(&0, |market_inner| { market_inner.status = status; @@ -2238,99 +2985,23 @@ fn dispute_fails_unless_reported_or_disputed_market(status: MarketStatus) { })); assert_noop!( - PredictionMarkets::dispute(Origin::signed(EVE), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::dispute( + RuntimeOrigin::signed(EVE), + 0, + OutcomeReport::Categorical(1) + ), Error::::InvalidMarketStatus ); }); } -#[test] -fn it_resolves_a_disputed_market_to_default_if_dispute_mechanism_failed() { - ExtBuilder::default().build().execute_with(|| { - let end = 2; - assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), - BOB, - MarketPeriod::Block(0..2), - get_deadlines(), - gen_metadata(2), - MarketCreation::Permissionless, - MarketType::Categorical(::MinCategories::get()), - MarketDisputeMechanism::Authorized, - ScoringRule::CPMM, - )); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, CENT)); - - let market = MarketCommons::market(&0).unwrap(); - let grace_period = market.deadlines.grace_period; - run_to_block(end + grace_period + 1); - assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), - 0, - OutcomeReport::Categorical(0) - )); - let dispute_at_0 = end + grace_period + 2; - run_to_block(dispute_at_0); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), - 0, - OutcomeReport::Categorical(1) - )); - let dispute_at_1 = dispute_at_0 + 1; - run_to_block(dispute_at_1); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(DAVE), - 0, - OutcomeReport::Categorical(0) - )); - let dispute_at_2 = dispute_at_1 + 1; - run_to_block(dispute_at_2); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), - 0, - OutcomeReport::Categorical(1) - )); - - let charlie_reserved = Balances::reserved_balance(&CHARLIE); - let eve_reserved = Balances::reserved_balance(&EVE); - let disputes = crate::Disputes::::get(0); - assert_eq!(disputes.len(), 3); - - run_blocks(market.deadlines.dispute_duration); - let market_after = MarketCommons::market(&0).unwrap(); - assert_eq!(market_after.status, MarketStatus::Resolved); - let disputes = crate::Disputes::::get(0); - assert_eq!(disputes.len(), 0); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); - - // make sure rewards are right - // - // slashed amounts - // --------------------------- - // - Charlie's reserve: DisputeBond::get() - // - Eve's reserve: DisputeBond::get() + 2 * DisputeFactor::get() - // - // All goes to Dave (because Bob is - strictly speaking - not a disputor). - assert_eq!(Balances::free_balance(&CHARLIE), 1_000 * BASE - charlie_reserved); - assert_eq!(Balances::free_balance(&EVE), 1_000 * BASE - eve_reserved); - let total_slashed = charlie_reserved + eve_reserved; - assert_eq!(Balances::free_balance(&DAVE), 1_000 * BASE + total_slashed); - - // The oracle report was accepted, so Alice is not slashed. - assert_eq!(Balances::free_balance(&ALICE), 1_000 * BASE); - assert_eq!(Balances::free_balance(&BOB), 1_000 * BASE); - - assert!(market_after.bonds.creation.unwrap().is_settled); - assert!(market_after.bonds.oracle.unwrap().is_settled); - }); -} - #[test] fn start_global_dispute_works() { ExtBuilder::default().build().execute_with(|| { let end = 2; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..2), get_deadlines(), @@ -2346,7 +3017,7 @@ fn start_global_dispute_works() { let grace_period = market.deadlines.grace_period; run_to_block(end + grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Categorical(0) )); @@ -2356,18 +3027,24 @@ fn start_global_dispute_works() { if i == 1 { #[cfg(feature = "with-global-disputes")] assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), market_id), + PredictionMarkets::start_global_dispute( + RuntimeOrigin::signed(CHARLIE), + market_id + ), Error::::InvalidMarketStatus ); } else { #[cfg(feature = "with-global-disputes")] assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), market_id), + PredictionMarkets::start_global_dispute( + RuntimeOrigin::signed(CHARLIE), + market_id + ), Error::::MaxDisputesNeeded ); } assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), market_id, OutcomeReport::Categorical(i.saturated_into()) )); @@ -2389,7 +3066,10 @@ fn start_global_dispute_works() { use zrml_global_disputes::GlobalDisputesPalletApi; let now = >::block_number(); - assert_ok!(PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), market_id)); + assert_ok!(PredictionMarkets::start_global_dispute( + RuntimeOrigin::signed(CHARLIE), + market_id + )); // report check assert_eq!( @@ -2419,7 +3099,7 @@ fn start_global_dispute_works() { System::assert_last_event(Event::GlobalDisputeStarted(market_id).into()); assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), market_id), + PredictionMarkets::start_global_dispute(RuntimeOrigin::signed(CHARLIE), market_id), Error::::GlobalDisputeAlreadyStarted ); } @@ -2431,7 +3111,8 @@ fn start_global_dispute_fails_on_wrong_mdm() { ExtBuilder::default().build().execute_with(|| { let end = 2; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..2), get_deadlines(), @@ -2447,27 +3128,26 @@ fn start_global_dispute_fails_on_wrong_mdm() { let grace_period = market.deadlines.grace_period; run_to_block(end + grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), market_id, OutcomeReport::Categorical(0) )); let dispute_at_0 = end + grace_period + 2; run_to_block(dispute_at_0); - for i in 1..=::MaxDisputes::get() { - assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), - market_id, - OutcomeReport::Categorical(i.saturated_into()) - )); - run_blocks(1); - let market = MarketCommons::market(&market_id).unwrap(); - assert_eq!(market.status, MarketStatus::Disputed); - } + // only one dispute allowed for authorized mdm + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(CHARLIE), + market_id, + OutcomeReport::Categorical(1u32.saturated_into()) + )); + run_blocks(1); + let market = MarketCommons::market(&market_id).unwrap(); + assert_eq!(market.status, MarketStatus::Disputed); #[cfg(feature = "with-global-disputes")] assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), market_id), + PredictionMarkets::start_global_dispute(RuntimeOrigin::signed(CHARLIE), market_id), Error::::InvalidDisputeMechanism ); }); @@ -2480,13 +3160,13 @@ fn start_global_dispute_works_without_feature() { #[cfg(not(feature = "with-global-disputes"))] assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), non_market_id), + PredictionMarkets::start_global_dispute(RuntimeOrigin::signed(CHARLIE), non_market_id), Error::::GlobalDisputesDisabled ); #[cfg(feature = "with-global-disputes")] assert_noop!( - PredictionMarkets::start_global_dispute(Origin::signed(CHARLIE), non_market_id), + PredictionMarkets::start_global_dispute(RuntimeOrigin::signed(CHARLIE), non_market_id), zrml_market_commons::Error::::MarketDoesNotExist ); }); @@ -2494,17 +3174,22 @@ fn start_global_dispute_works_without_feature() { #[test] fn it_allows_to_redeem_shares() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { let end = 2; - simple_create_categorical_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); + simple_create_categorical_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -2512,34 +3197,40 @@ fn it_allows_to_redeem_shares() { let market = MarketCommons::market(&0).unwrap(); assert_eq!(market.status, MarketStatus::Resolved); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); - let bal = Balances::free_balance(&CHARLIE); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); + let bal = Balances::free_balance(CHARLIE); assert_eq!(bal, 1_000 * BASE); System::assert_last_event( Event::TokensRedeemed(0, Asset::CategoricalOutcome(0, 1), CENT, CENT, CHARLIE).into(), ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn create_market_and_deploy_assets_results_in_expected_balances_and_pool_params() { - let oracle = ALICE; - let period = MarketPeriod::Block(0..42); - let metadata = gen_metadata(42); - let category_count = 4; - let market_type = MarketType::Categorical(category_count); - let swap_fee = ::MaxSwapFee::get(); - let amount = 123 * BASE; - let pool_id = 0; - let weight = ::MinWeight::get(); - let weights = vec![weight; category_count.into()]; - let base_asset_weight = (category_count as u128) * weight; - let total_weight = 2 * base_asset_weight; - - // Execute the combined convenience function - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { + let oracle = ALICE; + let period = MarketPeriod::Block(0..42); + let metadata = gen_metadata(42); + let category_count = 4; + let market_type = MarketType::Categorical(category_count); + let swap_fee = ::MaxSwapFee::get(); + let amount = 123 * BASE; + let pool_id = 0; + let weight = ::MinWeight::get(); + let weights = vec![weight; category_count.into()]; + let base_asset_weight = (category_count as u128) * weight; + let total_weight = 2 * base_asset_weight; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, oracle, period, get_deadlines(), @@ -2562,7 +3253,7 @@ fn create_market_and_deploy_assets_results_in_expected_balances_and_pool_params( assert_eq!(Tokens::free_balance(Asset::CategoricalOutcome(0, 1), &pool_account), amount); assert_eq!(Tokens::free_balance(Asset::CategoricalOutcome(0, 2), &pool_account), amount); assert_eq!(Tokens::free_balance(Asset::CategoricalOutcome(0, 3), &pool_account), amount); - assert_eq!(System::account(&pool_account).data.free, amount); + assert_eq!(AssetManager::free_balance(base_asset, &pool_account), amount); let pool = Pools::::get(0).unwrap(); let assets_expected = vec![ @@ -2570,10 +3261,10 @@ fn create_market_and_deploy_assets_results_in_expected_balances_and_pool_params( Asset::CategoricalOutcome(market_id, 1), Asset::CategoricalOutcome(market_id, 2), Asset::CategoricalOutcome(market_id, 3), - Asset::Ztg, + base_asset, ]; assert_eq!(pool.assets, assets_expected); - assert_eq!(pool.base_asset, Asset::Ztg); + assert_eq!(pool.base_asset, base_asset); assert_eq!(pool.market_id, market_id); assert_eq!(pool.scoring_rule, ScoringRule::CPMM); assert_eq!(pool.swap_fee, Some(swap_fee)); @@ -2585,68 +3276,93 @@ fn create_market_and_deploy_assets_results_in_expected_balances_and_pool_params( assert_eq!(pool_weights[&Asset::CategoricalOutcome(market_id, 1)], weight); assert_eq!(pool_weights[&Asset::CategoricalOutcome(market_id, 2)], weight); assert_eq!(pool_weights[&Asset::CategoricalOutcome(market_id, 3)], weight); - assert_eq!(pool_weights[&Asset::Ztg], base_asset_weight); + assert_eq!(pool_weights[&base_asset], base_asset_weight); + }; + + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn process_subsidy_activates_market_with_sufficient_subsidy() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { let min_sub_period = ::MinSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); let max_sub_period = ::MaxSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); simple_create_categorical_market( + base_asset, MarketCreation::Permissionless, min_sub_period..max_sub_period, ScoringRule::RikiddoSigmoidFeeMarketEma, ); let min_subsidy = ::MinSubsidy::get(); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(ALICE), 0, min_subsidy)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(ALICE), 0, min_subsidy)); run_to_block(min_sub_period); let subsidy_queue = crate::MarketsCollectingSubsidy::::get(); assert_eq!(subsidy_queue.len(), 0); assert_eq!(MarketCommons::market(&0).unwrap().status, MarketStatus::Active); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn process_subsidy_blocks_market_with_insufficient_subsidy() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { let min_sub_period = ::MinSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); let max_sub_period = ::MaxSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); simple_create_categorical_market( + base_asset, MarketCreation::Permissionless, min_sub_period..max_sub_period, ScoringRule::RikiddoSigmoidFeeMarketEma, ); let subsidy = ::MinSubsidy::get() / 3; - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(ALICE), 0, subsidy)); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(BOB), 0, subsidy)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(ALICE), 0, subsidy)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(BOB), 0, subsidy)); run_to_block(min_sub_period); let subsidy_queue = crate::MarketsCollectingSubsidy::::get(); assert_eq!(subsidy_queue.len(), 0); assert_eq!(MarketCommons::market(&0).unwrap().status, MarketStatus::InsufficientSubsidy); // Check that the balances are correctly unreserved. - assert_eq!(Balances::reserved_balance(&ALICE), 0); - assert_eq!(Balances::reserved_balance(&BOB), 0); + assert_eq!(AssetManager::reserved_balance(base_asset, &ALICE), 0); + assert_eq!(AssetManager::reserved_balance(base_asset, &BOB), 0); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn process_subsidy_keeps_market_in_subsidy_queue_until_end_of_subsidy_phase() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { let min_sub_period = ::MinSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); let max_sub_period = ::MaxSubsidyPeriod::get() / (MILLISECS_PER_BLOCK as u64); simple_create_categorical_market( + base_asset, MarketCreation::Permissionless, min_sub_period + 42..max_sub_period, ScoringRule::RikiddoSigmoidFeeMarketEma, @@ -2658,14 +3374,22 @@ fn process_subsidy_keeps_market_in_subsidy_queue_until_end_of_subsidy_phase() { assert!(subsidy_queue.len() == 1); assert!(subsidy_queue[0].market_id == 0); assert!(MarketCommons::market(&0).unwrap().status == MarketStatus::CollectingSubsidy); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn start_subsidy_creates_pool_and_starts_subsidy() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { // Create advised categorical market using Rikiddo. simple_create_categorical_market( + base_asset, MarketCreation::Advised, 1337..1338, ScoringRule::RikiddoSigmoidFeeMarketEma, @@ -2676,7 +3400,7 @@ fn start_subsidy_creates_pool_and_starts_subsidy() { // Ensure and set correct market status. assert_err!( PredictionMarkets::start_subsidy(&market, market_id), - crate::Error::::MarketIsNotCollectingSubsidy + Error::::MarketIsNotCollectingSubsidy ); assert_ok!(MarketCommons::mutate_market(&market_id, |market_inner| { market_inner.status = MarketStatus::CollectingSubsidy; @@ -2696,6 +3420,13 @@ fn start_subsidy_creates_pool_and_starts_subsidy() { } assert!(inserted); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -2703,7 +3434,12 @@ fn start_subsidy_creates_pool_and_starts_subsidy() { fn only_creator_can_edit_market() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -2712,14 +3448,15 @@ fn only_creator_can_edit_market() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; // Now it should work from SUDO - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason)); + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); assert!(MarketIdsForEdit::::contains_key(0)); // ALICE is market creator through simple_create_categorical_market assert_noop!( PredictionMarkets::edit_market( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), + Asset::Ztg, 0, CHARLIE, MarketPeriod::Block(0..1), @@ -2739,7 +3476,12 @@ fn edit_cycle_for_proposed_markets() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. run_to_block(1); - simple_create_categorical_market(MarketCreation::Advised, 2..4, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 2..4, + ScoringRule::CPMM, + ); // make sure it's in status proposed let market = MarketCommons::market(&0); @@ -2748,14 +3490,15 @@ fn edit_cycle_for_proposed_markets() { let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; // Now it should work from SUDO - assert_ok!(PredictionMarkets::request_edit(Origin::signed(SUDO), 0, edit_reason)); + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); assert!(MarketIdsForEdit::::contains_key(0)); // BOB was the oracle before through simple_create_categorical_market // After this edit its changed to ALICE assert_ok!(PredictionMarkets::edit_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, 0, CHARLIE, MarketPeriod::Block(2..4), @@ -2774,12 +3517,87 @@ fn edit_cycle_for_proposed_markets() { }); } +#[cfg(feature = "parachain")] +#[test] +fn edit_market_with_foreign_asset() { + ExtBuilder::default().build().execute_with(|| { + // Creates an advised market. + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); + + // make sure it's in status proposed + let market = MarketCommons::market(&0); + assert_eq!(market.unwrap().status, MarketStatus::Proposed); + + let edit_reason = vec![0_u8; ::MaxEditReasonLen::get() as usize]; + + // Now it should work from SUDO + assert_ok!(PredictionMarkets::request_edit(RuntimeOrigin::signed(SUDO), 0, edit_reason)); + + assert!(MarketIdsForEdit::::contains_key(0)); + + // ALICE is market creator through simple_create_categorical_market + // As per Mock asset_registry genesis ForeignAsset(50) is not registered in asset_registry. + assert_noop!( + PredictionMarkets::edit_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(50), + 0, + CHARLIE, + MarketPeriod::Block(0..1), + get_deadlines(), + gen_metadata(2), + MarketType::Categorical(::MinCategories::get()), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM + ), + Error::::UnregisteredForeignAsset + ); + // As per Mock asset_registry genesis ForeignAsset(420) has allow_as_base_asset set to false. + assert_noop!( + PredictionMarkets::edit_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(420), + 0, + CHARLIE, + MarketPeriod::Block(0..1), + get_deadlines(), + gen_metadata(2), + MarketType::Categorical(::MinCategories::get()), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM + ), + Error::::InvalidBaseAsset, + ); + // As per Mock asset_registry genesis ForeignAsset(100) has allow_as_base_asset set to true. + assert_ok!(PredictionMarkets::edit_market( + RuntimeOrigin::signed(ALICE), + Asset::ForeignAsset(100), + 0, + CHARLIE, + MarketPeriod::Block(0..1), + get_deadlines(), + gen_metadata(2), + MarketType::Categorical(::MinCategories::get()), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM + )); + let market = MarketCommons::market(&0).unwrap(); + assert_eq!(market.base_asset, Asset::ForeignAsset(100)); + }); +} + #[test] fn the_entire_market_lifecycle_works_with_timestamps() { ExtBuilder::default().build().execute_with(|| { // Creates a permissionless market. assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -2791,7 +3609,7 @@ fn the_entire_market_lifecycle_works_with_timestamps() { )); // is ok - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); // set the timestamp @@ -2801,12 +3619,12 @@ fn the_entire_market_lifecycle_works_with_timestamps() { Timestamp::set_timestamp(100_000_000 + grace_period); assert_noop!( - PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, CENT), + PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, CENT), Error::::MarketIsNotActive, ); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); @@ -2815,9 +3633,10 @@ fn the_entire_market_lifecycle_works_with_timestamps() { #[test] fn full_scalar_market_lifecycle() { - ExtBuilder::default().build().execute_with(|| { + let test = |base_asset: Asset| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -2828,7 +3647,11 @@ fn full_scalar_market_lifecycle() { ScoringRule::CPMM )); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, 100 * BASE)); + assert_ok!(PredictionMarkets::buy_complete_set( + RuntimeOrigin::signed(CHARLIE), + 0, + 100 * BASE + )); // check balances let assets = PredictionMarkets::outcome_assets(0, &MarketCommons::market(&0).unwrap()); @@ -2846,7 +3669,11 @@ fn full_scalar_market_lifecycle() { Timestamp::set_timestamp(100_000_000 + grace_period); // report - assert_ok!(PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Scalar(100))); + assert_ok!(PredictionMarkets::report( + RuntimeOrigin::signed(BOB), + 0, + OutcomeReport::Scalar(100) + )); let market_after_report = MarketCommons::market(&0).unwrap(); assert!(market_after_report.report.is_some()); @@ -2856,7 +3683,11 @@ fn full_scalar_market_lifecycle() { assert_eq!(report.outcome, OutcomeReport::Scalar(100)); // dispute - assert_ok!(PredictionMarkets::dispute(Origin::signed(DAVE), 0, OutcomeReport::Scalar(25))); + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(DAVE), + 0, + OutcomeReport::Scalar(25) + )); let disputes = crate::Disputes::::get(0); assert_eq!(disputes.len(), 1); @@ -2869,7 +3700,7 @@ fn full_scalar_market_lifecycle() { // give EVE some shares assert_ok!(Tokens::transfer( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), EVE, Asset::ScalarOutcome(0, ScalarPosition::Short), 50 * BASE @@ -2880,17 +3711,17 @@ fn full_scalar_market_lifecycle() { 50 * BASE ); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); for asset in assets.iter() { let bal = Tokens::free_balance(*asset, &CHARLIE); assert_eq!(bal, 0); } // check payouts is right for each CHARLIE and EVE - let ztg_bal_charlie = Balances::free_balance(&CHARLIE); - let ztg_bal_eve = Balances::free_balance(&EVE); - assert_eq!(ztg_bal_charlie, 98750 * CENT); // 75 (LONG) + 12.5 (SHORT) + 900 (balance) - assert_eq!(ztg_bal_eve, 1000 * BASE); + let base_asset_bal_charlie = AssetManager::free_balance(base_asset, &CHARLIE); + let base_asset_bal_eve = AssetManager::free_balance(base_asset, &EVE); + assert_eq!(base_asset_bal_charlie, 98750 * CENT); // 75 (LONG) + 12.5 (SHORT) + 900 (balance) + assert_eq!(base_asset_bal_eve, 1000 * BASE); System::assert_has_event( Event::TokensRedeemed( 0, @@ -2912,9 +3743,9 @@ fn full_scalar_market_lifecycle() { .into(), ); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(EVE), 0)); - let ztg_bal_eve_after = Balances::free_balance(&EVE); - assert_eq!(ztg_bal_eve_after, 101250 * CENT); // 12.5 (SHORT) + 1000 (balance) + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(EVE), 0)); + let base_asset_bal_eve_after = AssetManager::free_balance(base_asset, &EVE); + assert_eq!(base_asset_bal_eve_after, 101250 * CENT); // 12.5 (SHORT) + 1000 (balance) System::assert_last_event( Event::TokensRedeemed( 0, @@ -2925,36 +3756,62 @@ fn full_scalar_market_lifecycle() { ) .into(), ); - }) + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); + }); } #[test] fn scalar_market_correctly_resolves_on_out_of_range_outcomes_below_threshold() { + let test = |base_asset: Asset| { + scalar_market_correctly_resolves_common(base_asset, 50); + assert_eq!(AssetManager::free_balance(base_asset, &CHARLIE), 900 * BASE); + assert_eq!(AssetManager::free_balance(base_asset, &EVE), 1100 * BASE); + }; ExtBuilder::default().build().execute_with(|| { - scalar_market_correctly_resolves_common(50); - assert_eq!(Balances::free_balance(&CHARLIE), 900 * BASE); - assert_eq!(Balances::free_balance(&EVE), 1100 * BASE); - }) + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); + }); } #[test] fn scalar_market_correctly_resolves_on_out_of_range_outcomes_above_threshold() { + let test = |base_asset: Asset| { + scalar_market_correctly_resolves_common(base_asset, 250); + assert_eq!(AssetManager::free_balance(base_asset, &CHARLIE), 1000 * BASE); + assert_eq!(AssetManager::free_balance(base_asset, &EVE), 1000 * BASE); + }; ExtBuilder::default().build().execute_with(|| { - scalar_market_correctly_resolves_common(250); - assert_eq!(Balances::free_balance(&CHARLIE), 1000 * BASE); - assert_eq!(Balances::free_balance(&EVE), 1000 * BASE); - }) + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); + }); } #[test] fn reject_market_fails_on_permissionless_market() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Permissionless, 0..1, ScoringRule::CPMM); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Permissionless, + 0..1, + ScoringRule::CPMM, + ); let reject_reason: Vec = vec![0; ::MaxRejectReasonLen::get() as usize]; assert_noop!( - PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason), + PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason), Error::::InvalidMarketStatus ); }); @@ -2964,12 +3821,17 @@ fn reject_market_fails_on_permissionless_market() { fn reject_market_fails_on_approved_market() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. - simple_create_categorical_market(MarketCreation::Advised, 0..1, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); + simple_create_categorical_market( + Asset::Ztg, + MarketCreation::Advised, + 0..1, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); let reject_reason: Vec = vec![0; ::MaxRejectReasonLen::get() as usize]; assert_noop!( - PredictionMarkets::reject_market(Origin::signed(SUDO), 0, reject_reason), + PredictionMarkets::reject_market(RuntimeOrigin::signed(SUDO), 0, reject_reason), Error::::InvalidMarketStatus ); }); @@ -2980,7 +3842,8 @@ fn market_resolve_does_not_hold_liquidity_withdraw() { ExtBuilder::default().build().execute_with(|| { let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -2991,31 +3854,37 @@ fn market_resolve_does_not_hold_liquidity_withdraw() { ScoringRule::CPMM )); deploy_swap_pool(MarketCommons::market(&0).unwrap(), 0).unwrap(); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(ALICE), 0, BASE)); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(BOB), 0, 2 * BASE)); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, 3 * BASE)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(ALICE), 0, BASE)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(BOB), 0, 2 * BASE)); + assert_ok!(PredictionMarkets::buy_complete_set( + RuntimeOrigin::signed(CHARLIE), + 0, + 3 * BASE + )); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(2) )); run_to_block(grace_period + market.deadlines.dispute_duration + 2); - assert_ok!(Swaps::pool_exit(Origin::signed(FRED), 0, BASE * 100, vec![0, 0])); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(BOB), 0)); + assert_ok!(Swaps::pool_exit(RuntimeOrigin::signed(FRED), 0, BASE * 100, vec![0, 0])); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(BOB), 0)); }) } #[test] fn authorized_correctly_resolves_disputed_market() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { let end = 2; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3025,47 +3894,46 @@ fn authorized_correctly_resolves_disputed_market() { MarketDisputeMechanism::Authorized, ScoringRule::CPMM, )); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, CENT)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, CENT)); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); - let dispute_at_0 = grace_period + 1 + 1; - run_to_block(dispute_at_0); + + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT); + + let dispute_at = grace_period + 1 + 1; + run_to_block(dispute_at); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(1) )); + if base_asset == Asset::Ztg { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT - DisputeBond::get()); + } else { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - DisputeBond::get()); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT); + } + // Fred authorizses an outcome, but fat-fingers it on the first try. assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Categorical(0) )); assert_ok!(Authorized::authorize_market_outcome( - Origin::signed(AuthorizedDisputeResolutionUser::get()), - 0, - OutcomeReport::Categorical(1) - )); - - let dispute_at_1 = dispute_at_0 + 1; - run_to_block(dispute_at_1); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(DAVE), - 0, - OutcomeReport::Categorical(0) - )); - let dispute_at_2 = dispute_at_1 + 1; - run_to_block(dispute_at_2); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(AuthorizedDisputeResolutionUser::get()), 0, OutcomeReport::Categorical(1) )); @@ -3074,146 +3942,102 @@ fn authorized_correctly_resolves_disputed_market() { assert_eq!(market.status, MarketStatus::Disputed); // check everyone's deposits - let charlie_reserved = Balances::reserved_balance(&CHARLIE); + let charlie_reserved = Balances::reserved_balance(CHARLIE); assert_eq!(charlie_reserved, DisputeBond::get()); - let dave_reserved = Balances::reserved_balance(&DAVE); - assert_eq!(dave_reserved, DisputeBond::get() + DisputeFactor::get()); - - let eve_reserved = Balances::reserved_balance(&EVE); - assert_eq!(eve_reserved, DisputeBond::get() + 2 * DisputeFactor::get()); - // check disputes length let disputes = crate::Disputes::::get(0); - assert_eq!(disputes.len(), 3); + assert_eq!(disputes.len(), 1); - // make sure the old mappings of market id per dispute block are erased let market_ids_1 = MarketIdsPerDisputeBlock::::get( - dispute_at_0 + market.deadlines.dispute_duration, + dispute_at + ::CorrectionPeriod::get(), ); - assert_eq!(market_ids_1.len(), 0); + assert_eq!(market_ids_1.len(), 1); + + if base_asset == Asset::Ztg { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT - DisputeBond::get()); + } else { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - DisputeBond::get()); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT); + } - let market_ids_2 = MarketIdsPerDisputeBlock::::get( - dispute_at_1 + market.deadlines.dispute_duration, - ); - assert_eq!(market_ids_2.len(), 0); + run_blocks(::CorrectionPeriod::get() - 1); - let market_ids_3 = MarketIdsPerDisputeBlock::::get( - dispute_at_2 + market.deadlines.dispute_duration, - ); - assert_eq!(market_ids_3.len(), 1); + let market_after = MarketCommons::market(&0).unwrap(); + assert_eq!(market_after.status, MarketStatus::Disputed); + + if base_asset == Asset::Ztg { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT - DisputeBond::get()); + } else { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - DisputeBond::get()); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT); + } - run_blocks(market.deadlines.dispute_duration); + run_blocks(1); + + if base_asset == Asset::Ztg { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT + OracleBond::get()); + } else { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE + OracleBond::get()); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE - CENT); + } let market_after = MarketCommons::market(&0).unwrap(); assert_eq!(market_after.status, MarketStatus::Resolved); let disputes = crate::Disputes::::get(0); assert_eq!(disputes.len(), 0); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); - // Make sure rewards are right: - // - // Slashed amounts: - // - Dave's reserve: DisputeBond::get() + DisputeFactor::get() - // - Alice's oracle bond: OracleBond::get() - // Total: OracleBond::get() + DisputeBond::get() + DisputeFactor::get() - // - // Charlie and Eve each receive half of the total slashed amount as bounty. - let dave_reserved = DisputeBond::get() + DisputeFactor::get(); - let total_slashed = OracleBond::get() + dave_reserved; - - let charlie_balance = Balances::free_balance(&CHARLIE); - assert_eq!(charlie_balance, 1_000 * BASE + total_slashed / 2); - let charlie_reserved_2 = Balances::reserved_balance(&CHARLIE); + if base_asset == Asset::Ztg { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE + OracleBond::get()); + } else { + let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE + OracleBond::get()); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); + assert_eq!(charlie_balance, 1_000 * BASE); + } + let charlie_reserved_2 = AssetManager::reserved_balance(Asset::Ztg, &CHARLIE); assert_eq!(charlie_reserved_2, 0); - let eve_balance = Balances::free_balance(&EVE); - assert_eq!(eve_balance, 1_000 * BASE + total_slashed / 2); - - let dave_balance = Balances::free_balance(&DAVE); - assert_eq!(dave_balance, 1_000 * BASE - dave_reserved); - let alice_balance = Balances::free_balance(&ALICE); + let alice_balance = AssetManager::free_balance(Asset::Ztg, &ALICE); assert_eq!(alice_balance, 1_000 * BASE - OracleBond::get()); // bob kinda gets away scot-free since Alice is held responsible // for her designated reporter - let bob_balance = Balances::free_balance(&BOB); + let bob_balance = AssetManager::free_balance(Asset::Ztg, &BOB); assert_eq!(bob_balance, 1_000 * BASE); assert!(market_after.bonds.creation.unwrap().is_settled); assert!(market_after.bonds.oracle.unwrap().is_settled); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); }); -} - -#[test] -fn on_resolution_defaults_to_oracle_report_in_case_of_unresolved_dispute() { + #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - assert!(Balances::free_balance(Treasury::account_id()).is_zero()); - let end = 2; - let market_id = 0; - assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), - BOB, - MarketPeriod::Block(0..end), - get_deadlines(), - gen_metadata(2), - MarketCreation::Permissionless, - MarketType::Categorical(::MinCategories::get()), - MarketDisputeMechanism::Authorized, - ScoringRule::CPMM, - )); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), market_id, CENT)); - - let market = MarketCommons::market(&0).unwrap(); - let grace_period = end + market.deadlines.grace_period; - run_to_block(grace_period + 1); - assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), - market_id, - OutcomeReport::Categorical(1) - )); - assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), - market_id, - OutcomeReport::Categorical(0) - )); - let market = MarketCommons::market(&market_id).unwrap(); - assert_eq!(market.status, MarketStatus::Disputed); - - let charlie_reserved = Balances::reserved_balance(&CHARLIE); - assert_eq!(charlie_reserved, DisputeBond::get()); - - run_blocks(market.deadlines.dispute_duration); - let market_after = MarketCommons::market(&market_id).unwrap(); - assert_eq!(market_after.status, MarketStatus::Resolved); - let disputes = crate::Disputes::::get(0); - assert_eq!(disputes.len(), 0); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), market_id)); - - // Make sure rewards are right: - // - // - Bob reported "correctly" and in time, so Alice and Bob don't get slashed - // - Charlie started a dispute which was abandoned, hence he's slashed and his rewards are - // moved to the treasury - let alice_balance = Balances::free_balance(&ALICE); - assert_eq!(alice_balance, 1_000 * BASE); - let bob_balance = Balances::free_balance(&BOB); - assert_eq!(bob_balance, 1_000 * BASE); - let charlie_balance = Balances::free_balance(&CHARLIE); - assert_eq!(charlie_balance, 1_000 * BASE - charlie_reserved); - assert_eq!(Balances::free_balance(Treasury::account_id()), charlie_reserved); - - assert!(market_after.bonds.creation.unwrap().is_settled); - assert!(market_after.bonds.oracle.unwrap().is_settled); + test(Asset::ForeignAsset(100)); }); } #[test] fn approve_market_correctly_unreserves_advisory_bond() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -3224,22 +4048,20 @@ fn approve_market_correctly_unreserves_advisory_bond() { ScoringRule::CPMM, )); let market_id = 0; - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + AdvisoryBond::get() + OracleBond::get() - ); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), market_id)); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + AdvisoryBond::get()); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, AdvisoryBond::get() + OracleBond::get()); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), market_id)); + check_reserve(&ALICE, OracleBond::get()); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + AdvisoryBond::get()); let market = MarketCommons::market(&market_id).unwrap(); assert!(market.bonds.creation.unwrap().is_settled); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3252,7 +4074,8 @@ fn deploy_swap_pool_correctly_sets_weight_of_base_asset() { ::MinWeight::get() + 33, ]; assert_ok!(PredictionMarkets::create_cpmm_market_and_deploy_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, ALICE, MarketPeriod::Block(0..42), get_deadlines(), @@ -3260,7 +4083,7 @@ fn deploy_swap_pool_correctly_sets_weight_of_base_asset() { MarketType::Categorical(3), MarketDisputeMechanism::SimpleDisputes, 1, - ::MinLiquidity::get(), + LIQUIDITY, weights, )); let pool = >::get(0).unwrap(); @@ -3277,7 +4100,8 @@ fn deploy_swap_pool_for_market_returns_error_if_weights_is_too_short() { ExtBuilder::default().build().execute_with(|| { let category_count = 5; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -3288,13 +4112,13 @@ fn deploy_swap_pool_for_market_returns_error_if_weights_is_too_short() { ScoringRule::CPMM )); let amount = 123 * BASE; - assert_ok!(Balances::set_balance(Origin::root(), ALICE, 2 * amount, 0)); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(ALICE), 0, amount)); + assert_ok!(Balances::set_balance(RuntimeOrigin::root(), ALICE, 2 * amount, 0)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(ALICE), 0, amount)); // Attempt to create a pool with four weights; but we need five instead (base asset not // counted). assert_noop!( PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), 0, 1, amount, @@ -3313,7 +4137,8 @@ fn deploy_swap_pool_for_market_returns_error_if_weights_is_too_long() { ExtBuilder::default().build().execute_with(|| { let category_count = 5; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -3324,13 +4149,13 @@ fn deploy_swap_pool_for_market_returns_error_if_weights_is_too_long() { ScoringRule::CPMM )); let amount = 123 * BASE; - assert_ok!(Balances::set_balance(Origin::root(), ALICE, 2 * amount, 0)); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(ALICE), 0, amount)); + assert_ok!(Balances::set_balance(RuntimeOrigin::root(), ALICE, 2 * amount, 0)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(ALICE), 0, amount)); // Attempt to create a pool with six weights; but we need five instead (base asset not // counted). assert_noop!( PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), 0, ::MaxSwapFee::get(), amount, @@ -3347,10 +4172,13 @@ fn deploy_swap_pool_for_market_returns_error_if_weights_is_too_long() { #[test] fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_on_oracle_report() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3360,41 +4188,42 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + ValidityBond::get() + OracleBond::get() - ); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, ValidityBond::get() + OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); run_to_block(grace_period + market.deadlines.dispute_duration + 1); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get() + OracleBond::get() ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_on_outsider_report() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..100), get_deadlines(), @@ -3404,40 +4233,131 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, ValidityBond::get() + OracleBond::get()); + + let charlie_balance_before = Balances::free_balance(CHARLIE); + let market = MarketCommons::market(&0).unwrap(); + let grace_period = end + market.deadlines.grace_period; + let report_at = grace_period + market.deadlines.oracle_duration + 1; + run_to_block(report_at); + + assert!(market.bonds.outsider.is_none()); + assert_ok!(PredictionMarkets::report( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(1) )); - let alice_balance_before = Balances::free_balance(&ALICE); + + let market = MarketCommons::market(&0).unwrap(); + assert_eq!(market.bonds.outsider, Some(Bond::new(CHARLIE, OutsiderBond::get()))); + check_reserve(&CHARLIE, OutsiderBond::get()); + assert_eq!(Balances::free_balance(CHARLIE), charlie_balance_before - OutsiderBond::get()); + let charlie_balance_before = Balances::free_balance(CHARLIE); + + run_blocks(market.deadlines.dispute_duration); + check_reserve(&ALICE, 0); + // Check that validity bond didn't get slashed, but oracle bond did + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get()); + + check_reserve(&CHARLIE, 0); + // Check that the outsider gets the OracleBond together with the OutsiderBond assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + ValidityBond::get() + OracleBond::get() + Balances::free_balance(CHARLIE), + charlie_balance_before + OracleBond::get() + OutsiderBond::get() ); + let market = MarketCommons::market(&0).unwrap(); + assert!(market.bonds.outsider.unwrap().is_settled); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); + }); +} + +#[test] +fn outsider_reports_wrong_outcome() { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); + + let end = 100; + let alice_balance_before = Balances::free_balance(ALICE); + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + base_asset, + BOB, + MarketPeriod::Block(0..end), + get_deadlines(), + gen_metadata(2), + MarketCreation::Permissionless, + MarketType::Categorical(2), + MarketDisputeMechanism::SimpleDisputes, + ScoringRule::CPMM, + )); + + let outsider = CHARLIE; + let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; let report_at = grace_period + market.deadlines.oracle_duration + 1; run_to_block(report_at); assert_ok!(PredictionMarkets::report( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(outsider), 0, OutcomeReport::Categorical(1) )); + + let outsider_balance_before = Balances::free_balance(outsider); + check_reserve(&outsider, OutsiderBond::get()); + + let dispute_at_0 = report_at + 1; + run_to_block(dispute_at_0); + assert_ok!(PredictionMarkets::dispute( + RuntimeOrigin::signed(EVE), + 0, + OutcomeReport::Categorical(0) + )); + + let eve_balance_before = Balances::free_balance(EVE); + + // on_resolution called run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); - // Check that validity bond didn't get slashed, but oracle bond did - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + ValidityBond::get()); + + assert_eq!(Balances::free_balance(ALICE), alice_balance_before - OracleBond::get()); + + check_reserve(&outsider, 0); + assert_eq!(Balances::free_balance(outsider), outsider_balance_before); + + let dispute_bond = crate::default_dispute_bond::(0usize); + // disputor EVE gets the OracleBond and OutsiderBond and dispute bond + assert_eq!( + Balances::free_balance(EVE), + eve_balance_before + dispute_bond + OutsiderBond::get() + OracleBond::get() + ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_market_on_oracle_report() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3447,38 +4367,42 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; let report_at = grace_period + 1; run_to_block(report_at); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // Check that nothing got slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + OracleBond::get()); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + OracleBond::get()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } #[test] fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_market_on_outsider_report() { - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3488,28 +4412,29 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; let report_at = grace_period + market.deadlines.oracle_duration + 1; run_to_block(report_at); assert_ok!(PredictionMarkets::report( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(1) )); run_blocks(market.deadlines.dispute_duration); // Check that oracle bond got slashed - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before); + check_reserve(&ALICE, 0); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3517,10 +4442,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_with_correct_disputed_outcome_with_oracle_report() { // Oracle reports in time but incorrect report, so OracleBond gets slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3530,34 +4458,32 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + ValidityBond::get() + OracleBond::get() - ); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, ValidityBond::get() + OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(1) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + ValidityBond::get()); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3565,10 +4491,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_market_with_correct_disputed_outcome_with_oracle_report() { // Oracle reports in time but incorrect report, so OracleBond gets slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3578,32 +4507,33 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(1) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3611,10 +4541,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_with_wrong_disputed_outcome_with_oracle_report() { // Oracle reports in time and correct report, so OracleBond does not get slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3624,43 +4557,41 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + ValidityBond::get() + OracleBond::get() - ); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, ValidityBond::get() + OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); // EVE disputes with wrong outcome assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(0) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is not slashed assert_eq!( - Balances::free_balance(&ALICE), + Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get() + OracleBond::get() ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3668,10 +4599,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_market_with_wrong_disputed_outcome_with_oracle_report() { // Oracle reports in time and correct report, so OracleBond does not get slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3681,38 +4615,39 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(0) )); // EVE disputes with wrong outcome assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, OutcomeReport::Categorical(0) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is not slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + OracleBond::get()); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + OracleBond::get()); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3720,10 +4655,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_with_disputed_outcome_with_outsider_report() { // Oracle does not report in time, so OracleBond gets slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG, irrespective of base_asset. + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3733,42 +4671,54 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!( - Balances::reserved_balance(&ALICE), - SENTINEL_AMOUNT + ValidityBond::get() + OracleBond::get() - ); + + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, ValidityBond::get() + OracleBond::get()); + + let outsider = CHARLIE; + let market = MarketCommons::market(&0).unwrap(); let after_oracle_duration = end + market.deadlines.grace_period + market.deadlines.oracle_duration + 1; run_to_block(after_oracle_duration); // CHARLIE is not an Oracle assert_ok!(PredictionMarkets::report( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(outsider), 0, OutcomeReport::Categorical(0) )); + + let outsider_balance_before = Balances::free_balance(outsider); + check_reserve(&outsider, OutsiderBond::get()); + // EVE disputes with wrong outcome assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(FRED), + RuntimeOrigin::signed(FRED), 0, OutcomeReport::Categorical(0) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before + ValidityBond::get()); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get()); + + check_reserve(&outsider, 0); + assert_eq!( + Balances::free_balance(outsider), + outsider_balance_before + OracleBond::get() + OutsiderBond::get() + ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3776,10 +4726,13 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_market_with_disputed_outcome_with_outsider_report() { // Oracle does not report in time, so OracleBond gets slashed on resolution - ExtBuilder::default().build().execute_with(|| { + // NOTE: Bonds are always in ZTG + let test = |base_asset: Asset| { + reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + base_asset, BOB, MarketPeriod::Block(0..end), get_deadlines(), @@ -3789,40 +4742,54 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma MarketDisputeMechanism::SimpleDisputes, ScoringRule::CPMM, )); - // Reserve a sentinel amount to check that we don't unreserve too much. - assert_ok!(Balances::reserve_named( - &PredictionMarkets::reserve_id(), - &ALICE, - SENTINEL_AMOUNT - )); - assert_ok!(PredictionMarkets::approve_market(Origin::signed(SUDO), 0)); - let alice_balance_before = Balances::free_balance(&ALICE); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT + OracleBond::get()); + + let outsider = CHARLIE; + + assert_ok!(PredictionMarkets::approve_market(RuntimeOrigin::signed(SUDO), 0)); + let alice_balance_before = Balances::free_balance(ALICE); + check_reserve(&ALICE, OracleBond::get()); let market = MarketCommons::market(&0).unwrap(); let after_oracle_duration = end + market.deadlines.grace_period + market.deadlines.oracle_duration + 1; run_to_block(after_oracle_duration); // CHARLIE is not an Oracle assert_ok!(PredictionMarkets::report( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(outsider), 0, OutcomeReport::Categorical(0) )); + + let outsider_balance_before = Balances::free_balance(outsider); + check_reserve(&outsider, OutsiderBond::get()); + // EVE disputes with wrong outcome assert_ok!(PredictionMarkets::dispute( - Origin::signed(EVE), + RuntimeOrigin::signed(EVE), 0, OutcomeReport::Categorical(1) )); assert_ok!(PredictionMarkets::dispute( - Origin::signed(FRED), + RuntimeOrigin::signed(FRED), 0, OutcomeReport::Categorical(0) )); run_blocks(market.deadlines.dispute_duration); - assert_eq!(Balances::reserved_balance(&ALICE), SENTINEL_AMOUNT); + check_reserve(&ALICE, 0); // ValidityBond bond is returned but OracleBond is slashed - assert_eq!(Balances::free_balance(&ALICE), alice_balance_before); + assert_eq!(Balances::free_balance(ALICE), alice_balance_before); + + check_reserve(&outsider, 0); + assert_eq!( + Balances::free_balance(outsider), + outsider_balance_before + OracleBond::get() + OutsiderBond::get() + ); + }; + ExtBuilder::default().build().execute_with(|| { + test(Asset::Ztg); + }); + #[cfg(feature = "parachain")] + ExtBuilder::default().build().execute_with(|| { + test(Asset::ForeignAsset(100)); }); } @@ -3830,7 +4797,8 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma fn report_fails_on_market_state_proposed() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -3841,7 +4809,7 @@ fn report_fails_on_market_state_proposed() { ScoringRule::CPMM )); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3851,7 +4819,8 @@ fn report_fails_on_market_state_proposed() { fn report_fails_on_market_state_closed_for_advised_market() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -3862,7 +4831,7 @@ fn report_fails_on_market_state_closed_for_advised_market() { ScoringRule::CPMM )); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3872,7 +4841,8 @@ fn report_fails_on_market_state_closed_for_advised_market() { fn report_fails_on_market_state_collecting_subsidy() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(100_000_000..200_000_000), get_deadlines(), @@ -3883,7 +4853,7 @@ fn report_fails_on_market_state_collecting_subsidy() { ScoringRule::RikiddoSigmoidFeeMarketEma )); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3893,7 +4863,8 @@ fn report_fails_on_market_state_collecting_subsidy() { fn report_fails_on_market_state_insufficient_subsidy() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(100_000_000..200_000_000), get_deadlines(), @@ -3908,7 +4879,7 @@ fn report_fails_on_market_state_insufficient_subsidy() { Ok(()) }); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3918,7 +4889,8 @@ fn report_fails_on_market_state_insufficient_subsidy() { fn report_fails_on_market_state_active() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -3929,7 +4901,7 @@ fn report_fails_on_market_state_active() { ScoringRule::CPMM )); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3939,7 +4911,8 @@ fn report_fails_on_market_state_active() { fn report_fails_on_market_state_suspended() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -3954,7 +4927,7 @@ fn report_fails_on_market_state_suspended() { Ok(()) }); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3964,7 +4937,8 @@ fn report_fails_on_market_state_suspended() { fn report_fails_on_market_state_resolved() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -3979,7 +4953,7 @@ fn report_fails_on_market_state_resolved() { Ok(()) }); assert_noop!( - PredictionMarkets::report(Origin::signed(BOB), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, OutcomeReport::Categorical(1)), Error::::MarketIsNotClosed, ); }); @@ -3989,7 +4963,8 @@ fn report_fails_on_market_state_resolved() { fn report_fails_if_reporter_is_not_the_oracle() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), + Asset::Ztg, BOB, MarketPeriod::Timestamp(0..100_000_000), get_deadlines(), @@ -4006,12 +4981,128 @@ fn report_fails_if_reporter_is_not_the_oracle() { let grace_period: u64 = market.deadlines.grace_period * MILLISECS_PER_BLOCK as u64; set_timestamp_for_on_initialize(100_000_000 + grace_period + MILLISECS_PER_BLOCK as u64); assert_noop!( - PredictionMarkets::report(Origin::signed(CHARLIE), 0, OutcomeReport::Categorical(1)), + PredictionMarkets::report( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(1) + ), Error::::ReporterNotOracle, ); }); } +#[test] +fn create_market_succeeds_if_market_duration_is_maximal_in_blocks() { + ExtBuilder::default().build().execute_with(|| { + let now = 1; + frame_system::Pallet::::set_block_number(now); + let start = 5; + let end = now + ::MaxMarketLifetime::get(); + assert!( + end > start, + "Test failed due to misconfiguration: `MaxMarketLifetime` is too small" + ); + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Block(start..end), + get_deadlines(), + gen_metadata(0), + MarketCreation::Permissionless, + MarketType::Categorical(3), + MarketDisputeMechanism::Authorized, + ScoringRule::CPMM, + )); + }); +} + +#[test] +fn create_market_suceeds_if_market_duration_is_maximal_in_moments() { + ExtBuilder::default().build().execute_with(|| { + let now = 12_001u64; + Timestamp::set_timestamp(now); + let start = 5 * MILLISECS_PER_BLOCK as u64; + let end = + now + ::MaxMarketLifetime::get() * (MILLISECS_PER_BLOCK as u64); + assert!( + end > start, + "Test failed due to misconfiguration: `MaxMarketLifetime` is too small" + ); + assert_ok!(PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Timestamp(start..end), + get_deadlines(), + gen_metadata(0), + MarketCreation::Permissionless, + MarketType::Categorical(3), + MarketDisputeMechanism::Authorized, + ScoringRule::CPMM, + )); + }); +} + +#[test] +fn create_market_fails_if_market_duration_is_too_long_in_blocks() { + ExtBuilder::default().build().execute_with(|| { + let now = 1; + frame_system::Pallet::::set_block_number(now); + let start = 5; + let end = now + ::MaxMarketLifetime::get() + 1; + assert!( + end > start, + "Test failed due to misconfiguration: `MaxMarketLifetime` is too small" + ); + assert_noop!( + PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Block(start..end), + get_deadlines(), + gen_metadata(0), + MarketCreation::Permissionless, + MarketType::Categorical(3), + MarketDisputeMechanism::Authorized, + ScoringRule::CPMM, + ), + crate::Error::::MarketDurationTooLong, + ); + }); +} + +#[test] +fn create_market_fails_if_market_duration_is_too_long_in_moments() { + ExtBuilder::default().build().execute_with(|| { + let now = 12_001u64; + Timestamp::set_timestamp(now); + let start = 5 * MILLISECS_PER_BLOCK as u64; + let end = now + + (::MaxMarketLifetime::get() + 1) * (MILLISECS_PER_BLOCK as u64); + assert!( + end > start, + "Test failed due to misconfiguration: `MaxMarketLifetime` is too small" + ); + assert_noop!( + PredictionMarkets::create_market( + RuntimeOrigin::signed(ALICE), + Asset::Ztg, + BOB, + MarketPeriod::Timestamp(start..end), + get_deadlines(), + gen_metadata(0), + MarketCreation::Permissionless, + MarketType::Categorical(3), + MarketDisputeMechanism::Authorized, + ScoringRule::CPMM, + ), + crate::Error::::MarketDurationTooLong, + ); + }); +} + #[test_case( MarketCreation::Advised, ScoringRule::CPMM, @@ -4019,6 +5110,7 @@ fn report_fails_if_reporter_is_not_the_oracle() { MarketBonds { creation: Some(Bond::new(ALICE, ::AdvisoryBond::get())), oracle: Some(Bond::new(ALICE, ::OracleBond::get())), + outsider: None, } )] #[test_case( @@ -4028,6 +5120,7 @@ fn report_fails_if_reporter_is_not_the_oracle() { MarketBonds { creation: Some(Bond::new(ALICE, ::ValidityBond::get())), oracle: Some(Bond::new(ALICE, ::OracleBond::get())), + outsider: None, } )] fn create_market_sets_the_correct_market_parameters_and_reserves_the_correct_amount( @@ -4050,7 +5143,8 @@ fn create_market_sets_the_correct_market_parameters_and_reserves_the_correct_amo let market_type = MarketType::Categorical(7); let dispute_mechanism = MarketDisputeMechanism::Authorized; assert_ok!(PredictionMarkets::create_market( - Origin::signed(creator), + RuntimeOrigin::signed(creator), + Asset::Ztg, oracle, period.clone(), deadlines, @@ -4079,32 +5173,37 @@ fn create_market_sets_the_correct_market_parameters_and_reserves_the_correct_amo } fn deploy_swap_pool( - market: Market, + market: Market>, market_id: u128, ) -> DispatchResultWithPostInfo { - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(FRED), 0, 100 * BASE)); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(FRED), 0, 100 * BASE)); assert_ok!(Balances::transfer( - Origin::signed(FRED), + RuntimeOrigin::signed(FRED), ::PalletId::get().into_account_truncating(), 100 * BASE )); let outcome_assets_len = PredictionMarkets::outcome_assets(market_id, &market).len(); PredictionMarkets::deploy_swap_pool_for_market( - Origin::signed(FRED), + RuntimeOrigin::signed(FRED), 0, ::MaxSwapFee::get(), - ::MinLiquidity::get(), + LIQUIDITY, vec![::MinWeight::get(); outcome_assets_len], ) } // Common code of `scalar_market_correctly_resolves_*` -fn scalar_market_correctly_resolves_common(reported_value: u128) { +fn scalar_market_correctly_resolves_common(base_asset: Asset, reported_value: u128) { let end = 100; - simple_create_scalar_market(MarketCreation::Permissionless, 0..end, ScoringRule::CPMM); - assert_ok!(PredictionMarkets::buy_complete_set(Origin::signed(CHARLIE), 0, 100 * BASE)); + simple_create_scalar_market( + base_asset, + MarketCreation::Permissionless, + 0..end, + ScoringRule::CPMM, + ); + assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, 100 * BASE)); assert_ok!(Tokens::transfer( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), EVE, Asset::ScalarOutcome(0, ScalarPosition::Short), 100 * BASE @@ -4115,7 +5214,7 @@ fn scalar_market_correctly_resolves_common(reported_value: u128) { let grace_period = end + market.deadlines.grace_period; run_to_block(grace_period + 1); assert_ok!(PredictionMarkets::report( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), 0, OutcomeReport::Scalar(reported_value) )); @@ -4132,14 +5231,14 @@ fn scalar_market_correctly_resolves_common(reported_value: u128) { // Check balances before redeeming (just to make sure that our tests are based on correct // assumptions)! - assert_eq!(Balances::free_balance(&CHARLIE), 900 * BASE); - assert_eq!(Balances::free_balance(&EVE), 1000 * BASE); + assert_eq!(AssetManager::free_balance(base_asset, &CHARLIE), 900 * BASE); + assert_eq!(AssetManager::free_balance(base_asset, &EVE), 1000 * BASE); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(CHARLIE), 0)); - assert_ok!(PredictionMarkets::redeem_shares(Origin::signed(EVE), 0)); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); + assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(EVE), 0)); let assets = PredictionMarkets::outcome_assets(0, &MarketCommons::market(&0).unwrap()); for asset in assets.iter() { - assert_eq!(Tokens::free_balance(*asset, &CHARLIE), 0); - assert_eq!(Tokens::free_balance(*asset, &EVE), 0); + assert_eq!(AssetManager::free_balance(*asset, &CHARLIE), 0); + assert_eq!(AssetManager::free_balance(*asset, &EVE), 0); } } diff --git a/zrml/prediction-markets/src/weights.rs b/zrml/prediction-markets/src/weights.rs index 22884a3f0..ffae859e8 100644 --- a/zrml/prediction-markets/src/weights.rs +++ b/zrml/prediction-markets/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_prediction_markets //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -50,8 +51,8 @@ pub trait WeightInfoZeitgeist { fn admin_move_market_to_closed(o: u32, c: u32) -> Weight; fn admin_move_market_to_resolved_scalar_reported(r: u32) -> Weight; fn admin_move_market_to_resolved_categorical_reported(r: u32) -> Weight; - fn admin_move_market_to_resolved_scalar_disputed(r: u32, d: u32) -> Weight; - fn admin_move_market_to_resolved_categorical_disputed(r: u32, d: u32) -> Weight; + fn admin_move_market_to_resolved_scalar_disputed(r: u32) -> Weight; + fn admin_move_market_to_resolved_categorical_disputed(r: u32) -> Weight; fn approve_market() -> Weight; fn request_edit(r: u32) -> Weight; fn buy_complete_set(a: u32) -> Weight; @@ -59,13 +60,13 @@ pub trait WeightInfoZeitgeist { fn edit_market(m: u32) -> Weight; fn deploy_swap_pool_for_market_future_pool(a: u32, o: u32) -> Weight; fn deploy_swap_pool_for_market_open_pool(a: u32) -> Weight; - fn start_global_dispute(m: u32) -> Weight; - fn dispute_authorized(d: u32, b: u32) -> Weight; + fn start_global_dispute(m: u32, n: u32) -> Weight; + fn dispute_authorized() -> Weight; fn handle_expired_advised_market() -> Weight; fn internal_resolve_categorical_reported() -> Weight; - fn internal_resolve_categorical_disputed(d: u32) -> Weight; + fn internal_resolve_categorical_disputed() -> Weight; fn internal_resolve_scalar_reported() -> Weight; - fn internal_resolve_scalar_disputed(d: u32) -> Weight; + fn internal_resolve_scalar_disputed() -> Weight; fn on_initialize_resolve_overhead() -> Weight; fn process_subsidy_collecting_markets_raw(a: u32) -> Weight; fn redeem_shares_categorical() -> Weight; @@ -83,24 +84,32 @@ pub trait WeightInfoZeitgeist { pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { // Storage: MarketCommons Markets (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: System Account (r:2 w:2) + // Storage: Balances Reserves (r:7 w:7) + // Storage: System Account (r:8 w:8) // Storage: MarketCommons MarketPool (r:1 w:1) // Storage: Swaps Pools (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: Tokens TotalIssuance (r:2 w:2) // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - fn admin_destroy_disputed_market(a: u32, d: u32, _o: u32, _c: u32, _r: u32) -> Weight { - (176_251_000 as Weight) - // Standard Error: 14_000 - .saturating_add((37_179_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 218_000 - .saturating_add((6_261_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + fn admin_destroy_disputed_market(a: u32, d: u32, o: u32, c: u32, r: u32) -> Weight { + Weight::from_ref_time(107_238_514) + // Standard Error: 41_363 + .saturating_add(Weight::from_ref_time(29_341_596).saturating_mul(a.into())) + // Standard Error: 472_622 + .saturating_add(Weight::from_ref_time(27_719_415).saturating_mul(d.into())) + // Standard Error: 41_159 + .saturating_add(Weight::from_ref_time(628_912).saturating_mul(o.into())) + // Standard Error: 41_159 + .saturating_add(Weight::from_ref_time(225_352).saturating_mul(c.into())) + // Standard Error: 41_159 + .saturating_add(Weight::from_ref_time(116_924).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(d.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(d.into()))) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) @@ -111,121 +120,114 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: Tokens TotalIssuance (r:2 w:2) // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) // Storage: PredictionMarkets Disputes (r:0 w:1) - fn admin_destroy_reported_market(a: u32, _o: u32, c: u32, _r: u32) -> Weight { - (198_500_000 as Weight) - // Standard Error: 16_000 - .saturating_add((37_042_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 15_000 - .saturating_add((218_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + fn admin_destroy_reported_market(a: u32, o: u32, _c: u32, _r: u32) -> Weight { + Weight::from_ref_time(318_190_722) + // Standard Error: 36_412 + .saturating_add(Weight::from_ref_time(28_170_443).saturating_mul(a.into())) + // Standard Error: 36_230 + .saturating_add(Weight::from_ref_time(110_146).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerOpenTimeFrame (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) fn admin_move_market_to_closed(_o: u32, c: u32) -> Weight { - (62_877_000 as Weight) - // Standard Error: 0 - .saturating_add((71_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(79_287_004) + // Standard Error: 2_160 + .saturating_add(Weight::from_ref_time(1_879).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) - // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) + // Storage: PredictionMarkets Disputes (r:0 w:1) fn admin_move_market_to_resolved_scalar_reported(r: u32) -> Weight { - (100_354_000 as Weight) - // Standard Error: 0 - .saturating_add((80_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(113_444_507) + // Standard Error: 3_870 + .saturating_add(Weight::from_ref_time(50_492).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) - // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) + // Storage: PredictionMarkets Disputes (r:0 w:1) fn admin_move_market_to_resolved_categorical_reported(r: u32) -> Weight { - (201_548_000 as Weight) - // Standard Error: 3_000 - .saturating_add((100_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(177_369_441) + // Standard Error: 5_024 + .saturating_add(Weight::from_ref_time(916).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets Disputes (r:1 w:1) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - // Storage: Balances Reserves (r:7 w:7) + // Storage: Balances Reserves (r:2 w:2) // Storage: GlobalDisputes Winners (r:1 w:0) - // Storage: Authorized AuthorizedOutcomeReports (r:1 w:0) - // Storage: System Account (r:7 w:7) + // Storage: System Account (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) - fn admin_move_market_to_resolved_scalar_disputed(r: u32, d: u32) -> Weight { - (132_066_000 as Weight) - // Standard Error: 1_000 - .saturating_add((120_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 21_000 - .saturating_add((30_950_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(d as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(d as Weight))) + fn admin_move_market_to_resolved_scalar_disputed(r: u32) -> Weight { + Weight::from_ref_time(176_005_979) + // Standard Error: 5_651 + .saturating_add(Weight::from_ref_time(11_093).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets Disputes (r:1 w:1) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - // Storage: Balances Reserves (r:7 w:7) + // Storage: Balances Reserves (r:2 w:2) // Storage: GlobalDisputes Winners (r:1 w:0) - // Storage: Authorized AuthorizedOutcomeReports (r:1 w:0) - // Storage: System Account (r:6 w:6) + // Storage: System Account (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) - fn admin_move_market_to_resolved_categorical_disputed(r: u32, d: u32) -> Weight { - (227_185_000 as Weight) - // Standard Error: 6_000 - .saturating_add((69_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 90_000 - .saturating_add((33_824_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(d as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(d as Weight))) + fn admin_move_market_to_resolved_categorical_disputed(r: u32) -> Weight { + Weight::from_ref_time(238_247_311) + // Standard Error: 6_613 + .saturating_add(Weight::from_ref_time(35_386).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsForEdit (r:1 w:0) // Storage: Balances Reserves (r:1 w:1) fn approve_market() -> Weight { - (62_900_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(73_620_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: PredictionMarkets MarketIdsForEdit (r:1 w:1) fn request_edit(r: u32) -> Weight { - (37_307_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(42_488_817) + // Standard Error: 95 + .saturating_add(Weight::from_ref_time(1_055).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: Tokens TotalIssuance (r:2 w:2) fn buy_complete_set(a: u32) -> Weight { - (63_624_000 as Weight) - // Standard Error: 12_000 - .saturating_add((26_565_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(85_601_158) + // Standard Error: 22_842 + .saturating_add(Weight::from_ref_time(19_933_921).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Timestamp Now (r:1 w:0) // Storage: Balances Reserves (r:1 w:1) @@ -233,22 +235,22 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) // Storage: MarketCommons Markets (r:0 w:1) fn create_market(m: u32) -> Weight { - (75_202_000 as Weight) - // Standard Error: 3_000 - .saturating_add((53_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(79_694_906) + // Standard Error: 3_703 + .saturating_add(Weight::from_ref_time(38_813).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: PredictionMarkets MarketIdsForEdit (r:1 w:1) // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn edit_market(m: u32) -> Weight { - (64_080_000 as Weight) - // Standard Error: 0 - .saturating_add((117_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(69_089_314) + // Standard Error: 2_466 + .saturating_add(Weight::from_ref_time(61_240).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: Swaps NextPoolId (r:1 w:1) @@ -259,16 +261,14 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: PredictionMarkets MarketIdsPerOpenTimeFrame (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:1) // Storage: Swaps Pools (r:0 w:1) - fn deploy_swap_pool_for_market_future_pool(a: u32, o: u32) -> Weight { - (108_283_000 as Weight) - // Standard Error: 14_000 - .saturating_add((42_613_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 13_000 - .saturating_add((322_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + fn deploy_swap_pool_for_market_future_pool(a: u32, _o: u32) -> Weight { + Weight::from_ref_time(204_259_432) + // Standard Error: 39_253 + .saturating_add(Weight::from_ref_time(32_676_903).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: Swaps NextPoolId (r:1 w:1) @@ -279,92 +279,86 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: MarketCommons MarketPool (r:1 w:1) // Storage: Swaps Pools (r:0 w:1) fn deploy_swap_pool_for_market_open_pool(a: u32) -> Weight { - (136_673_000 as Weight) - // Standard Error: 16_000 - .saturating_add((42_795_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(148_687_190) + // Standard Error: 35_655 + .saturating_add(Weight::from_ref_time(33_156_557).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: PredictionMarkets Disputes (r:1 w:0) // Storage: GlobalDisputes Winners (r:1 w:1) // Storage: GlobalDisputes Outcomes (r:7 w:7) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:2 w:2) - fn start_global_dispute(_m: u32) -> Weight { - (143_932_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(10 as Weight)) + fn start_global_dispute(m: u32, n: u32) -> Weight { + Weight::from_ref_time(134_890_624) + // Standard Error: 4_075 + .saturating_add(Weight::from_ref_time(7_847).saturating_mul(m.into())) + // Standard Error: 4_075 + .saturating_add(Weight::from_ref_time(48_957).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(10)) } // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) - // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - fn dispute_authorized(d: u32, b: u32) -> Weight { - (79_841_000 as Weight) - // Standard Error: 17_000 - .saturating_add((1_894_000 as Weight).saturating_mul(d as Weight)) - // Standard Error: 1_000 - .saturating_add((82_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + fn dispute_authorized() -> Weight { + Weight::from_ref_time(82_290_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: Balances Reserves (r:1 w:1) // Storage: MarketCommons Markets (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) // Storage: PredictionMarkets MarketIdsForEdit (r:0 w:1) fn handle_expired_advised_market() -> Weight { - (61_850_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(79_701_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) - // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) - // Storage: MarketCommons Markets (r:1 w:1) + // Storage: PredictionMarkets Disputes (r:0 w:1) fn internal_resolve_categorical_reported() -> Weight { - (172_370_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(149_241_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } + // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) // Storage: PredictionMarkets Disputes (r:1 w:1) + // Storage: GlobalDisputes Winners (r:1 w:0) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) - // Storage: MarketCommons Markets (r:1 w:1) - // Storage: GlobalDisputes Winners (r:1 w:0) - // Storage: Authorized AuthorizedOutcomeReports (r:1 w:0) - // Storage: System Account (r:1 w:1) - fn internal_resolve_categorical_disputed(d: u32) -> Weight { - (183_852_000 as Weight) - // Standard Error: 82_000 - .saturating_add((24_286_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + fn internal_resolve_categorical_disputed() -> Weight { + Weight::from_ref_time(196_701_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) - // Storage: PredictionMarkets Disputes (r:1 w:1) // Storage: MarketCommons MarketPool (r:1 w:0) - // Storage: MarketCommons Markets (r:1 w:1) + // Storage: PredictionMarkets Disputes (r:0 w:1) fn internal_resolve_scalar_reported() -> Weight { - (73_231_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(90_760_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } + // Storage: MarketCommons Markets (r:1 w:1) // Storage: Balances Reserves (r:1 w:1) // Storage: PredictionMarkets Disputes (r:1 w:1) - // Storage: MarketCommons MarketPool (r:1 w:0) - // Storage: MarketCommons Markets (r:1 w:1) // Storage: GlobalDisputes Winners (r:1 w:0) - // Storage: Authorized AuthorizedOutcomeReports (r:1 w:0) + // Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) // Storage: System Account (r:1 w:1) - fn internal_resolve_scalar_disputed(d: u32) -> Weight { - (90_052_000 as Weight) - // Standard Error: 74_000 - .saturating_add((21_265_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Storage: MarketCommons MarketPool (r:1 w:0) + fn internal_resolve_scalar_disputed() -> Weight { + Weight::from_ref_time(150_781_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Timestamp Now (r:1 w:0) // Storage: PredictionMarkets MarketsCollectingSubsidy (r:1 w:1) @@ -376,35 +370,35 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) fn on_initialize_resolve_overhead() -> Weight { - (45_170_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(39_020_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: PredictionMarkets MarketsCollectingSubsidy (r:1 w:1) fn process_subsidy_collecting_markets_raw(a: u32) -> Weight { - (5_577_000 as Weight) - // Standard Error: 8_000 - .saturating_add((507_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_926_513) + // Standard Error: 3_860 + .saturating_add(Weight::from_ref_time(277_807).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: Tokens Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Tokens TotalIssuance (r:1 w:1) fn redeem_shares_categorical() -> Weight { - (130_241_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(119_160_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: Tokens Accounts (r:2 w:2) // Storage: System Account (r:1 w:1) // Storage: Tokens TotalIssuance (r:2 w:2) fn redeem_shares_scalar() -> Weight { - (144_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(136_620_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: PredictionMarkets MarketIdsPerOpenTimeFrame (r:1 w:1) @@ -412,38 +406,36 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: Balances Reserves (r:1 w:1) // Storage: PredictionMarkets MarketIdsForEdit (r:0 w:1) fn reject_market(c: u32, o: u32, r: u32) -> Weight { - (89_918_000 as Weight) - // Standard Error: 0 - .saturating_add((76_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 0 - .saturating_add((81_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(120_686_900) + // Standard Error: 3_165 + .saturating_add(Weight::from_ref_time(32_234).saturating_mul(c.into())) + // Standard Error: 3_165 + .saturating_add(Weight::from_ref_time(60_783).saturating_mul(o.into())) + // Standard Error: 194 + .saturating_add(Weight::from_ref_time(1_535).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: MarketCommons Markets (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - fn report(m: u32) -> Weight { - (50_223_000 as Weight) - // Standard Error: 0 - .saturating_add((16_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn report(_m: u32) -> Weight { + Weight::from_ref_time(58_882_549) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) // Storage: Tokens TotalIssuance (r:2 w:2) fn sell_complete_set(a: u32) -> Weight { - (48_611_000 as Weight) - // Standard Error: 12_000 - .saturating_add((33_331_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(75_333_021) + // Standard Error: 42_233 + .saturating_add(Weight::from_ref_time(27_741_358).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Swaps NextPoolId (r:1 w:1) // Storage: RikiddoSigmoidFeeMarketEma RikiddoPerPool (r:1 w:1) @@ -452,44 +444,44 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: PredictionMarkets MarketsCollectingSubsidy (r:1 w:1) // Storage: Swaps Pools (r:0 w:1) fn start_subsidy(a: u32) -> Weight { - (57_592_000 as Weight) - // Standard Error: 2_000 - .saturating_add((53_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(59_895_192) + // Standard Error: 2_305 + .saturating_add(Weight::from_ref_time(63_978).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: PredictionMarkets MarketIdsPerOpenBlock (r:1 w:1) // Storage: MarketCommons Markets (r:32 w:0) // Storage: PredictionMarkets MarketIdsPerOpenTimeFrame (r:1 w:1) fn market_status_manager(b: u32, f: u32) -> Weight { - (27_651_000 as Weight) - // Standard Error: 3_000 - .saturating_add((6_365_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 3_000 - .saturating_add((6_378_000 as Weight).saturating_mul(f as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(f as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(54_851_745) + // Standard Error: 3_638 + .saturating_add(Weight::from_ref_time(3_397_992).saturating_mul(b.into())) + // Standard Error: 3_638 + .saturating_add(Weight::from_ref_time(3_372_304).saturating_mul(f.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(f.into()))) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) // Storage: MarketCommons Markets (r:32 w:0) // Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) fn market_resolution_manager(r: u32, d: u32) -> Weight { - (29_736_000 as Weight) - // Standard Error: 3_000 - .saturating_add((6_353_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 3_000 - .saturating_add((6_344_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(d as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(51_119_835) + // Standard Error: 7_314 + .saturating_add(Weight::from_ref_time(3_513_755).saturating_mul(r.into())) + // Standard Error: 7_314 + .saturating_add(Weight::from_ref_time(3_510_880).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: PredictionMarkets MarketsCollectingSubsidy (r:1 w:1) fn process_subsidy_collecting_markets_dummy() -> Weight { - (5_470_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(8_780_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/rikiddo/Cargo.toml b/zrml/rikiddo/Cargo.toml index e47e223d0..15079b971 100644 --- a/zrml/rikiddo/Cargo.toml +++ b/zrml/rikiddo/Cargo.toml @@ -1,16 +1,16 @@ [dependencies] arbitrary = { version = "1.0.1", features = ["derive"], optional = true } cfg-if = { version = "1.0.0", default-features = false } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } hashbrown = { default-features = true, version = "0.11" } -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-core = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-core = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } substrate-fixed = { default-features = false, features = ["serde"], git = "https://github.com/encointer/substrate-fixed" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } @@ -42,4 +42,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-rikiddo" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/rikiddo/fuzz/Cargo.toml b/zrml/rikiddo/fuzz/Cargo.toml index 7abae1f10..5c28dfedf 100644 --- a/zrml/rikiddo/fuzz/Cargo.toml +++ b/zrml/rikiddo/fuzz/Cargo.toml @@ -72,8 +72,8 @@ test = false [dependencies] arbitrary = { features = ["derive"], version = "1.0" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } libfuzzer-sys = "0.4" substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed" } zrml-rikiddo = { features = ["arbitrary", "mock"], path = ".." } diff --git a/zrml/rikiddo/fuzz/balance_to_fixedu_conversion.rs b/zrml/rikiddo/fuzz/balance_to_fixedu_conversion.rs index 5b3c61745..2010927a1 100644 --- a/zrml/rikiddo/fuzz/balance_to_fixedu_conversion.rs +++ b/zrml/rikiddo/fuzz/balance_to_fixedu_conversion.rs @@ -18,7 +18,7 @@ //! Fuzz test: Conversion Balance -> FixedU #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/ema_market_volume_estimate_ema.rs b/zrml/rikiddo/fuzz/ema_market_volume_estimate_ema.rs index 08ae2375f..add40ca7f 100644 --- a/zrml/rikiddo/fuzz/ema_market_volume_estimate_ema.rs +++ b/zrml/rikiddo/fuzz/ema_market_volume_estimate_ema.rs @@ -19,7 +19,7 @@ //! -> Configure the struct in a way that it estimates the ema at the second update, update #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/ema_market_volume_first_state.rs b/zrml/rikiddo/fuzz/ema_market_volume_first_state.rs index 107bdbbeb..122aa1124 100644 --- a/zrml/rikiddo/fuzz/ema_market_volume_first_state.rs +++ b/zrml/rikiddo/fuzz/ema_market_volume_first_state.rs @@ -19,7 +19,7 @@ //! -> update_volume #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/ema_market_volume_second_state.rs b/zrml/rikiddo/fuzz/ema_market_volume_second_state.rs index 90a08a350..c6f8bf791 100644 --- a/zrml/rikiddo/fuzz/ema_market_volume_second_state.rs +++ b/zrml/rikiddo/fuzz/ema_market_volume_second_state.rs @@ -19,7 +19,7 @@ //! -> change state (update), update, get ema, clear #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/ema_market_volume_third_state.rs b/zrml/rikiddo/fuzz/ema_market_volume_third_state.rs index 08eb4d1bf..8c26b8b8e 100644 --- a/zrml/rikiddo/fuzz/ema_market_volume_third_state.rs +++ b/zrml/rikiddo/fuzz/ema_market_volume_third_state.rs @@ -19,7 +19,7 @@ //! -> change state (two updates with specific configuration), update #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/fee_sigmoid.rs b/zrml/rikiddo/fuzz/fee_sigmoid.rs index 16823983b..6277c0b70 100644 --- a/zrml/rikiddo/fuzz/fee_sigmoid.rs +++ b/zrml/rikiddo/fuzz/fee_sigmoid.rs @@ -18,7 +18,7 @@ //! Fuzz test: FeeSigmoid.calculate() is called #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/fixedi_to_fixedu_conversion.rs b/zrml/rikiddo/fuzz/fixedi_to_fixedu_conversion.rs index 6a3f73e1e..98ff02f48 100644 --- a/zrml/rikiddo/fuzz/fixedi_to_fixedu_conversion.rs +++ b/zrml/rikiddo/fuzz/fixedi_to_fixedu_conversion.rs @@ -18,7 +18,7 @@ //! Fuzz test: Conversion FixedI -> FixedU #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/fixedu_to_balance_conversion.rs b/zrml/rikiddo/fuzz/fixedu_to_balance_conversion.rs index f902c61d3..cc2c3b5a1 100644 --- a/zrml/rikiddo/fuzz/fixedu_to_balance_conversion.rs +++ b/zrml/rikiddo/fuzz/fixedu_to_balance_conversion.rs @@ -18,7 +18,7 @@ //! Fuzz test: Conversion Balance -> FixedU #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/fixedu_to_fixedi_conversion.rs b/zrml/rikiddo/fuzz/fixedu_to_fixedi_conversion.rs index c0e631f88..19792f328 100644 --- a/zrml/rikiddo/fuzz/fixedu_to_fixedi_conversion.rs +++ b/zrml/rikiddo/fuzz/fixedu_to_fixedi_conversion.rs @@ -18,7 +18,7 @@ //! Fuzz test: Conversion FixedU -> FixedI #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![no_main] diff --git a/zrml/rikiddo/fuzz/rikiddo_pallet.rs b/zrml/rikiddo/fuzz/rikiddo_pallet.rs index c88f881c6..5fd0afc0a 100644 --- a/zrml/rikiddo/fuzz/rikiddo_pallet.rs +++ b/zrml/rikiddo/fuzz/rikiddo_pallet.rs @@ -19,7 +19,7 @@ //! -> create, force fee by multiple update_volume, cost, price, all_prices, clear, destroy #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![allow(clippy::type_complexity)] #![no_main] diff --git a/zrml/rikiddo/fuzz/rikiddo_with_calculated_fee.rs b/zrml/rikiddo/fuzz/rikiddo_with_calculated_fee.rs index 43a3d1444..0ae9b4679 100644 --- a/zrml/rikiddo/fuzz/rikiddo_with_calculated_fee.rs +++ b/zrml/rikiddo/fuzz/rikiddo_with_calculated_fee.rs @@ -19,7 +19,7 @@ //! -> force EmaMarketVolume, cost, price, all_prices #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![allow(clippy::type_complexity)] #![no_main] diff --git a/zrml/rikiddo/fuzz/rikiddo_with_initial_fee.rs b/zrml/rikiddo/fuzz/rikiddo_with_initial_fee.rs index 40b2f7c23..01ea3ab27 100644 --- a/zrml/rikiddo/fuzz/rikiddo_with_initial_fee.rs +++ b/zrml/rikiddo/fuzz/rikiddo_with_initial_fee.rs @@ -18,7 +18,7 @@ //! Fuzz test: Rikiddo is called with initial fee -> cost, price, all_prices, clear #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![allow(clippy::type_complexity)] #![no_main] diff --git a/zrml/rikiddo/src/lib.rs b/zrml/rikiddo/src/lib.rs index 811656585..be7f94817 100644 --- a/zrml/rikiddo/src/lib.rs +++ b/zrml/rikiddo/src/lib.rs @@ -18,7 +18,7 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] // This is required to be able to use the derive(Arbitrary) macro. -#![cfg_attr(feature = "arbitrary", allow(clippy::integer_arithmetic))] +#![cfg_attr(feature = "arbitrary", allow(clippy::arithmetic_side_effects))] #![deny(missing_docs)] extern crate alloc; diff --git a/zrml/rikiddo/src/mock.rs b/zrml/rikiddo/src/mock.rs index 3b951a497..07d089867 100644 --- a/zrml/rikiddo/src/mock.rs +++ b/zrml/rikiddo/src/mock.rs @@ -17,7 +17,7 @@ #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![cfg(feature = "mock")] #![allow(missing_docs)] @@ -59,7 +59,7 @@ construct_runtime!( { Balances: pallet_balances::{Call, Config, Event, Pallet, Storage}, Rikiddo: crate::{Pallet, Storage}, - System: frame_system::{Config, Event, Pallet, Storage}, + System: frame_system::{Call, Config, Event, Pallet, Storage}, Timestamp: pallet_timestamp::{Call, Pallet, Storage, Inherent}, } ); @@ -87,9 +87,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -99,7 +99,7 @@ impl frame_system::Config for Runtime { type OnKilledAccount = (); type OnNewAccount = (); type OnSetCode = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -110,7 +110,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxReserves = MaxReserves; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = (); diff --git a/zrml/rikiddo/src/tests/pallet.rs b/zrml/rikiddo/src/tests/pallet.rs index b7242b4bb..c734068d2 100644 --- a/zrml/rikiddo/src/tests/pallet.rs +++ b/zrml/rikiddo/src/tests/pallet.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/zrml/rikiddo/src/types.rs b/zrml/rikiddo/src/types.rs index cbca959b7..cff58f86b 100644 --- a/zrml/rikiddo/src/types.rs +++ b/zrml/rikiddo/src/types.rs @@ -58,7 +58,7 @@ pub struct TimestampedVolume { #[cfg(feature = "arbitrary")] macro_rules! impl_arbitrary_for_timestamped_volume { ( $t:ident, $LeEqU:ident, $p:ty ) => { - #[allow(clippy::integer_arithmetic)] + #[allow(clippy::arithmetic_side_effects)] impl<'a, Frac> Arbitrary<'a> for TimestampedVolume<$t> where Frac: $LeEqU, diff --git a/zrml/rikiddo/src/types/sigmoid_fee.rs b/zrml/rikiddo/src/types/sigmoid_fee.rs index 437ec2373..d122c64ec 100644 --- a/zrml/rikiddo/src/types/sigmoid_fee.rs +++ b/zrml/rikiddo/src/types/sigmoid_fee.rs @@ -68,7 +68,7 @@ pub struct FeeSigmoidConfig { #[cfg(feature = "arbitrary")] macro_rules! impl_arbitrary_for_fee_sigmoid_config { ( $t:ident, $LeEqU:ident, $p:ty ) => { - #[allow(clippy::integer_arithmetic)] + #[allow(clippy::arithmetic_side_effects)] impl<'a, Frac> Arbitrary<'a> for FeeSigmoidConfig<$t> where Frac: $LeEqU, diff --git a/zrml/simple-disputes/Cargo.toml b/zrml/simple-disputes/Cargo.toml index ee00bd310..d61fd1c51 100644 --- a/zrml/simple-disputes/Cargo.toml +++ b/zrml/simple-disputes/Cargo.toml @@ -1,17 +1,17 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-market-commons = { default-features = false, path = "../market-commons" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -38,4 +38,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-simple-disputes" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/simple-disputes/src/lib.rs b/zrml/simple-disputes/src/lib.rs index 2609fe844..1db2ff3f9 100644 --- a/zrml/simple-disputes/src/lib.rs +++ b/zrml/simple-disputes/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -33,13 +34,16 @@ mod pallet { use core::marker::PhantomData; use frame_support::{ dispatch::DispatchResult, + ensure, traits::{Currency, Get, Hooks, IsType}, PalletId, }; - use sp_runtime::DispatchError; + use sp_runtime::{traits::Saturating, DispatchError}; use zeitgeist_primitives::{ - traits::DisputeApi, - types::{Market, MarketDispute, MarketDisputeMechanism, MarketStatus, OutcomeReport}, + traits::{DisputeApi, DisputeResolutionApi}, + types::{ + Asset, Market, MarketDispute, MarketDisputeMechanism, MarketStatus, OutcomeReport, + }, }; use zrml_market_commons::MarketCommonsPalletApi; @@ -55,6 +59,7 @@ mod pallet { BalanceOf, ::BlockNumber, MomentOf, + Asset>, >; #[pallet::call] @@ -63,13 +68,17 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Event - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + type DisputeResolution: DisputeResolutionApi< + AccountId = Self::AccountId, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + Moment = MomentOf, + >; /// The identifier of individual markets. - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - >; + type MarketCommons: MarketCommonsPalletApi; /// The pallet identifier. #[pallet::constant] @@ -93,6 +102,33 @@ mod pallet { #[pallet::hooks] impl Hooks for Pallet {} + impl Pallet + where + T: Config, + { + fn get_auto_resolve( + disputes: &[MarketDispute], + market: &MarketOf, + ) -> Option { + disputes.last().map(|last_dispute| { + last_dispute.at.saturating_add(market.deadlines.dispute_duration) + }) + } + + fn remove_auto_resolve( + disputes: &[MarketDispute], + market_id: &MarketIdOf, + market: &MarketOf, + ) { + if let Some(dispute_duration_ends_at_block) = Self::get_auto_resolve(disputes, market) { + T::DisputeResolution::remove_auto_resolve( + market_id, + dispute_duration_ends_at_block, + ); + } + } + } + impl DisputeApi for Pallet where T: Config, @@ -102,16 +138,23 @@ mod pallet { type BlockNumber = T::BlockNumber; type MarketId = MarketIdOf; type Moment = MomentOf; - type Origin = T::Origin; + type Origin = T::RuntimeOrigin; fn on_dispute( - _: &[MarketDispute], - _: &Self::MarketId, + disputes: &[MarketDispute], + market_id: &Self::MarketId, market: &MarketOf, ) -> DispatchResult { - if market.dispute_mechanism != MarketDisputeMechanism::SimpleDisputes { - return Err(Error::::MarketDoesNotHaveSimpleDisputesMechanism.into()); - } + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::SimpleDisputes, + Error::::MarketDoesNotHaveSimpleDisputesMechanism + ); + Self::remove_auto_resolve(disputes, market_id, market); + let curr_block_num = >::block_number(); + // each dispute resets dispute_duration + let dispute_duration_ends_at_block = + curr_block_num.saturating_add(market.deadlines.dispute_duration); + T::DisputeResolution::add_auto_resolve(market_id, dispute_duration_ends_at_block)?; Ok(()) } @@ -120,12 +163,11 @@ mod pallet { _: &Self::MarketId, market: &MarketOf, ) -> Result, DispatchError> { - if market.dispute_mechanism != MarketDisputeMechanism::SimpleDisputes { - return Err(Error::::MarketDoesNotHaveSimpleDisputesMechanism.into()); - } - if market.status != MarketStatus::Disputed { - return Err(Error::::InvalidMarketStatus.into()); - } + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::SimpleDisputes, + Error::::MarketDoesNotHaveSimpleDisputesMechanism + ); + ensure!(market.status == MarketStatus::Disputed, Error::::InvalidMarketStatus); if let Some(last_dispute) = disputes.last() { Ok(Some(last_dispute.outcome.clone())) @@ -133,6 +175,31 @@ mod pallet { Err(Error::::InvalidMarketStatus.into()) } } + + fn get_auto_resolve( + disputes: &[MarketDispute], + _: &Self::MarketId, + market: &MarketOf, + ) -> Result, DispatchError> { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::SimpleDisputes, + Error::::MarketDoesNotHaveSimpleDisputesMechanism + ); + Ok(Self::get_auto_resolve(disputes, market)) + } + + fn has_failed( + _: &[MarketDispute], + _: &Self::MarketId, + market: &MarketOf, + ) -> Result { + ensure!( + market.dispute_mechanism == MarketDisputeMechanism::SimpleDisputes, + Error::::MarketDoesNotHaveSimpleDisputesMechanism + ); + // TODO when does simple disputes fail? + Ok(false) + } } impl SimpleDisputesPalletApi for Pallet where T: Config {} diff --git a/zrml/simple-disputes/src/mock.rs b/zrml/simple-disputes/src/mock.rs index bc03f9baa..c0848647b 100644 --- a/zrml/simple-disputes/src/mock.rs +++ b/zrml/simple-disputes/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,12 @@ #![cfg(test)] use crate::{self as zrml_simple_disputes}; -use frame_support::{construct_runtime, traits::Everything}; +use frame_support::{ + construct_runtime, + pallet_prelude::{DispatchError, Weight}, + traits::Everything, + BoundedVec, +}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, @@ -27,9 +33,10 @@ use zeitgeist_primitives::{ constants::mock::{ BlockHashCount, MaxReserves, MinimumPeriod, PmPalletId, SimpleDisputesPalletId, }, + traits::DisputeResolutionApi, types::{ - AccountIdTest, Balance, BlockNumber, BlockTest, Hash, Index, MarketId, Moment, - UncheckedExtrinsicTest, + AccountIdTest, Asset, Balance, BlockNumber, BlockTest, Hash, Index, Market, MarketDispute, + MarketId, Moment, UncheckedExtrinsicTest, }, }; @@ -48,8 +55,55 @@ construct_runtime!( } ); +// NoopResolution implements DisputeResolutionApi with no-ops. +pub struct NoopResolution; + +impl DisputeResolutionApi for NoopResolution { + type AccountId = AccountIdTest; + type Balance = Balance; + type BlockNumber = BlockNumber; + type MarketId = MarketId; + type MaxDisputes = u32; + type Moment = Moment; + + fn resolve( + _market_id: &Self::MarketId, + _market: &Market< + Self::AccountId, + Self::Balance, + Self::BlockNumber, + Self::Moment, + Asset, + >, + ) -> Result { + Ok(Weight::zero()) + } + + fn add_auto_resolve( + _market_id: &Self::MarketId, + _resolve_at: Self::BlockNumber, + ) -> Result { + Ok(0u32) + } + + fn auto_resolve_exists(_market_id: &Self::MarketId, _resolve_at: Self::BlockNumber) -> bool { + false + } + + fn remove_auto_resolve(_market_id: &Self::MarketId, _resolve_at: Self::BlockNumber) -> u32 { + 0u32 + } + + fn get_disputes( + _market_id: &Self::MarketId, + ) -> BoundedVec, Self::MaxDisputes> { + Default::default() + } +} + impl crate::Config for Runtime { - type Event = (); + type RuntimeEvent = (); + type DisputeResolution = NoopResolution; type MarketCommons = MarketCommons; type PalletId = SimpleDisputesPalletId; } @@ -62,9 +116,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = (); + type RuntimeEvent = (); type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -73,7 +127,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -85,7 +139,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = (); + type RuntimeEvent = (); type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/simple-disputes/src/tests.rs b/zrml/simple-disputes/src/tests.rs index 251377533..f9e9d87af 100644 --- a/zrml/simple-disputes/src/tests.rs +++ b/zrml/simple-disputes/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -25,12 +26,13 @@ use frame_support::assert_noop; use zeitgeist_primitives::{ traits::DisputeApi, types::{ - Deadlines, Market, MarketBonds, MarketCreation, MarketDispute, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, OutcomeReport, ScoringRule, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDispute, + MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, OutcomeReport, ScoringRule, }, }; const DEFAULT_MARKET: MarketOf = Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: 0, @@ -44,7 +46,7 @@ const DEFAULT_MARKET: MarketOf = Market { resolved_outcome: None, scoring_rule: ScoringRule::CPMM, status: MarketStatus::Disputed, - bonds: MarketBonds { creation: None, oracle: None }, + bonds: MarketBonds { creation: None, oracle: None, outsider: None }, }; #[test] diff --git a/zrml/styx/Cargo.toml b/zrml/styx/Cargo.toml index 1575a9989..b2e55bb25 100644 --- a/zrml/styx/Cargo.toml +++ b/zrml/styx/Cargo.toml @@ -1,16 +1,16 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } [dev-dependencies] -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate" } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, features = ["mock"], path = "../../primitives" } [features] @@ -36,4 +36,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-styx" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/styx/src/benchmarks.rs b/zrml/styx/src/benchmarks.rs index 684663da9..6ae9e0223 100644 --- a/zrml/styx/src/benchmarks.rs +++ b/zrml/styx/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,7 +18,7 @@ #![allow( // Auto-generated code is a no man's land - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] #![allow(clippy::type_complexity)] #![cfg(feature = "runtime-benchmarks")] diff --git a/zrml/styx/src/lib.rs b/zrml/styx/src/lib.rs index d1a6164e0..e00713303 100644 --- a/zrml/styx/src/lib.rs +++ b/zrml/styx/src/lib.rs @@ -38,9 +38,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The origin that is allowed to set the amount burned when crossing Styx. - type SetBurnAmountOrigin: EnsureOrigin; + type SetBurnAmountOrigin: EnsureOrigin; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type Currency: Currency; diff --git a/zrml/styx/src/mock.rs b/zrml/styx/src/mock.rs index b147fe247..80dd2a2f8 100644 --- a/zrml/styx/src/mock.rs +++ b/zrml/styx/src/mock.rs @@ -53,7 +53,7 @@ construct_runtime!( impl crate::Config for Runtime { type Currency = Balances; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type SetBurnAmountOrigin = EnsureSignedBy; type WeightInfo = zrml_styx::weights::WeightInfo; } @@ -66,9 +66,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -77,7 +77,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -89,7 +89,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = (); type MaxLocks = (); type MaxReserves = MaxReserves; diff --git a/zrml/styx/src/tests.rs b/zrml/styx/src/tests.rs index 32b1fb1e1..dfcc0bf1a 100644 --- a/zrml/styx/src/tests.rs +++ b/zrml/styx/src/tests.rs @@ -25,9 +25,9 @@ fn cross_slashes_funds_and_stores_crossing() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); let burn_amount = crate::BurnAmount::::get(); - let original_balance = Balances::free_balance(&ALICE); - assert_ok!(Styx::cross(Origin::signed(ALICE))); - let balance_after_crossing = Balances::free_balance(&ALICE); + let original_balance = Balances::free_balance(ALICE); + assert_ok!(Styx::cross(RuntimeOrigin::signed(ALICE))); + let balance_after_crossing = Balances::free_balance(ALICE); let diff = original_balance - balance_after_crossing; assert!(Crossings::::contains_key(ALICE)); assert_eq!(diff, burn_amount); @@ -38,8 +38,11 @@ fn cross_slashes_funds_and_stores_crossing() { fn account_should_only_be_able_to_cross_once() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_ok!(Styx::cross(Origin::signed(ALICE))); - assert_noop!(Styx::cross(Origin::signed(ALICE)), Error::::HasAlreadyCrossed); + assert_ok!(Styx::cross(RuntimeOrigin::signed(ALICE))); + assert_noop!( + Styx::cross(RuntimeOrigin::signed(ALICE)), + Error::::HasAlreadyCrossed + ); }); } @@ -47,7 +50,7 @@ fn account_should_only_be_able_to_cross_once() { fn should_set_burn_amount() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_ok!(Styx::set_burn_amount(Origin::signed(SUDO), 144u128)); + assert_ok!(Styx::set_burn_amount(RuntimeOrigin::signed(SUDO), 144u128)); System::assert_last_event(Event::CrossingFeeChanged(144u128).into()); assert_eq!(crate::BurnAmount::::get(), 144u128); }); @@ -57,7 +60,7 @@ fn should_set_burn_amount() { fn set_burn_amount_should_fail_with_unathorized_caller() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_noop!(Styx::set_burn_amount(Origin::signed(9999), 144u128), BadOrigin); + assert_noop!(Styx::set_burn_amount(RuntimeOrigin::signed(9999), 144u128), BadOrigin); }); } @@ -65,9 +68,9 @@ fn set_burn_amount_should_fail_with_unathorized_caller() { fn account_should_not_cross_without_sufficient_funds() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_ok!(Balances::set_balance(Origin::root(), ALICE, 0, 0)); + assert_ok!(Balances::set_balance(RuntimeOrigin::root(), ALICE, 0, 0)); assert_noop!( - Styx::cross(Origin::signed(ALICE)), + Styx::cross(RuntimeOrigin::signed(ALICE)), Error::::FundDoesNotHaveEnoughFreeBalance ); }); @@ -77,7 +80,7 @@ fn account_should_not_cross_without_sufficient_funds() { fn should_emit_account_crossed_event_with_correct_value() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - assert_ok!(Styx::cross(Origin::signed(ALICE))); + assert_ok!(Styx::cross(RuntimeOrigin::signed(ALICE))); System::assert_last_event( Event::AccountCrossed(ALICE, crate::BurnAmount::::get()).into(), ); diff --git a/zrml/styx/src/weights.rs b/zrml/styx/src/weights.rs index 8112bbfa2..095ede0e6 100644 --- a/zrml/styx/src/weights.rs +++ b/zrml/styx/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_styx //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -55,12 +56,12 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: Styx Crossings (r:1 w:1) // Storage: Styx BurnAmount (r:1 w:0) fn cross() -> Weight { - (54_390_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(63_231_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Styx BurnAmount (r:0 w:1) fn set_burn_amount() -> Weight { - (22_050_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(23_250_000).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/swaps/Cargo.toml b/zrml/swaps/Cargo.toml index 0cf02c871..bdb90fc5f 100644 --- a/zrml/swaps/Cargo.toml +++ b/zrml/swaps/Cargo.toml @@ -1,11 +1,11 @@ [dependencies] -frame-benchmarking = { branch = "polkadot-v0.9.26", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -frame-system = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +frame-benchmarking = { branch = "polkadot-v0.9.32", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-system = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } substrate-fixed = { default-features = false, git = "https://github.com/encointer/substrate-fixed" } zeitgeist-primitives = { default-features = false, path = "../../primitives" } zrml-liquidity-mining = { default-features = false, path = "../liquidity-mining" } @@ -14,12 +14,12 @@ zrml-rikiddo = { default-features = false, path = "../rikiddo" } # Mock -orml-currencies = { branch = "polkadot-v0.9.26", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -orml-tokens = { branch = "polkadot-v0.9.26", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } -pallet-balances = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -pallet-timestamp = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-api = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } -sp-io = { branch = "polkadot-v0.9.26", git = "https://github.com/paritytech/substrate", optional = true } +orml-currencies = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +orml-tokens = { branch = "polkadot-v0.9.32", git = "https://github.com/open-web3-stack/open-runtime-module-library", optional = true } +pallet-balances = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +pallet-timestamp = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-api = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } +sp-io = { branch = "polkadot-v0.9.32", git = "https://github.com/paritytech/substrate", optional = true } zrml-swaps-runtime-api = { optional = true, path = "./runtime-api" } [dev-dependencies] @@ -65,4 +65,4 @@ try-runtime = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-swaps" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/swaps/fuzz/Cargo.toml b/zrml/swaps/fuzz/Cargo.toml index 0351975f0..900ff87a3 100644 --- a/zrml/swaps/fuzz/Cargo.toml +++ b/zrml/swaps/fuzz/Cargo.toml @@ -54,11 +54,11 @@ test = false [dependencies] arbitrary = { features = ["derive"], version = "1.0" } -frame-support = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +frame-support = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } libfuzzer-sys = "0.4" -orml-traits = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } +orml-traits = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/open-web3-stack/open-runtime-module-library" } rand = "0.8.4" -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { features = ["mock"], path = "../../../primitives" } zrml-swaps = { features = ["mock"], path = ".." } diff --git a/zrml/swaps/fuzz/pool_exit.rs b/zrml/swaps/fuzz/pool_exit.rs index 20489be31..5b0c6e7be 100644 --- a/zrml/swaps/fuzz/pool_exit.rs +++ b/zrml/swaps/fuzz/pool_exit.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; mod utils; use orml_traits::currency::MultiCurrency; @@ -47,7 +47,7 @@ fuzz_target!(|data: GeneralPoolData| { data.pool_amount, ); let _ = Swaps::pool_exit( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, data.pool_amount, data.asset_bounds, diff --git a/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs b/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs index b57329429..9f983b131 100644 --- a/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs +++ b/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; mod utils; use orml_traits::currency::MultiCurrency; @@ -49,7 +49,7 @@ fuzz_target!(|data: ExactAssetAmountData| { data.pool_amount, ); let _ = Swaps::pool_exit_with_exact_asset_amount( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset), data.asset_amount, diff --git a/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs b/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs index 3de0eb4b7..a583da30e 100644 --- a/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs +++ b/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; mod utils; use orml_traits::currency::MultiCurrency; @@ -48,7 +48,7 @@ fuzz_target!(|data: ExactAmountData| { data.pool_amount, ); let _ = Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset), data.pool_amount, diff --git a/zrml/swaps/fuzz/pool_join.rs b/zrml/swaps/fuzz/pool_join.rs index 18d28234d..76a1bf87c 100644 --- a/zrml/swaps/fuzz/pool_join.rs +++ b/zrml/swaps/fuzz/pool_join.rs @@ -21,7 +21,7 @@ use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; use utils::GeneralPoolData; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; mod utils; use utils::construct_asset; use zrml_swaps::mock::AssetManager; @@ -41,7 +41,7 @@ fuzz_target!(|data: GeneralPoolData| { let pool_id = data.pool_creation.create_pool(); // join a pool with a valid pool id let _ = Swaps::pool_join( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, data.pool_amount, data.asset_bounds, diff --git a/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs b/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs index 3b317472b..91f1808d6 100644 --- a/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs +++ b/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; use utils::ExactAssetAmountData; mod utils; @@ -41,7 +41,7 @@ fuzz_target!(|data: ExactAssetAmountData| { } let pool_id = data.pool_creation.create_pool(); let _ = Swaps::pool_join_with_exact_asset_amount( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset), data.asset_amount, diff --git a/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs b/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs index 6da473ee4..f480592dd 100644 --- a/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs +++ b/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; use utils::ExactAmountData; mod utils; @@ -41,7 +41,7 @@ fuzz_target!(|data: ExactAmountData| { } let pool_id = data.pool_creation.create_pool(); let _ = Swaps::pool_join_with_exact_pool_amount( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset), data.pool_amount, diff --git a/zrml/swaps/fuzz/swap_exact_amount_in.rs b/zrml/swaps/fuzz/swap_exact_amount_in.rs index 40d7a92c9..4aba80d2f 100644 --- a/zrml/swaps/fuzz/swap_exact_amount_in.rs +++ b/zrml/swaps/fuzz/swap_exact_amount_in.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{AssetManager, ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{AssetManager, ExtBuilder, RuntimeOrigin, Swaps}; use utils::SwapExactAmountInData; mod utils; @@ -44,7 +44,7 @@ fuzz_target!(|data: SwapExactAmountInData| { data.asset_amount_in, ); let _ = Swaps::swap_exact_amount_in( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset_in), data.asset_amount_in, diff --git a/zrml/swaps/fuzz/swap_exact_amount_out.rs b/zrml/swaps/fuzz/swap_exact_amount_out.rs index 32e9162b5..93eab4325 100644 --- a/zrml/swaps/fuzz/swap_exact_amount_out.rs +++ b/zrml/swaps/fuzz/swap_exact_amount_out.rs @@ -18,7 +18,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{AssetManager, ExtBuilder, Origin, Swaps}; +use zrml_swaps::mock::{AssetManager, ExtBuilder, RuntimeOrigin, Swaps}; mod utils; use orml_traits::currency::MultiCurrency; @@ -43,7 +43,7 @@ fuzz_target!(|data: SwapExactAmountOutData| { } let _ = Swaps::swap_exact_amount_out( - Origin::signed(data.origin), + RuntimeOrigin::signed(data.origin), pool_id, construct_asset(data.asset_in), data.asset_amount_in, diff --git a/zrml/swaps/fuzz/utils.rs b/zrml/swaps/fuzz/utils.rs index ec6e54171..b03364729 100644 --- a/zrml/swaps/fuzz/utils.rs +++ b/zrml/swaps/fuzz/utils.rs @@ -17,7 +17,7 @@ #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic, + clippy::arithmetic_side_effects, clippy::type_complexity, )] @@ -25,7 +25,7 @@ use arbitrary::{Arbitrary, Result, Unstructured}; use rand::{rngs::ThreadRng, seq::SliceRandom, Rng}; use zeitgeist_primitives::{ constants::mock::{ - MaxAssets, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, MinLiquidity, MinWeight, BASE, + MaxAssets, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, MinWeight, BASE, CENT, }, traits::Swaps as SwapsTrait, types::{Asset, PoolId, ScalarPosition, ScoringRule, SerdeWrapper}, @@ -102,7 +102,9 @@ impl<'a> arbitrary::Arbitrary<'a> for ValidPoolData { let origin = rng.gen::(); let market_id = rng.gen::(); let swap_fee = rng.gen_range(0..BASE); - let amount = rng.gen_range(MinLiquidity::get()..u128::MAX); + // Slightly dirty hack: We're assuming that the minimum liquidity is CENT. This is not + // guaranteed by the protocol, but will most likely remain so forever. + let amount = rng.gen_range(CENT..u128::MAX); Ok(ValidPoolData { origin, assets, base_asset, market_id, swap_fee, amount, weights }) } diff --git a/zrml/swaps/rpc/Cargo.toml b/zrml/swaps/rpc/Cargo.toml index aad792e06..e3f57d771 100644 --- a/zrml/swaps/rpc/Cargo.toml +++ b/zrml/swaps/rpc/Cargo.toml @@ -1,9 +1,9 @@ [dependencies] -jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } +jsonrpsee = { version = "0.15.1", features = ["server", "macros"] } parity-scale-codec = { default-features = false, version = "3.0.0" } -sp-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-blockchain = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-blockchain = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../../primitives" } zrml-swaps-runtime-api = { default-features = false, features = ["std"], path = "../runtime-api" } @@ -11,4 +11,4 @@ zrml-swaps-runtime-api = { default-features = false, features = ["std"], path = authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-swaps-rpc" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/swaps/rpc/src/lib.rs b/zrml/swaps/rpc/src/lib.rs index 5d8accf7e..403d1da39 100644 --- a/zrml/swaps/rpc/src/lib.rs +++ b/zrml/swaps/rpc/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -33,6 +34,7 @@ use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, MaybeDisplay, MaybeFromStr, NumberFor}, }; +use std::collections::BTreeMap; use zeitgeist_primitives::types::{Asset, SerdeWrapper}; pub use zrml_swaps_runtime_api::SwapsApi as SwapsRuntimeApi; @@ -41,8 +43,9 @@ pub use zrml_swaps_runtime_api::SwapsApi as SwapsRuntimeApi; pub trait SwapsApi where Balance: FromStr + Display + parity_scale_codec::MaxEncodedLen, - MarketId: FromStr + Display + parity_scale_codec::MaxEncodedLen, + MarketId: FromStr + Display + parity_scale_codec::MaxEncodedLen + Ord, PoolId: FromStr + Display, + BlockNumber: Ord + parity_scale_codec::MaxEncodedLen + Display + FromStr, { #[method(name = "swaps_poolSharesId", aliases = ["swaps_poolSharesIdAt"])] async fn pool_shares_id( @@ -61,8 +64,8 @@ where pool_id: PoolId, asset_in: Asset, asset_out: Asset, - at: Option, with_fees: bool, + at: Option, ) -> RpcResult>; #[method(name = "swaps_getSpotPrices")] @@ -71,9 +74,17 @@ where pool_id: PoolId, asset_in: Asset, asset_out: Asset, - blocks: Vec, with_fees: bool, + blocks: Vec, ) -> RpcResult>>; + + #[method(name = "swaps_getAllSpotPrices")] + async fn get_all_spot_prices( + &self, + pool_id: PoolId, + with_fees: bool, + blocks: Vec, + ) -> RpcResult, Balance)>>>; } /// A struct that implements the [`SwapsApi`]. @@ -109,12 +120,13 @@ impl for Swaps where Block: BlockT, + NumberFor: MaxEncodedLen, C: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, C::Api: SwapsRuntimeApi, PoolId: Clone + Codec + MaybeDisplay + MaybeFromStr + Send + 'static, AccountId: Clone + Display + Codec + Send + 'static, Balance: Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Send + 'static, - MarketId: Clone + Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Send + 'static, + MarketId: Clone + Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Ord + Send + 'static, { async fn pool_shares_id( &self, @@ -162,8 +174,8 @@ where pool_id: PoolId, asset_in: Asset, asset_out: Asset, - at: Option<::Hash>, with_fees: bool, + at: Option<::Hash>, ) -> RpcResult> { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); @@ -183,8 +195,8 @@ where pool_id: PoolId, asset_in: Asset, asset_out: Asset, - blocks: Vec>, with_fees: bool, + blocks: Vec>, ) -> RpcResult>> { let api = self.client.runtime_api(); blocks @@ -204,4 +216,38 @@ where }) .collect() } + + async fn get_all_spot_prices( + &self, + pool_id: PoolId, + with_fees: bool, + blocks: Vec>, + ) -> RpcResult, Vec<(Asset, Balance)>>> { + let api = self.client.runtime_api(); + Ok(blocks + .into_iter() + .map( + |block| -> Result<(NumberFor, Vec<(Asset, Balance)>), CallError> { + let hash = BlockId::number(block); + let prices: Vec<(Asset, Balance)> = api + .get_all_spot_prices(&hash, &pool_id, with_fees) + .map_err(|e| { + CallError::Custom(ErrorObject::owned( + Error::RuntimeError.into(), + "Unable to get_all_spot_prices: ApiError.", + Some(format!("{:?}", e)), + )) + })? + .map_err(|e| { + CallError::Custom(ErrorObject::owned( + Error::RuntimeError.into(), + "Unable to get_all_spot_prices: DispatchError.", + Some(format!("{:?}", e)), + )) + })?; + Ok((block, prices)) + }, + ) + .collect::, _>>()?) + } } diff --git a/zrml/swaps/runtime-api/Cargo.toml b/zrml/swaps/runtime-api/Cargo.toml index ac224fc28..d26bd0a3f 100644 --- a/zrml/swaps/runtime-api/Cargo.toml +++ b/zrml/swaps/runtime-api/Cargo.toml @@ -1,7 +1,8 @@ [dependencies] parity-scale-codec = { default-features = false, features = ["derive", "max-encoded-len"], version = "3.0.0" } -sp-api = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } -sp-runtime = { branch = "polkadot-v0.9.26", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-api = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-runtime = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } +sp-std = { branch = "polkadot-v0.9.32", default-features = false, git = "https://github.com/paritytech/substrate" } zeitgeist-primitives = { default-features = false, path = "../../../primitives" } [features] @@ -17,4 +18,4 @@ std = [ authors = ["Zeitgeist PM "] edition = "2021" name = "zrml-swaps-runtime-api" -version = "0.3.7" +version = "0.3.9" diff --git a/zrml/swaps/runtime-api/src/lib.rs b/zrml/swaps/runtime-api/src/lib.rs index bd7fc3c48..437b0a53d 100644 --- a/zrml/swaps/runtime-api/src/lib.rs +++ b/zrml/swaps/runtime-api/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,9 +19,13 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -use parity_scale_codec::{Codec, MaxEncodedLen}; -use sp_runtime::traits::{MaybeDisplay, MaybeFromStr}; -use zeitgeist_primitives::types::{Asset, SerdeWrapper}; +use parity_scale_codec::{Codec, Decode, MaxEncodedLen}; +use sp_runtime::{ + traits::{MaybeDisplay, MaybeFromStr}, + DispatchError, +}; +use sp_std::vec::Vec; +use zeitgeist_primitives::types::{Asset, Pool, SerdeWrapper}; sp_api::decl_runtime_apis! { pub trait SwapsApi where @@ -28,6 +33,7 @@ sp_api::decl_runtime_apis! { AccountId: Codec, Balance: Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen, MarketId: Codec + MaxEncodedLen, + Pool: Decode, { fn pool_shares_id(pool_id: PoolId) -> Asset>; fn pool_account_id(pool_id: &PoolId) -> AccountId; @@ -37,5 +43,9 @@ sp_api::decl_runtime_apis! { asset_out: &Asset, with_fees: bool, ) -> SerdeWrapper; + fn get_all_spot_prices( + pool_id: &PoolId, + with_fees: bool + ) -> Result, Balance)>, DispatchError>; } } diff --git a/zrml/swaps/src/arbitrage.rs b/zrml/swaps/src/arbitrage.rs index 3b9f1c680..6d1878083 100644 --- a/zrml/swaps/src/arbitrage.rs +++ b/zrml/swaps/src/arbitrage.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/zrml/swaps/src/benchmarks.rs b/zrml/swaps/src/benchmarks.rs index 0c4e6ec68..d456425e9 100644 --- a/zrml/swaps/src/benchmarks.rs +++ b/zrml/swaps/src/benchmarks.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -22,7 +23,7 @@ // . // Auto-generated code is a no man's land -#![allow(clippy::integer_arithmetic, clippy::indexing_slicing)] +#![allow(clippy::arithmetic_side_effects, clippy::indexing_slicing)] #![cfg(feature = "runtime-benchmarks")] use super::*; @@ -47,7 +48,9 @@ use zeitgeist_primitives::{ }; use zrml_market_commons::MarketCommonsPalletApi; -fn assert_last_event(generic_event: ::Event) { +const LIQUIDITY: u128 = 100 * BASE; + +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } @@ -84,7 +87,7 @@ fn generate_assets( let asset_amount_unwrapped: BalanceOf = { match asset_amount { Some(ac) => ac, - _ => T::MinLiquidity::get(), + _ => LIQUIDITY.saturated_into(), } }; @@ -129,7 +132,7 @@ fn initialize_pool( market_id, scoring_rule, if scoring_rule == ScoringRule::CPMM { Some(Zero::zero()) } else { None }, - if scoring_rule == ScoringRule::CPMM { Some(T::MinLiquidity::get()) } else { None }, + if scoring_rule == ScoringRule::CPMM { Some(LIQUIDITY.saturated_into()) } else { None }, if scoring_rule == ScoringRule::CPMM { some_weights } else { None }, ) .unwrap(); @@ -174,6 +177,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let market_id = T::MarketCommons::push_market( Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: caller.clone(), @@ -214,6 +218,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let market_id = T::MarketCommons::push_market( Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: caller.clone(), @@ -317,7 +322,7 @@ benchmarks! { let pool_id: PoolId = i.into(); PoolsCachedForArbitrage::::insert(pool_id, ()); } - let noop = |_: PoolId| -> Result { Ok(0) }; + let noop = |_: PoolId| -> Result { Ok(Weight::zero()) }; }: { Pallet::::apply_to_cached_pools(a, noop, Weight::MAX) } @@ -566,12 +571,12 @@ benchmarks! { let (pool_id, ..) = bench_create_pool::( caller.clone(), Some(a as usize), - Some(T::MinLiquidity::get() * 2u32.into()), + Some((2u128 * LIQUIDITY).saturated_into()), ScoringRule::CPMM, false, None, ); - let pool_amount = T::MinLiquidity::get() / 2u32.into(); + let pool_amount = (LIQUIDITY / 2u128).saturated_into(); let min_assets_out = vec![0u32.into(); a as usize]; }: _(RawOrigin::Signed(caller), pool_id, pool_amount, min_assets_out) @@ -604,7 +609,7 @@ benchmarks! { None, ); let asset_amount: BalanceOf = BASE.saturated_into(); - let pool_amount = T::MinLiquidity::get(); + let pool_amount = LIQUIDITY.saturated_into(); }: _(RawOrigin::Signed(caller), pool_id, assets[0], asset_amount, pool_amount) pool_exit_with_exact_pool_amount { @@ -628,13 +633,13 @@ benchmarks! { let (pool_id, ..) = bench_create_pool::( caller.clone(), Some(a as usize), - Some(T::MinLiquidity::get() * 2u32.into()), + Some((2u128 * LIQUIDITY).saturated_into()), ScoringRule::CPMM, false, None, ); - let pool_amount = T::MinLiquidity::get(); - let max_assets_in = vec![T::MinLiquidity::get(); a as usize]; + let pool_amount = LIQUIDITY.saturated_into(); + let max_assets_in = vec![LIQUIDITY.saturated_into(); a as usize]; }: _(RawOrigin::Signed(caller), pool_id, pool_amount, max_assets_in) pool_join_subsidy { @@ -655,7 +660,7 @@ benchmarks! { let (pool_id, assets, ..) = bench_create_pool::( caller.clone(), Some(a as usize), - Some(T::MinLiquidity::get() * 2u32.into()), + Some((2u128 * LIQUIDITY).saturated_into()), ScoringRule::CPMM, false, None, @@ -670,13 +675,13 @@ benchmarks! { let (pool_id, assets, ..) = bench_create_pool::( caller.clone(), Some(a as usize), - Some(T::MinLiquidity::get() * 2u32.into()), + Some((2u128 * LIQUIDITY).saturated_into()), ScoringRule::CPMM, false, None, ); let pool_amount = BASE.saturated_into(); - let max_asset_amount: BalanceOf = T::MinLiquidity::get(); + let max_asset_amount: BalanceOf = LIQUIDITY.saturated_into(); }: _(RawOrigin::Signed(caller), pool_id, assets[0], pool_amount, max_asset_amount) clean_up_pool_categorical_without_reward_distribution { @@ -715,7 +720,7 @@ benchmarks! { // `math::calc_out_given_in`). To get these values, we use the following parameters: // amount_in = 1/3 * balance_in, weight_in = 1, weight_out = 2. let asset_count = T::MaxAssets::get(); - let balance: BalanceOf = T::MinLiquidity::get(); + let balance: BalanceOf = LIQUIDITY.saturated_into(); let asset_amount_in: BalanceOf = bmul( balance.saturated_into(), T::MaxInRatio::get().saturated_into(), @@ -781,7 +786,7 @@ benchmarks! { // `math::calc_in_given_out`). To get these values, we use the following parameters: // amount_out = 1/3 * balance_out, weight_out = 1, weight_in = 4. let asset_count = T::MaxAssets::get(); - let balance: BalanceOf = T::MinLiquidity::get(); + let balance: BalanceOf = LIQUIDITY.saturated_into(); let asset_amount_out: BalanceOf = bmul( balance.saturated_into(), T::MaxOutRatio::get().saturated_into(), diff --git a/zrml/swaps/src/lib.rs b/zrml/swaps/src/lib.rs index 9164b2abd..995c049c7 100644 --- a/zrml/swaps/src/lib.rs +++ b/zrml/swaps/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -112,7 +113,7 @@ mod pallet { pub(crate) const ARBITRAGE_MAX_ITERATIONS: usize = 30; const ARBITRAGE_THRESHOLD: u128 = CENT; const MIN_BALANCE: u128 = CENT; - const ON_IDLE_MIN_WEIGHT: Weight = 1_000_000; + const ON_IDLE_MIN_WEIGHT: Weight = Weight::from_ref_time(1_000_000); #[pallet::call] impl Pallet { @@ -756,7 +757,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fee for exiting a pool. #[pallet::constant] @@ -789,16 +790,13 @@ mod pallet { + PartialOrd; type LiquidityMining: LiquidityMiningPalletApi< - AccountId = Self::AccountId, - Balance = BalanceOf, - BlockNumber = Self::BlockNumber, - MarketId = MarketIdOf, - >; + AccountId = Self::AccountId, + Balance = BalanceOf, + BlockNumber = Self::BlockNumber, + MarketId = MarketIdOf, + >; - type MarketCommons: MarketCommonsPalletApi< - AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, - >; + type MarketCommons: MarketCommonsPalletApi; #[pallet::constant] type MaxAssets: Get; @@ -822,10 +820,6 @@ mod pallet { /// The minimum amount of assets in a pool. type MinAssets: Get; - /// The minimum amount of liqudity required to bootstrap a pool. - #[pallet::constant] - type MinLiquidity: Get>; - /// The minimum amount of subsidy required to state transit a market into active state. /// Must be greater than 0, but can be arbitrarily close to 0. #[pallet::constant] @@ -844,22 +838,19 @@ mod pallet { /// The Rikiddo instance that uses a sigmoid fee and ema of market volume type RikiddoSigmoidFeeMarketEma: RikiddoMVPallet< - Balance = BalanceOf, - PoolId = PoolId, - FU = Self::FixedTypeU, - Rikiddo = RikiddoSigmoidMV< - Self::FixedTypeU, - Self::FixedTypeS, - FeeSigmoid, - EmaMarketVolume, - >, - >; + Balance = BalanceOf, + PoolId = PoolId, + FU = Self::FixedTypeU, + Rikiddo = RikiddoSigmoidMV< + Self::FixedTypeU, + Self::FixedTypeS, + FeeSigmoid, + EmaMarketVolume, + >, + >; /// Shares of outcome assets and native currency - type AssetManager: ZeitgeistAssetManager< - Self::AccountId, - CurrencyId = Asset>, - >; + type AssetManager: ZeitgeistAssetManager>>; /// The weight information for swap's dispatchable functions. type WeightInfo: WeightInfoZeitgeist; @@ -881,7 +872,7 @@ mod pallet { BelowMinimumWeight, /// Some funds could not be transferred due to a too low balance. InsufficientBalance, - /// Liquidity provided to new CPMM pool is less than `MinLiquidity`. + /// Liquidity provided to new CPMM pool is less than the minimum allowed balance. InsufficientLiquidity, /// The market was not started since the subsidy goal was not reached. InsufficientSubsidy, @@ -1097,8 +1088,8 @@ mod pallet { #[pallet::hooks] impl Hooks for Pallet { fn on_idle(_: T::BlockNumber, remaining_weight: Weight) -> Weight { - if remaining_weight < ON_IDLE_MIN_WEIGHT { - return 0; + if remaining_weight.all_lt(ON_IDLE_MIN_WEIGHT) { + return Weight::zero(); } Self::execute_arbitrage_all(remaining_weight / 2) } @@ -1114,7 +1105,7 @@ mod pallet { ) -> Weight { // CPMM handling of market profit not supported if pool.scoring_rule == ScoringRule::CPMM { - return 1_000_000; + return Weight::from_ref_time(1_000_000); } // Total pool shares @@ -1249,19 +1240,19 @@ mod pallet { // The division can fail if the benchmark of `apply_to_cached_pools` is not linear in // the number of pools. This shouldn't ever happen, but if it does, we ensure that // `pool_count` is zero (this isn't really a runtime error). - let pool_count: u32 = weight - .saturating_sub(overhead) - .checked_div(extra_weight_per_pool) + let pool_count = weight + .ref_time() + .saturating_sub(overhead.ref_time()) + .checked_div(extra_weight_per_pool.ref_time()) .unwrap_or_else(|| { log::warn!("Unexpected zero division when calculating arbitrage weight"); - Weight::zero() - }) - .saturated_into(); // Saturates only if we have u32::MAX trades per block. - if pool_count == 0 { + 0_u64 + }); + if pool_count == 0_u64 { return weight; } Self::apply_to_cached_pools( - pool_count, + pool_count.saturated_into(), |pool_id| Self::execute_arbitrage(pool_id, ARBITRAGE_MAX_ITERATIONS), extra_weight_per_pool, ) @@ -1469,16 +1460,55 @@ mod pallet { } } + // Returns vector of pairs `(a, p)` where `a` ranges over all assets in the pool and `p` is + // the spot price of swapping the base asset for `a` (including swap fees if `with_fees` is + // `true`). + pub fn get_all_spot_prices( + pool_id: &PoolId, + with_fees: bool, + ) -> Result>, BalanceOf)>, DispatchError> { + let pool = Self::pool_by_id(*pool_id)?; + pool.assets + .into_iter() + .map(|asset| { + let spot_price = + Self::get_spot_price(pool_id, &pool.base_asset, &asset, with_fees)?; + Ok((asset, spot_price)) + }) + .collect() + } + #[inline] pub fn pool_account_id(pool_id: &PoolId) -> T::AccountId { T::PalletId::get().into_sub_account_truncating((*pool_id).saturated_into::()) } - // The minimum allowed balance in a liquidity pool. + /// The minimum allowed balance of `asset` in a liquidity pool. pub(crate) fn min_balance(asset: Asset>) -> BalanceOf { T::AssetManager::minimum_balance(asset).max(MIN_BALANCE.saturated_into()) } + /// Returns the minimum allowed balance allowed for a pool with id `pool_id` containing + /// `assets`. + /// + /// The minimum allowed balance is the maximum of all minimum allowed balances of assets + /// contained in the pool, _including_ the pool shares asset. This ensures that none of the + /// accounts involved are slashed when a pool is created with the minimum amount. + /// + /// **Should** only be called if `assets` is non-empty. Note that the existence of a pool + /// with the specified `pool_id` is not mandatory. + pub(crate) fn min_balance_of_pool( + pool_id: PoolId, + assets: &[Asset>], + ) -> BalanceOf { + assets + .iter() + .map(|asset| Self::min_balance(*asset)) + .max() + .unwrap_or_else(|| MIN_BALANCE.saturated_into()) + .max(Self::min_balance(Self::pool_shares_id(pool_id))) + } + fn ensure_minimum_liquidity_shares( pool_id: PoolId, pool: &Pool, MarketIdOf>, @@ -1561,7 +1591,7 @@ mod pallet { Asset::PoolShare(SerdeWrapper(pool_id)) } - pub(crate) fn pool_by_id( + pub fn pool_by_id( pool_id: PoolId, ) -> Result, MarketIdOf>, DispatchError> where @@ -1616,7 +1646,7 @@ mod pallet { outcome_report: &OutcomeReport, winner_payout_account: &T::AccountId, ) -> Result { - let mut extra_weight = 0; + let mut extra_weight = Weight::zero(); let mut total_assets = 0; Self::mutate_pool(pool_id, |pool| { @@ -1686,7 +1716,7 @@ mod pallet { /// # Arguments /// /// * `who`: The account that is the creator of the pool. Must have enough - /// funds for each of the assets to cover the `MinLiqudity`. + /// funds for each of the assets to cover the `amount`. /// * `assets`: The assets that are used in the pool. /// * `base_asset`: The base asset in a prediction market swap pool (usually a currency). /// * `market_id`: The market id of the market the pool belongs to. @@ -1728,8 +1758,11 @@ mod pallet { match scoring_rule { ScoringRule::CPMM => { ensure!(amount.is_some(), Error::::InvalidAmountArgument); + // `amount` must be larger than all minimum balances. As we deposit `amount` + // liquidity shares, we must also ensure that `amount` is larger than the + // existential deposit of the liquidity shares. ensure!( - amount_unwrapped >= T::MinLiquidity::get(), + amount_unwrapped >= Self::min_balance_of_pool(next_pool_id, &assets), Error::::InsufficientLiquidity ); let swap_fee_unwrapped = swap_fee.ok_or(Error::::InvalidFeeArgument)?; @@ -2211,7 +2244,7 @@ mod pallet { outcome_report: &OutcomeReport, winner_payout_account: &T::AccountId, ) -> Result { - let mut weight = 0; + let mut weight = Weight::zero(); Self::mutate_pool(pool_id, |pool| { ensure!(pool.pool_status == PoolStatus::Closed, Error::::InvalidStateTransition); pool.pool_status = PoolStatus::Clean; diff --git a/zrml/swaps/src/mock.rs b/zrml/swaps/src/mock.rs index 527f311da..91d8ff17a 100644 --- a/zrml/swaps/src/mock.rs +++ b/zrml/swaps/src/mock.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -24,7 +25,7 @@ #![cfg(feature = "mock")] #![allow( // Mocks are only used for fuzzing and unit tests - clippy::integer_arithmetic + clippy::arithmetic_side_effects )] use crate as zrml_swaps; @@ -32,14 +33,15 @@ use frame_support::{construct_runtime, parameter_types, traits::Everything}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, + DispatchError, }; use substrate_fixed::{types::extra::U33, FixedI128, FixedU128}; use zeitgeist_primitives::{ constants::mock::{ BalanceFractionalDecimals, BlockHashCount, ExistentialDeposit, ExistentialDeposits, GetNativeCurrencyId, LiquidityMiningPalletId, MaxAssets, MaxInRatio, MaxLocks, MaxOutRatio, - MaxReserves, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, MinLiquidity, MinSubsidy, - MinWeight, MinimumPeriod, PmPalletId, SwapsPalletId, BASE, + MaxReserves, MaxSwapFee, MaxTotalWeight, MaxWeight, MinAssets, MinSubsidy, MinWeight, + MinimumPeriod, PmPalletId, SwapsPalletId, BASE, }, types::{ AccountIdTest, Amount, Asset, Balance, BasicCurrencyAdapter, BlockNumber, BlockTest, @@ -84,7 +86,7 @@ construct_runtime!( pub type AssetManager = Currencies; impl crate::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExitFee = ExitFeeMock; type FixedTypeU = ::FixedTypeU; type FixedTypeS = ::FixedTypeS; @@ -97,7 +99,6 @@ impl crate::Config for Runtime { type MaxTotalWeight = MaxTotalWeight; type MaxWeight = MaxWeight; type MinAssets = MinAssets; - type MinLiquidity = MinLiquidity; type MinSubsidy = MinSubsidy; type MinSubsidyPerAccount = MinSubsidyPerAccount; type MinWeight = MinWeight; @@ -115,9 +116,9 @@ impl frame_system::Config for Runtime { type BlockLength = (); type BlockNumber = BlockNumber; type BlockWeights = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type DbWeight = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Hash = Hash; type Hashing = BlakeTwo256; type Header = Header; @@ -127,7 +128,7 @@ impl frame_system::Config for Runtime { type OnKilledAccount = (); type OnNewAccount = (); type OnSetCode = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type PalletInfo = PalletInfo; type SS58Prefix = (); type SystemWeightInfo = (); @@ -146,13 +147,11 @@ impl orml_tokens::Config for Runtime { type Balance = Balance; type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; - type OnDust = (); - type OnKilledTokenAccount = (); - type OnNewTokenAccount = (); + type CurrencyHooks = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } @@ -161,7 +160,7 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; @@ -170,7 +169,7 @@ impl pallet_balances::Config for Runtime { } impl zrml_liquidity_mining::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type MarketId = MarketId; type PalletId = LiquidityMiningPalletId; @@ -250,5 +249,12 @@ sp_api::mock_impl_runtime_apis! { fn pool_shares_id(pool_id: PoolId) -> Asset> { Asset::PoolShare(SerdeWrapper(pool_id)) } + + fn get_all_spot_prices( + pool_id: &PoolId, + with_fees: bool + ) -> Result, Balance)>, DispatchError> { + Swaps::get_all_spot_prices(pool_id, with_fees) + } } } diff --git a/zrml/swaps/src/root.rs b/zrml/swaps/src/root.rs index c1cc94175..4e1222e4f 100644 --- a/zrml/swaps/src/root.rs +++ b/zrml/swaps/src/root.rs @@ -1,4 +1,4 @@ -// Copyright 2021-2022 Zeitgeist PM LLC. +// Copyright 2022 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/zrml/swaps/src/tests.rs b/zrml/swaps/src/tests.rs index fcf16e09b..57d3f4f86 100644 --- a/zrml/swaps/src/tests.rs +++ b/zrml/swaps/src/tests.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -22,6 +23,7 @@ // . #![cfg(all(feature = "mock", test))] +#![allow(clippy::too_many_arguments)] use crate::{ events::{CommonPoolEventParams, PoolAssetEvent, PoolAssetsEvent, SwapEvent}, @@ -91,6 +93,8 @@ const _900: u128 = 900 * BASE; const _1234: u128 = 1234 * BASE; const _10000: u128 = 10000 * BASE; +const LIQUIDITY: u128 = _100; + // Macro for comparing fixed point u128. #[allow(unused_macros)] macro_rules! assert_approx { @@ -128,7 +132,7 @@ fn create_pool_fails_with_duplicate_assets(assets: Vec 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec![_2; asset_count]), ), crate::Error::::SomeIdenticalAssets @@ -308,7 +312,7 @@ fn create_pool_generates_a_new_pool_with_correct_parameters_for_cpmm() { let next_pool_before = Swaps::next_pool_id(); assert_eq!(next_pool_before, 0); - let amount = ::MinLiquidity::get(); + let amount = LIQUIDITY; let base_asset = ASSETS.last().unwrap(); ASSETS.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, amount)); @@ -403,7 +407,7 @@ fn destroy_pool_in_subsidy_phase_returns_subsidy_and_closes_pool() { // Reserve some funds for subsidy assert_ok!(Swaps::pool_join_subsidy(alice_signed(), pool_id, _25)); assert_ok!(Currencies::deposit(ASSET_D, &BOB, _26)); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(BOB), pool_id, _26)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(BOB), pool_id, _26)); assert_eq!(Currencies::reserved_balance(ASSET_D, &ALICE), _25); assert_eq!(Currencies::reserved_balance(ASSET_D, &BOB), _26); @@ -435,7 +439,7 @@ fn distribute_pool_share_rewards() { subsidy_providers.iter().for_each(|provider| { assert_ok!(Currencies::deposit(base_asset, provider, subsidy_per_acc)); assert_ok!(Swaps::pool_join_subsidy( - Origin::signed(*provider), + RuntimeOrigin::signed(*provider), pool_id, subsidy_per_acc )); @@ -449,7 +453,7 @@ fn distribute_pool_share_rewards() { asset_holders.iter().for_each(|asset_holder| { assert_ok!(Currencies::deposit(base_asset, asset_holder, asset_per_acc + 20)); assert_ok!(Swaps::swap_exact_amount_out( - Origin::signed(*asset_holder), + RuntimeOrigin::signed(*asset_holder), pool_id, base_asset, Some(asset_per_acc + 20), @@ -511,8 +515,8 @@ fn end_subsidy_phase_distributes_shares_and_outcome_assets() { let subsidy_bob = min_subsidy + _25; assert_ok!(Currencies::deposit(ASSET_D, &ALICE, subsidy_alice)); assert_ok!(Currencies::deposit(ASSET_D, &BOB, subsidy_bob)); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(ALICE), pool_id, min_subsidy)); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(BOB), pool_id, subsidy_bob)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(ALICE), pool_id, min_subsidy)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(BOB), pool_id, subsidy_bob)); assert!(Swaps::end_subsidy_phase(pool_id).unwrap().result); // Check that subsidy was deposited, shares were distributed in exchange, the initial @@ -618,7 +622,7 @@ fn pool_join_fails_if_pool_is_closed() { let pool_id = 0; assert_ok!(Swaps::close_pool(pool_id)); assert_noop!( - Swaps::pool_join(Origin::signed(ALICE), pool_id, _1, vec![_1, _1, _1, _1]), + Swaps::pool_join(RuntimeOrigin::signed(ALICE), pool_id, _1, vec![_1, _1, _1, _1]), crate::Error::::InvalidPoolStatus, ); }); @@ -642,7 +646,7 @@ fn most_operations_fail_if_pool_is_clean() { )); assert_noop!( - Swaps::pool_join(Origin::signed(ALICE), pool_id, _1, vec![_10]), + Swaps::pool_join(RuntimeOrigin::signed(ALICE), pool_id, _1, vec![_10]), crate::Error::::InvalidPoolStatus, ); assert_noop!( @@ -712,10 +716,10 @@ fn get_spot_price_returns_correct_results_cpmm( ) { ExtBuilder::default().build().execute_with(|| { // We always swap ASSET_A for ASSET_B, but we vary the weights, balances and swap fees. + let amount_in_pool = LIQUIDITY; ASSETS.iter().cloned().for_each(|asset| { - assert_ok!(Currencies::deposit(asset, &BOB, _100)); + assert_ok!(Currencies::deposit(asset, &BOB, amount_in_pool)); }); - let amount_in_pool = ::MinLiquidity::get(); assert_ok!(Swaps::create_pool( BOB, ASSETS.to_vec(), @@ -776,6 +780,86 @@ fn get_spot_price_returns_correct_results_rikiddo() { }); } +#[test] +fn get_all_spot_price_returns_correct_results_rikiddo() { + ExtBuilder::default().build().execute_with(|| { + create_initial_pool(ScoringRule::RikiddoSigmoidFeeMarketEma, None, false); + let pool_id = 0; + assert_noop!( + Swaps::get_spot_price(&pool_id, &ASSETS[0], &ASSETS[0], true), + crate::Error::::PoolIsNotActive + ); + subsidize_and_start_rikiddo_pool(pool_id, &ALICE, 0); + + let prices = + Swaps::get_all_spot_prices(&pool_id, false).expect("get_all_spot_prices fails"); + // Base currency in, asset out. + // Price Between 0.3 and 0.4 + for (asset, price) in prices { + // ASSETS.last() is base_asset + if asset != *ASSETS.last().expect("no last asset") { + assert!(price > 3 * BASE / 10 && price < 4 * BASE / 10); + } + } + }); +} + +#[test_case(_3, _3, _2, _2, 0, 15_000_000_000, 15_000_000_000, 10_000_000_000, 10_000_000_000)] +#[test_case(_3, _3, _1, _3, 0, 10_000_000_000, 10_000_000_000, 3_333_333_333, 10_000_000_000)] +#[test_case(_3, _4, _1, _1, 0, 30_000_000_000, 40_000_000_000, 10_000_000_000, 10_000_000_000)] +#[test_case(_3, _4, _10, _4, 0, 7_500_000_000, 10_000_000_000, 25_000_000_000, 10_000_000_000)] +#[test_case(_3, _6, _4, _5, 0, 6_000_000_000, 12_000_000_000, 8_000_000_000, 10_000_000_000)] +#[test_case(_3, _3, _4, _5, 0, 6_000_000_000, 6_000_000_000, 8_000_000_000, 10_000_000_000)] +#[test_case(_3, _3, _10, _10, _1_10, 3_333_333_333, 3_333_333_333, 11_111_111_111, 11_111_111_111)] +#[test_case(_3, _3, _10, _5, _1_10, 6_666_666_667, 6_666_666_667, 22_222_222_222, 11_111_111_111)] +#[test_case(_3, _4, _10, _10, _1_10, 3_333_333_333, 4_444_444_444, 11_111_111_111, 11_111_111_111)] +#[test_case(_3, _4, _10, _5, _1_10, 6_666_666_667, 8_888_888_889, 22_222_222_222, 11_111_111_111)] +#[test_case(_3, _6, _2, _5, _1_10, 6_666_666_667, 13_333_333_333, 4_444_444_444, 11_111_111_111)] +#[test_case(_3, _6, _2, _10, _1_10, 3_333_333_333, 6_666_666_667, 2_222_222_222, 11_111_111_111)] +fn get_all_spot_prices_returns_correct_results_cpmm( + weight_a: u128, + weight_b: u128, + weight_c: u128, + weight_d: u128, + swap_fee: BalanceOf, + exp_spot_price_a_with_fees: BalanceOf, + exp_spot_price_b_with_fees: BalanceOf, + exp_spot_price_c_with_fees: BalanceOf, + exp_spot_price_d_with_fees: BalanceOf, +) { + ExtBuilder::default().build().execute_with(|| { + ASSETS.iter().cloned().for_each(|asset| { + assert_ok!(Currencies::deposit(asset, &BOB, _100)); + }); + assert_ok!(Swaps::create_pool( + BOB, + ASSETS.to_vec(), + *ASSETS.last().unwrap(), + 0, + ScoringRule::CPMM, + Some(swap_fee), + Some(_100), + Some(vec!(weight_a, weight_b, weight_c, weight_d)) + )); + let pool_id = 0; + + // Gets spot prices for all assets against base_asset. + let prices = + Swaps::get_all_spot_prices(&pool_id, true).expect("get_all_spot_prices failed"); + for (asset, price) in prices { + if asset == ASSET_A { + assert_eq!(exp_spot_price_a_with_fees, price); + } else if asset == ASSET_B { + assert_eq!(exp_spot_price_b_with_fees, price); + } else if asset == ASSET_C { + assert_eq!(exp_spot_price_c_with_fees, price); + } else if asset == ASSET_D { + assert_eq!(exp_spot_price_d_with_fees, price); + } + } + }); +} + #[test] fn in_amount_must_be_equal_or_less_than_max_in_ratio() { ExtBuilder::default().build().execute_with(|| { @@ -803,8 +887,9 @@ fn pool_exit_with_exact_asset_amount_satisfies_max_out_ratio_constraints() { ExtBuilder::default().build().execute_with(|| { // We make sure that the individual asset weights don't divide total weight so we trigger // the calculation of exp using the binomial series. + let amount_in_pool = LIQUIDITY; ASSETS.iter().cloned().for_each(|asset| { - assert_ok!(Currencies::deposit(asset, &BOB, _100)); + assert_ok!(Currencies::deposit(asset, &BOB, amount_in_pool)); }); assert_ok!(Swaps::create_pool( BOB, @@ -813,7 +898,7 @@ fn pool_exit_with_exact_asset_amount_satisfies_max_out_ratio_constraints() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(amount_in_pool), Some(vec!(_2, _2, _2, _5)), )); let pool_id = 0; @@ -821,7 +906,7 @@ fn pool_exit_with_exact_asset_amount_satisfies_max_out_ratio_constraints() { assert_noop!( Swaps::pool_exit_with_exact_asset_amount( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, ASSET_A, _50, @@ -837,8 +922,9 @@ fn pool_exit_with_exact_pool_amount_satisfies_max_in_ratio_constraints() { ExtBuilder::default().build().execute_with(|| { // We make sure that the individual asset weights don't divide total weight so we trigger // the calculation of exp using the binomial series. + let amount_in_pool = LIQUIDITY; ASSETS.iter().cloned().for_each(|asset| { - assert_ok!(Currencies::deposit(asset, &BOB, _100)); + assert_ok!(Currencies::deposit(asset, &BOB, amount_in_pool)); }); assert_ok!(Swaps::create_pool( BOB, @@ -847,7 +933,7 @@ fn pool_exit_with_exact_pool_amount_satisfies_max_in_ratio_constraints() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(amount_in_pool), Some(vec!(_2, _2, _2, _5)), )); let pool_id = 0; @@ -855,7 +941,7 @@ fn pool_exit_with_exact_pool_amount_satisfies_max_in_ratio_constraints() { assert_noop!( Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, ASSET_A, _50, @@ -871,8 +957,9 @@ fn pool_join_with_exact_asset_amount_satisfies_max_in_ratio_constraints() { ExtBuilder::default().build().execute_with(|| { // We make sure that the individual asset weights don't divide total weight so we trigger // the calculation of exp using the binomial series. + let amount_in_pool = LIQUIDITY; ASSETS.iter().cloned().for_each(|asset| { - assert_ok!(Currencies::deposit(asset, &BOB, _100)); + assert_ok!(Currencies::deposit(asset, &BOB, amount_in_pool)); }); assert_ok!(Swaps::create_pool( BOB, @@ -881,12 +968,12 @@ fn pool_join_with_exact_asset_amount_satisfies_max_in_ratio_constraints() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(amount_in_pool), Some(vec!(_2, _2, _2, _5)), )); let pool_id = 0; assert_ok!(Swaps::open_pool(pool_id)); - let asset_amount = _100; + let asset_amount = LIQUIDITY; assert_ok!(Currencies::deposit(ASSET_A, &ALICE, asset_amount)); assert_noop!( @@ -911,8 +998,9 @@ fn pool_join_with_exact_pool_amount_satisfies_max_out_ratio_constraints() { ExtBuilder::default().build().execute_with(|| { // We make sure that the individual asset weights don't divide total weight so we trigger // the calculation of exp using the binomial series. + let amount_in_pool = LIQUIDITY; ASSETS.iter().cloned().for_each(|asset| { - assert_ok!(Currencies::deposit(asset, &BOB, _100)); + assert_ok!(Currencies::deposit(asset, &BOB, amount_in_pool)); }); assert_ok!(Swaps::create_pool( BOB, @@ -921,7 +1009,7 @@ fn pool_join_with_exact_pool_amount_satisfies_max_out_ratio_constraints() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(amount_in_pool), Some(vec!(_2, _2, _2, _5)), )); let pool_id = 0; @@ -1037,8 +1125,8 @@ fn pool_exit_decreases_correct_pool_parameters() { assert_all_parameters( [_25 + 1, _25 + 1, _25 + 1, _25 + 1], 0, - [_100 - 1, _100 - 1, _100 - 1, _100 - 1], - _100, + [LIQUIDITY - 1, LIQUIDITY - 1, LIQUIDITY - 1, LIQUIDITY - 1], + LIQUIDITY, ); }) } @@ -1048,7 +1136,7 @@ fn pool_exit_emits_correct_events() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); create_initial_pool_with_funds_for_alice(ScoringRule::CPMM, Some(0), true); - assert_ok!(Swaps::pool_exit(Origin::signed(BOB), 0, _1, vec!(1, 2, 3, 4),)); + assert_ok!(Swaps::pool_exit(RuntimeOrigin::signed(BOB), 0, _1, vec!(1, 2, 3, 4),)); let amount = _1 - BASE / 10; // Subtract 10% fees! System::assert_last_event( Event::PoolExit(PoolAssetsEvent { @@ -1069,7 +1157,7 @@ fn pool_exit_decreases_correct_pool_parameters_with_exit_fee() { frame_system::Pallet::::set_block_number(1); create_initial_pool_with_funds_for_alice(ScoringRule::CPMM, Some(0), true); - assert_ok!(Swaps::pool_exit(Origin::signed(BOB), 0, _10, vec!(_1, _1, _1, _1),)); + assert_ok!(Swaps::pool_exit(RuntimeOrigin::signed(BOB), 0, _10, vec!(_1, _1, _1, _1),)); let pool_account = Swaps::pool_account_id(&0); let pool_shares_id = Swaps::pool_shares_id(0); @@ -1077,12 +1165,12 @@ fn pool_exit_decreases_correct_pool_parameters_with_exit_fee() { assert_eq!(Currencies::free_balance(ASSET_B, &BOB), _9); assert_eq!(Currencies::free_balance(ASSET_C, &BOB), _9); assert_eq!(Currencies::free_balance(ASSET_D, &BOB), _9); - assert_eq!(Currencies::free_balance(pool_shares_id, &BOB), _100 - _10); - assert_eq!(Currencies::free_balance(ASSET_A, &pool_account), _100 - _9); - assert_eq!(Currencies::free_balance(ASSET_B, &pool_account), _100 - _9); - assert_eq!(Currencies::free_balance(ASSET_C, &pool_account), _100 - _9); - assert_eq!(Currencies::free_balance(ASSET_D, &pool_account), _100 - _9); - assert_eq!(Currencies::total_issuance(pool_shares_id), _100 - _10); + assert_eq!(Currencies::free_balance(pool_shares_id, &BOB), LIQUIDITY - _10); + assert_eq!(Currencies::free_balance(ASSET_A, &pool_account), LIQUIDITY - _9); + assert_eq!(Currencies::free_balance(ASSET_B, &pool_account), LIQUIDITY - _9); + assert_eq!(Currencies::free_balance(ASSET_C, &pool_account), LIQUIDITY - _9); + assert_eq!(Currencies::free_balance(ASSET_D, &pool_account), LIQUIDITY - _9); + assert_eq!(Currencies::total_issuance(pool_shares_id), LIQUIDITY - _10); System::assert_last_event( Event::PoolExit(PoolAssetsEvent { @@ -1108,7 +1196,11 @@ fn pool_exit_decreases_correct_pool_parameters_on_cleaned_up_pool() { assert_ok!(Swaps::pool_join(alice_signed(), 0, _1, vec!(_1, _1, _1, _1),)); assert_ok!(Swaps::close_pool(0)); - assert_ok!(Swaps::admin_clean_up_pool(Origin::root(), 0, OutcomeReport::Categorical(65),)); + assert_ok!(Swaps::admin_clean_up_pool( + RuntimeOrigin::root(), + 0, + OutcomeReport::Categorical(65), + )); assert_ok!(Swaps::pool_exit(alice_signed(), 0, _1, vec!(_1, _1),)); System::assert_last_event( @@ -1126,8 +1218,8 @@ fn pool_exit_decreases_correct_pool_parameters_on_cleaned_up_pool() { 0, // Note: Although the asset is deleted from the pool, the assets B/C still remain on the // pool account. - [_100 - 1, _101, _101, _100 - 1], - _100, + [LIQUIDITY - 1, LIQUIDITY + _1, LIQUIDITY + _1, LIQUIDITY - 1], + LIQUIDITY, ); }) } @@ -1294,8 +1386,13 @@ fn pool_exit_with_exact_pool_amount_exchanges_correct_values( assert_all_parameters( [_25 - asset_amount_joined + asset_amount_expected, _25, _25, _25], 0, - [_100 + asset_amount_joined - asset_amount_expected, _100, _100, _100], - _100, + [ + LIQUIDITY + asset_amount_joined - asset_amount_expected, + LIQUIDITY, + LIQUIDITY, + LIQUIDITY, + ], + LIQUIDITY, ) }); } @@ -1355,8 +1452,8 @@ fn pool_exit_with_exact_asset_amount_exchanges_correct_values( assert_all_parameters( [_25 - asset_amount_joined + asset_amount, _25, _25, _25], dust, - [_100 + asset_amount_joined - asset_amount, _100, _100, _100], - _100 + dust, + [LIQUIDITY + asset_amount_joined - asset_amount, LIQUIDITY, LIQUIDITY, LIQUIDITY], + LIQUIDITY + dust, ) }); } @@ -1600,8 +1697,8 @@ fn pool_join_with_exact_asset_amount_exchanges_correct_values( assert_all_parameters( [_25 - asset_amount, _25, _25, _25], pool_amount_expected, - [_100 + alice_sent, _100, _100, _100], - _100 + pool_amount_expected, + [LIQUIDITY + alice_sent, LIQUIDITY, LIQUIDITY, LIQUIDITY], + LIQUIDITY + pool_amount_expected, ); }); } @@ -1637,8 +1734,8 @@ fn pool_join_with_exact_pool_amount_exchanges_correct_values( assert_all_parameters( [_25 - asset_amount_expected, _25, _25, _25], pool_amount, - [_100 + asset_amount_expected, _100, _100, _100], - _100 + pool_amount, + [LIQUIDITY + asset_amount_expected, LIQUIDITY, LIQUIDITY, LIQUIDITY], + LIQUIDITY + pool_amount, ); }); } @@ -1780,8 +1877,8 @@ fn swap_exact_amount_in_exchanges_correct_values_with_cpmm() { assert_all_parameters( [_24, _25 + 9900990100, _25, _25], 0, - [_101, _99 + 99009900, _100, _100], - _100, + [LIQUIDITY + _1, LIQUIDITY - 9900990100, LIQUIDITY, LIQUIDITY], + LIQUIDITY, ); }); } @@ -1801,7 +1898,7 @@ fn swap_exact_amount_in_exchanges_correct_values_with_cpmm_with_fees() { 0, ScoringRule::CPMM, Some(BASE / 10), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, _2, _2, _2)), )); let pool_id = 0; @@ -1837,8 +1934,8 @@ fn swap_exact_amount_in_exchanges_correct_values_with_cpmm_with_fees() { assert_all_parameters( [_25 - asset_amount_in, _25 + asset_amount_out, _25, _25], 0, - [_100 + asset_amount_in, _100 - asset_amount_out, _100, _100], - _100, + [LIQUIDITY + asset_amount_in, LIQUIDITY - asset_amount_out, LIQUIDITY, LIQUIDITY], + LIQUIDITY, ); }); } @@ -1982,8 +2079,8 @@ fn swap_exact_amount_out_exchanges_correct_values_with_cpmm() { assert_all_parameters( [239898989900, _26, _25, _25], 0, - [_101 + 101010100, _99, _100, _100], - _100, + [LIQUIDITY + _1 + 101010100, LIQUIDITY - _1, LIQUIDITY, LIQUIDITY], + LIQUIDITY, ); }); } @@ -2003,7 +2100,7 @@ fn swap_exact_amount_out_exchanges_correct_values_with_cpmm_with_fees() { 0, ScoringRule::CPMM, Some(BASE / 10), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, _2, _2, _2)), )); let pool_id = 0; @@ -2037,8 +2134,8 @@ fn swap_exact_amount_out_exchanges_correct_values_with_cpmm_with_fees() { assert_all_parameters( [_25 - asset_amount_in, _25 + asset_amount_out, _25, _25], 0, - [_100 + asset_amount_in, _100 - asset_amount_out, _100, _100], - _100, + [LIQUIDITY + asset_amount_in, LIQUIDITY - asset_amount_out, LIQUIDITY, LIQUIDITY], + LIQUIDITY, ); }); } @@ -2170,7 +2267,7 @@ fn create_pool_fails_on_too_many_assets() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(weights), ), crate::Error::::TooManyAssets @@ -2189,7 +2286,7 @@ fn create_pool_fails_on_too_few_assets() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, _2, _2, _2)), ), crate::Error::::TooFewAssets @@ -2208,7 +2305,7 @@ fn create_pool_fails_if_base_asset_is_not_in_asset_vector() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, _2, _2)), ), crate::Error::::BaseAssetNotFound @@ -2219,7 +2316,7 @@ fn create_pool_fails_if_base_asset_is_not_in_asset_vector() { #[test] fn create_pool_fails_if_swap_fee_is_too_high() { ExtBuilder::default().build().execute_with(|| { - let amount = ::MinLiquidity::get(); + let amount = _100; ASSETS.iter().cloned().for_each(|asset| { let _ = Currencies::deposit(asset, &BOB, amount); }); @@ -2242,7 +2339,7 @@ fn create_pool_fails_if_swap_fee_is_too_high() { #[test] fn create_pool_fails_if_swap_fee_is_unspecified_for_cpmm() { ExtBuilder::default().build().execute_with(|| { - let amount = ::MinLiquidity::get(); + let amount = _100; ASSETS.iter().cloned().for_each(|asset| { let _ = Currencies::deposit(asset, &BOB, amount); }); @@ -2273,12 +2370,12 @@ fn join_pool_exit_pool_does_not_create_extra_tokens() { let amount = 123_456_789_123; // Strange number to force rounding errors! assert_ok!(Swaps::pool_join( - Origin::signed(CHARLIE), + RuntimeOrigin::signed(CHARLIE), 0, amount, vec![_10000, _10000, _10000, _10000] )); - assert_ok!(Swaps::pool_exit(Origin::signed(CHARLIE), 0, amount, vec![0, 0, 0, 0])); + assert_ok!(Swaps::pool_exit(RuntimeOrigin::signed(CHARLIE), 0, amount, vec![0, 0, 0, 0])); // Check that the pool retains more tokens than before, and that Charlie loses some tokens // due to fees. @@ -2308,7 +2405,7 @@ fn create_pool_fails_on_weight_below_minimum_weight() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, ::MinWeight::get() - 1, _2, _2)), ), crate::Error::::BelowMinimumWeight, @@ -2330,7 +2427,7 @@ fn create_pool_fails_on_weight_above_maximum_weight() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_2, ::MaxWeight::get() + 1, _2, _2)), ), crate::Error::::AboveMaximumWeight, @@ -2353,7 +2450,7 @@ fn create_pool_fails_on_total_weight_above_maximum_total_weight() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec![weight; 4]), ), crate::Error::::MaxTotalWeight, @@ -2367,6 +2464,7 @@ fn create_pool_fails_on_insufficient_liquidity() { ASSETS.iter().cloned().for_each(|asset| { let _ = Currencies::deposit(asset, &BOB, _100); }); + let min_balance = Swaps::min_balance_of_pool(0, ASSETS.as_ref()); assert_noop!( Swaps::create_pool( BOB, @@ -2375,7 +2473,7 @@ fn create_pool_fails_on_insufficient_liquidity() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get() - 1), + Some(min_balance - 1), Some(vec!(_2, _2, _2, _2)), ), crate::Error::::InsufficientLiquidity, @@ -2383,6 +2481,36 @@ fn create_pool_fails_on_insufficient_liquidity() { }); } +#[test] +fn create_pool_succeeds_on_min_liquidity() { + ExtBuilder::default().build().execute_with(|| { + ASSETS.iter().cloned().for_each(|asset| { + let _ = Currencies::deposit(asset, &BOB, _100); + }); + // Only got one type of tokens in the pool, so we can sample the minimum balance using one + // asset. + let min_balance = Swaps::min_balance_of_pool(0, ASSETS.as_ref()); + assert_ok!(Swaps::create_pool( + BOB, + ASSETS.to_vec(), + *ASSETS.last().unwrap(), + 0, + ScoringRule::CPMM, + Some(0), + Some(min_balance), + Some(vec!(_2, _2, _2, _2)), + )); + assert_all_parameters( + [0; 4], + 0, + [min_balance, min_balance, min_balance, min_balance], + min_balance, + ); + let pool_shares_id = Swaps::pool_shares_id(0); + assert_eq!(Currencies::free_balance(pool_shares_id, &BOB), min_balance); + }); +} + #[test] fn create_pool_transfers_the_correct_amount_of_tokens() { ExtBuilder::default().build().execute_with(|| { @@ -2477,7 +2605,7 @@ fn open_pool_fails_if_pool_is_not_closed(pool_status: PoolStatus) { fn open_pool_succeeds_and_emits_correct_event_if_pool_exists() { ExtBuilder::default().build().execute_with(|| { frame_system::Pallet::::set_block_number(1); - let amount = ::MinLiquidity::get(); + let amount = _100; ASSETS.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, amount)); }); @@ -2617,7 +2745,7 @@ fn create_pool_correctly_associates_weights_with_assets() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec!(_1, _2, _3, _4)), )); let pool = Swaps::pool(0).unwrap(); @@ -2641,7 +2769,7 @@ fn single_asset_join_and_exit_are_inverse() { let pool_id = 0; assert_ok!(Currencies::deposit(asset, &ALICE, amount_in)); assert_ok!(Swaps::pool_join_with_exact_asset_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, asset, amount_in, @@ -2649,7 +2777,7 @@ fn single_asset_join_and_exit_are_inverse() { )); let pool_amount = Currencies::free_balance(Swaps::pool_shares_id(pool_id), &ALICE); assert_ok!(Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, asset, pool_amount, @@ -2678,7 +2806,7 @@ fn single_asset_operations_are_equivalent_to_swaps() { let pool_id = 0; assert_ok!(Currencies::deposit(asset_in, &ALICE, amount_in)); assert_ok!(Swaps::pool_join_with_exact_asset_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, asset_in, amount_in, @@ -2686,7 +2814,7 @@ fn single_asset_operations_are_equivalent_to_swaps() { )); let pool_amount = Currencies::free_balance(Swaps::pool_shares_id(pool_id), &ALICE); assert_ok!(Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, asset_out, pool_amount, @@ -2700,7 +2828,7 @@ fn single_asset_operations_are_equivalent_to_swaps() { let pool_id = 0; assert_ok!(Currencies::deposit(asset_in, &ALICE, amount_in)); assert_ok!(Swaps::swap_exact_amount_in( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, asset_in, amount_in, @@ -2723,7 +2851,7 @@ fn pool_join_with_uneven_balances() { let pool_id = 0; let pool_account_id = Swaps::pool_account_id(&pool_id); assert_ok!(Currencies::deposit(ASSET_A, &pool_account_id, _50)); - assert_ok!(Swaps::pool_join(Origin::signed(ALICE), pool_id, _10, vec![_100; 4])); + assert_ok!(Swaps::pool_join(RuntimeOrigin::signed(ALICE), pool_id, _10, vec![_100; 4])); assert_eq!(Currencies::free_balance(ASSET_A, &pool_account_id), _165); assert_eq!(Currencies::free_balance(ASSET_B, &pool_account_id), _110); assert_eq!(Currencies::free_balance(ASSET_C, &pool_account_id), _110); @@ -2764,7 +2892,7 @@ fn pool_exit_fails_if_balances_drop_too_low() { // We withdraw 99% of it, leaving 0.01 of each asset, which is below minimum balance. assert_noop!( - Swaps::pool_exit(Origin::signed(BOB), pool_id, _10, vec![0; 4]), + Swaps::pool_exit(RuntimeOrigin::signed(BOB), pool_id, _10, vec![0; 4]), crate::Error::::PoolDrain, ); }); @@ -2789,7 +2917,7 @@ fn pool_exit_fails_if_liquidity_drops_too_low() { // We withdraw too much liquidity but leave enough of each asset. assert_noop!( Swaps::pool_exit( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, _100 - Swaps::min_balance(Swaps::pool_shares_id(pool_id)) + 1, vec![0; 4] @@ -2831,7 +2959,7 @@ fn swap_exact_amount_in_fails_if_balances_drop_too_low() { assert_noop!( Swaps::swap_exact_amount_in( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, Swaps::min_balance(ASSET_A) / 10, @@ -2876,7 +3004,7 @@ fn swap_exact_amount_out_fails_if_balances_drop_too_low() { assert_noop!( Swaps::swap_exact_amount_out( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, Some(u128::MAX), @@ -2920,7 +3048,13 @@ fn pool_exit_with_exact_pool_amount_fails_if_balances_drop_too_low() { )); assert_noop!( - Swaps::pool_exit_with_exact_pool_amount(Origin::signed(BOB), pool_id, ASSET_A, _1, 0), + Swaps::pool_exit_with_exact_pool_amount( + RuntimeOrigin::signed(BOB), + pool_id, + ASSET_A, + _1, + 0 + ), crate::Error::::PoolDrain, ); }); @@ -2947,7 +3081,7 @@ fn pool_exit_with_exact_pool_amount_fails_if_liquidity_drops_too_low() { let ten_percent_of_pool = Swaps::min_balance(pool_shares_id) / 10; assert_noop!( Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, ASSET_A, ten_percent_of_pool, @@ -2991,7 +3125,7 @@ fn pool_exit_with_exact_asset_amount_fails_if_balances_drop_too_low() { let ten_percent_of_balance = Swaps::min_balance(ASSET_A) / 10; assert_noop!( Swaps::pool_exit_with_exact_asset_amount( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, ASSET_A, ten_percent_of_balance, @@ -3016,7 +3150,7 @@ fn pool_exit_with_exact_asset_amount_fails_if_liquidity_drops_too_low() { assert_noop!( Swaps::pool_exit_with_exact_asset_amount( - Origin::signed(BOB), + RuntimeOrigin::signed(BOB), pool_id, ASSET_A, _25, @@ -3034,7 +3168,7 @@ fn trading_functions_cache_pool_ids() { let pool_id = 0; assert_ok!(Swaps::pool_join_with_exact_pool_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, _2, @@ -3044,7 +3178,7 @@ fn trading_functions_cache_pool_ids() { PoolsCachedForArbitrage::::remove(pool_id); assert_ok!(Swaps::pool_join_with_exact_asset_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, _2, @@ -3054,7 +3188,7 @@ fn trading_functions_cache_pool_ids() { PoolsCachedForArbitrage::::remove(pool_id); assert_ok!(Swaps::pool_exit_with_exact_asset_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, _1, @@ -3064,7 +3198,7 @@ fn trading_functions_cache_pool_ids() { PoolsCachedForArbitrage::::remove(pool_id); assert_ok!(Swaps::pool_exit_with_exact_pool_amount( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, _1, @@ -3074,7 +3208,7 @@ fn trading_functions_cache_pool_ids() { PoolsCachedForArbitrage::::remove(pool_id); assert_ok!(Swaps::swap_exact_amount_in( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, _1, @@ -3086,7 +3220,7 @@ fn trading_functions_cache_pool_ids() { PoolsCachedForArbitrage::::remove(pool_id); assert_ok!(Swaps::swap_exact_amount_out( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), pool_id, ASSET_A, Some(u128::MAX), @@ -3115,13 +3249,13 @@ fn on_idle_skips_arbitrage_if_price_does_not_exceed_threshold() { 0, ScoringRule::CPMM, Some(0), - Some(::MinLiquidity::get()), + Some(LIQUIDITY), Some(vec![_3, _1, _1, _1]), )); let pool_id = 0; // Force the pool into the cache. crate::PoolsCachedForArbitrage::::insert(pool_id, ()); - Swaps::on_idle(System::block_number(), Weight::max_value()); + Swaps::on_idle(System::block_number(), Weight::MAX); System::assert_has_event(Event::ArbitrageSkipped(pool_id).into()); }); } @@ -3134,7 +3268,7 @@ fn on_idle_arbitrages_pools_with_mint_sell() { assets.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, _10000)); }); - let balance = ::MinLiquidity::get(); + let balance = _100; let base_asset = ASSET_A; assert_ok!(Swaps::create_pool( BOB, @@ -3156,7 +3290,7 @@ fn on_idle_arbitrages_pools_with_mint_sell() { // Force arbitrage hook. crate::PoolsCachedForArbitrage::::insert(pool_id, ()); - Swaps::on_idle(System::block_number(), Weight::max_value()); + Swaps::on_idle(System::block_number(), Weight::MAX); let arbitrage_amount = 49_537_658_690; assert_eq!( @@ -3184,7 +3318,7 @@ fn on_idle_arbitrages_pools_with_buy_burn() { assets.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, _10000)); }); - let balance = ::MinLiquidity::get(); + let balance = _100; let base_asset = ASSET_A; assert_ok!(Swaps::create_pool( BOB, @@ -3216,7 +3350,7 @@ fn on_idle_arbitrages_pools_with_buy_burn() { // Force arbitrage hook. crate::PoolsCachedForArbitrage::::insert(pool_id, ()); - Swaps::on_idle(System::block_number(), Weight::max_value()); + Swaps::on_idle(System::block_number(), Weight::MAX); assert_eq!( Currencies::free_balance(base_asset, &pool_account_id), @@ -3241,8 +3375,8 @@ fn apply_to_cached_pools_only_drains_requested_pools() { let number_of_pools_to_retain: u32 = 3; Swaps::apply_to_cached_pools( pool_count.saturated_into::() - number_of_pools_to_retain, - |_| Ok(0), - Weight::max_value(), + |_| Ok(Weight::zero()), + Weight::MAX, ); assert_eq!( PoolsCachedForArbitrage::::iter().count(), @@ -3263,7 +3397,7 @@ fn execute_arbitrage_correctly_observes_min_balance_buy_burn() { assets.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, _10000)); }); - let balance = ::MinLiquidity::get(); + let balance = _100; let base_asset = ASSET_A; assert_ok!(Swaps::create_pool( BOB, @@ -3322,7 +3456,7 @@ fn execute_arbitrage_observes_min_balances_mint_sell() { assets.iter().cloned().for_each(|asset| { assert_ok!(Currencies::deposit(asset, &BOB, _10000)); }); - let balance = ::MinLiquidity::get(); + let balance = _100; let base_asset = ASSET_A; assert_ok!(Swaps::create_pool( BOB, @@ -3379,8 +3513,8 @@ fn execute_arbitrage_observes_min_balances_mint_sell() { }); } -fn alice_signed() -> Origin { - Origin::signed(ALICE) +fn alice_signed() -> RuntimeOrigin { + RuntimeOrigin::signed(ALICE) } fn create_initial_pool( @@ -3402,11 +3536,7 @@ fn create_initial_pool( 0, scoring_rule, swap_fee, - if scoring_rule == ScoringRule::CPMM { - Some(::MinLiquidity::get()) - } else { - None - }, + if scoring_rule == ScoringRule::CPMM { Some(LIQUIDITY) } else { None }, if scoring_rule == ScoringRule::CPMM { Some(vec!(_2, _2, _2, _2)) } else { None }, )); if scoring_rule == ScoringRule::CPMM { @@ -3457,12 +3587,15 @@ fn subsidize_and_start_rikiddo_pool( ) { let min_subsidy = ::MinSubsidy::get(); assert_ok!(Currencies::deposit(ASSET_D, who, min_subsidy + extra)); - assert_ok!(Swaps::pool_join_subsidy(Origin::signed(*who), pool_id, min_subsidy)); + assert_ok!(Swaps::pool_join_subsidy(RuntimeOrigin::signed(*who), pool_id, min_subsidy)); assert!(Swaps::end_subsidy_phase(pool_id).unwrap().result); } -fn mock_market(categories: u16) -> Market { +fn mock_market( + categories: u16, +) -> Market> { Market { + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: 0, creator: ALICE, diff --git a/zrml/swaps/src/utils.rs b/zrml/swaps/src/utils.rs index 893c410b0..f35314271 100644 --- a/zrml/swaps/src/utils.rs +++ b/zrml/swaps/src/utils.rs @@ -1,3 +1,4 @@ +// Copyright 2022 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. diff --git a/zrml/swaps/src/weights.rs b/zrml/swaps/src/weights.rs index e12685039..fd6789496 100644 --- a/zrml/swaps/src/weights.rs +++ b/zrml/swaps/src/weights.rs @@ -1,3 +1,4 @@ +// Copyright 2022-2023 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,7 +19,7 @@ //! Autogenerated weights for zrml_swaps //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-25, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-16, STEPS: `10`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -80,70 +81,70 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) fn admin_clean_up_pool_cpmm_categorical(a: u32) -> Weight { - (57_698_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_027_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(58_170_398) + // Standard Error: 1_806 + .saturating_add(Weight::from_ref_time(565_711).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: MarketCommons Markets (r:1 w:0) // Storage: MarketCommons MarketPool (r:1 w:0) // Storage: Swaps Pools (r:1 w:1) fn admin_clean_up_pool_cpmm_scalar() -> Weight { - (52_361_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(53_560_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Swaps PoolsCachedForArbitrage (r:7 w:6) - // Storage: Swaps Pools (r:6 w:0) - // Storage: Tokens Accounts (r:396 w:396) - // Storage: System Account (r:6 w:0) + // Storage: Swaps PoolsCachedForArbitrage (r:8 w:7) + // Storage: Swaps Pools (r:7 w:0) + // Storage: Tokens Accounts (r:462 w:462) + // Storage: System Account (r:7 w:0) // Storage: Tokens TotalIssuance (r:64 w:64) fn apply_to_cached_pools_execute_arbitrage(a: u32) -> Weight { - (0 as Weight) - // Standard Error: 905_000 - .saturating_add((3_336_767_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(44 as Weight)) - .saturating_add(T::DbWeight::get().reads((69 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(44 as Weight)) - .saturating_add(T::DbWeight::get().writes((67 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(950_000) + // Standard Error: 425_528 + .saturating_add(Weight::from_ref_time(2_278_865_797).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(43)) + .saturating_add(T::DbWeight::get().reads((70_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(42)) + .saturating_add(T::DbWeight::get().writes((67_u64).saturating_mul(a.into()))) } - // Storage: Swaps PoolsCachedForArbitrage (r:7 w:6) + // Storage: Swaps PoolsCachedForArbitrage (r:8 w:7) fn apply_to_cached_pools_noop(a: u32) -> Weight { - (0 as Weight) - // Standard Error: 7_000 - .saturating_add((10_520_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(5_030_930) + // Standard Error: 8_315 + .saturating_add(Weight::from_ref_time(8_177_593).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:1) // Storage: Swaps SubsidyProviders (r:1 w:0) // Storage: RikiddoSigmoidFeeMarketEma RikiddoPerPool (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) fn destroy_pool_in_subsidy_phase(a: u32) -> Weight { - (44_428_000 as Weight) - // Standard Error: 17_000 - .saturating_add((25_843_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(51_577_376) + // Standard Error: 40_794 + .saturating_add(Weight::from_ref_time(20_795_563).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Tokens TotalIssuance (r:2 w:1) - // Storage: Tokens Accounts (r:46 w:22) - // Storage: System Account (r:2 w:1) + // Storage: Tokens Accounts (r:46 w:21) + // Storage: System Account (r:11 w:10) fn distribute_pool_share_rewards(a: u32, b: u32) -> Weight { - (29_974_000 as Weight) - // Standard Error: 77_000 - .saturating_add((43_084_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 77_000 - .saturating_add((50_328_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight))) + Weight::from_ref_time(109_037_971) + // Standard Error: 137_890 + .saturating_add(Weight::from_ref_time(22_311_542).saturating_mul(a.into())) + // Standard Error: 137_890 + .saturating_add(Weight::from_ref_time(43_711_337).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into()))) } // Storage: Swaps Pools (r:1 w:1) // Storage: Swaps SubsidyProviders (r:11 w:10) @@ -152,70 +153,72 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: Tokens TotalIssuance (r:2 w:2) // Storage: RikiddoSigmoidFeeMarketEma RikiddoPerPool (r:1 w:0) fn end_subsidy_phase(a: u32, b: u32) -> Weight { - (0 as Weight) - // Standard Error: 194_000 - .saturating_add((36_944_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_231_000 - .saturating_add((175_983_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().reads((9 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes((9 as Weight).saturating_mul(b as Weight))) + Weight::from_ref_time(28_320_000) + // Standard Error: 86_902 + .saturating_add(Weight::from_ref_time(19_686_690).saturating_mul(a.into())) + // Standard Error: 577_146 + .saturating_add(Weight::from_ref_time(85_851_591).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(b.into()))) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:3 w:3) // Storage: System Account (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) fn execute_arbitrage_buy_burn(a: u32) -> Weight { - (0 as Weight) - // Standard Error: 18_000 - .saturating_add((52_561_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(85_487_346) + // Standard Error: 39_317 + .saturating_add(Weight::from_ref_time(35_613_473).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:3 w:3) // Storage: System Account (r:2 w:1) // Storage: Tokens TotalIssuance (r:1 w:1) fn execute_arbitrage_mint_sell(a: u32) -> Weight { - (19_956_000 as Weight) - // Standard Error: 16_000 - .saturating_add((48_596_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(88_354_876) + // Standard Error: 38_137 + .saturating_add(Weight::from_ref_time(33_290_909).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:2 w:0) fn execute_arbitrage_skipped(a: u32) -> Weight { - (16_944_000 as Weight) - // Standard Error: 3_000 - .saturating_add((9_053_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(34_149_355) + // Standard Error: 3_877 + .saturating_add(Weight::from_ref_time(4_760_669).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: Tokens Accounts (r:5 w:5) // Storage: System Account (r:1 w:0) fn pool_exit(a: u32) -> Weight { - (47_671_000 as Weight) - // Standard Error: 17_000 - .saturating_add((39_937_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(71_597_112) + // Standard Error: 31_790 + .saturating_add(Weight::from_ref_time(27_110_684).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:1) // Storage: Swaps SubsidyProviders (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) fn pool_exit_subsidy() -> Weight { - (86_760_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(79_620_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:3 w:3) @@ -223,9 +226,9 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: System Account (r:1 w:0) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn pool_exit_with_exact_asset_amount() -> Weight { - (184_191_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(144_091_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) @@ -233,64 +236,64 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: System Account (r:1 w:0) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn pool_exit_with_exact_pool_amount() -> Weight { - (184_751_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(145_410_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: Tokens Accounts (r:5 w:5) fn pool_join(a: u32) -> Weight { - (42_632_000 as Weight) - // Standard Error: 14_000 - .saturating_add((36_906_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(66_902_178) + // Standard Error: 35_145 + .saturating_add(Weight::from_ref_time(26_627_552).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } // Storage: Swaps Pools (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) // Storage: Swaps SubsidyProviders (r:1 w:1) fn pool_join_subsidy() -> Weight { - (88_700_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(81_541_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: Tokens Accounts (r:3 w:3) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn pool_join_with_exact_asset_amount() -> Weight { - (165_460_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(130_781_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens TotalIssuance (r:1 w:1) // Storage: Tokens Accounts (r:3 w:3) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn pool_join_with_exact_pool_amount() -> Weight { - (162_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(131_360_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:1) fn clean_up_pool_categorical_without_reward_distribution(a: u32) -> Weight { - (11_083_000 as Weight) - // Standard Error: 1_000 - .saturating_add((581_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(15_637_896) + // Standard Error: 915 + .saturating_add(Weight::from_ref_time(352_368).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:4 w:4) // Storage: System Account (r:1 w:0) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn swap_exact_amount_in_cpmm() -> Weight { - (223_361_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(172_211_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:3 w:3) @@ -299,21 +302,21 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn swap_exact_amount_in_rikiddo(a: u32) -> Weight { - (140_111_000 as Weight) - // Standard Error: 10_000 - .saturating_add((25_517_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(182_553_505) + // Standard Error: 21_078 + .saturating_add(Weight::from_ref_time(17_637_755).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:4 w:4) // Storage: System Account (r:1 w:0) // Storage: Swaps PoolsCachedForArbitrage (r:0 w:1) fn swap_exact_amount_out_cpmm() -> Weight { - (217_140_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(171_171_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:0) // Storage: Tokens Accounts (r:4 w:3) @@ -321,39 +324,40 @@ impl WeightInfoZeitgeist for WeightInfo { // Storage: RikiddoSigmoidFeeMarketEma RikiddoPerPool (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn swap_exact_amount_out_rikiddo(a: u32) -> Weight { - (73_337_000 as Weight) - // Standard Error: 10_000 - .saturating_add((45_756_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(83_162_756) + // Standard Error: 54_784 + .saturating_add(Weight::from_ref_time(33_550_034).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: Swaps Pools (r:1 w:1) fn open_pool(a: u32) -> Weight { - (26_996_000 as Weight) - // Standard Error: 1_000 - .saturating_add((880_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(30_971_080) + // Standard Error: 1_312 + .saturating_add(Weight::from_ref_time(478_368).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Swaps Pools (r:1 w:1) fn close_pool(a: u32) -> Weight { - (25_651_000 as Weight) - // Standard Error: 1_000 - .saturating_add((650_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(28_580_115) + // Standard Error: 1_191 + .saturating_add(Weight::from_ref_time(370_645).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Swaps Pools (r:1 w:1) // Storage: Tokens Accounts (r:2 w:2) + // Storage: System Account (r:1 w:1) // Storage: Tokens TotalIssuance (r:2 w:2) fn destroy_pool(a: u32) -> Weight { - (0 as Weight) - // Standard Error: 14_000 - .saturating_add((33_316_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(a as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(a as Weight))) + Weight::from_ref_time(50_684_702) + // Standard Error: 34_331 + .saturating_add(Weight::from_ref_time(25_852_777).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) } }