From 838d67f3337f9ff509aa503d1bfa0dcfa29afaf8 Mon Sep 17 00:00:00 2001 From: Malte Kliemann Date: Sun, 11 Aug 2024 13:11:37 +0200 Subject: [PATCH] Merge release v0.5.3 (#1349) * Revert "New Asset System (#1295)" (#1338) * Revert "New Asset System (#1295)" This reverts commit a956877d596ac41d8bda5c341b35472ef915fa18. * Fix formatting * Update copyright * Remove pallet-assets dependency * Fix fuzz tests * Merge `main` into `develop` (#1345) * Update dependencies to Polkadot v1.1.0 (#1331) * Update dependencies (#1319) * Update dependencies to polkadot-v1.1.0 * Format code * Remove duplicate dependencies * Update zrml-asset-router (#1321) * Update zrml-primitives * Partially update asset-router * Finalize logic adjustments in asset-router * Make asset-router tests compilable * Correct Inspect routing for market assets in Currencies * Directly invoke Inspect API for Currencies * Add tests for remaining Unbalances functions * Update remaining Zeitgeist pallets (#1322) * Update zrml-asset-router (#1321) * Upgrade zrml-market-commons * Upgrade zrml-authorized && use MockBlock instead of MockBlockU32 * Upgrade zrml-court * Upgrade zrml-global-disputes * Upgrade liquidity mining * Upgrade zrml-rikiddo * Upgrade zrml-simple-disputes * Upgrade zrml-styx * Upgrade zrml-orderbook * Upgrade zrml-parimutuel * Upgrade zrml-swaps * Upgrade zrml-prediction-markets * Upgrade zrml-neo-swaps * Upgrade zrml-hybrid-router * Update license headers * Update runtime (#1323) * Update weight files & Runtime enum * Use workspace metadata * Always use serde serialization for asset types * Make battery station standalone runtime compilable * Make benchmark and try-runtime feature compilable * Make BS build with all features * Make parachain tests compile * Partially fix xcm tests * Use safe xcm version 2 * Update Zeitgeist runtime (except xcm tests) * Format code * Remove deprecated comment * Integrate new xcm-emulator (#1324) * Integrate new xcm-emulator environment * Utilize new xcm-emulator interfaces * Spawn relay-para network using patched xcm-emulator * Use proper collator genesis config * Fix Rococo tests * Finalize Battery Station XCM tests * Finalize Zeitgeist XCM tests * Update client (#1327) * Fix rpc and work on client update * Finalize standalone client * Update parachain client * Use same try-runtime subcommand in every case * Update node/src/cli.rs Co-authored-by: Malte Kliemann * Update try-runtime* Makefile targets --------- Co-authored-by: Malte Kliemann * Make CI succeed and add migrations (#1329) * Fix rpc and work on client update * Finalize standalone client * Update parachain client * Use same try-runtime subcommand in every case * Satisfy Clippy * Fix benchmarks * Add migrations * Satisfy Clippy * Update moonkit depedencies * Free disk space more aggressively --------- Co-authored-by: Malte Kliemann * Update spec version, try-runtime Makefile * Fix copyright notices * Fix broken chain state (#1336) * Add `StorageVersion` fix and contrats fix migrations * Don't set pallet-balances' storage version * Remove migrations from pallet-contracts config * Clear storage tries of contracts * Fix migration and info logs in try-runtime * Fix licenses and comments * Fix formatting --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --------- Co-authored-by: Harald Heckmann Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Merge * Fix benchmark * Fix compiler error * Fix tests and imports * Fix imports (again...) * Fix orderbook benchmarks * Fix fuzz tests * Fix formatting * Fix orderbook fuzz --------- Co-authored-by: Harald Heckmann Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Update versions to v0.5.3 * Fix Makefile * Change endpoint of integration tests * Fix copyright notices * Run benchmarks --------- Co-authored-by: Harald Heckmann Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Your Name --- CODEOWNERS | 1 - Cargo.lock | 40 +- Cargo.toml | 11 +- Makefile | 2 +- README.md | 2 - docs/changelog_for_devs.md | 24 +- integration-tests/configs/zeitgeist.yml | 6 +- macros/src/lib.rs | 8 +- primitives/Cargo.toml | 1 - primitives/src/{assets.rs => asset.rs} | 64 +- primitives/src/assets/all_assets.rs | 171 -- primitives/src/assets/campaign_assets.rs | 63 - primitives/src/assets/currencies.rs | 88 -- primitives/src/assets/custom_assets.rs | 61 - primitives/src/assets/market_assets.rs | 74 - primitives/src/assets/subsets/base_assets.rs | 62 - primitives/src/assets/subsets/mod.rs | 26 - primitives/src/assets/subsets/parimutuel.rs | 51 - primitives/src/assets/subsets/xcm_assets.rs | 57 - primitives/src/assets/tests.rs | 24 - primitives/src/assets/tests/conversion.rs | 358 ----- primitives/src/assets/tests/scale_codec.rs | 146 -- primitives/src/constants.rs | 2 +- primitives/src/constants/base_multiples.rs | 2 - primitives/src/constants/mock.rs | 36 +- primitives/src/lib.rs | 3 +- primitives/src/market.rs | 192 ++- primitives/src/serde_wrapper.rs | 66 + primitives/src/traits.rs | 2 - primitives/src/traits/dispute_api.rs | 10 +- primitives/src/traits/market_builder.rs | 26 +- .../src/traits/market_commons_pallet_api.rs | 9 +- primitives/src/traits/market_id.rs | 14 +- .../src/traits/market_transition_api.rs | 322 ---- primitives/src/traits/swaps.rs | 9 +- primitives/src/types.rs | 41 +- runtime/battery-station/Cargo.toml | 7 - .../xcm/genesis/battery_station.rs | 9 +- .../src/integration_tests/xcm/setup.rs | 13 +- .../xcm/tests/currency_id_convert.rs | 59 +- .../integration_tests/xcm/tests/transfers.rs | 59 +- runtime/battery-station/src/lib.rs | 33 +- runtime/battery-station/src/parameters.rs | 65 +- .../src/xcm_config/asset_registry.rs | 10 +- .../battery-station/src/xcm_config/config.rs | 166 +- .../battery-station/src/xcm_config/fees.rs | 4 +- runtime/common/Cargo.toml | 2 - runtime/common/src/fees.rs | 436 ++---- runtime/common/src/lib.rs | 278 +--- .../src/weights/cumulus_pallet_xcmp_queue.rs | 28 +- runtime/common/src/weights/frame_system.rs | 91 +- runtime/common/src/weights/mod.rs | 1 - runtime/common/src/weights/orml_currencies.rs | 82 +- runtime/common/src/weights/orml_tokens.rs | 88 +- .../src/weights/pallet_author_inherent.rs | 36 +- .../src/weights/pallet_author_mapping.rs | 98 +- .../src/weights/pallet_author_slot_filter.rs | 12 +- runtime/common/src/weights/pallet_balances.rs | 118 +- runtime/common/src/weights/pallet_bounties.rs | 202 +-- .../common/src/weights/pallet_collective.rs | 340 ++-- .../common/src/weights/pallet_contracts.rs | 1370 ++++++++-------- .../common/src/weights/pallet_democracy.rs | 660 ++++---- runtime/common/src/weights/pallet_identity.rs | 354 ++--- .../common/src/weights/pallet_membership.rs | 210 +-- runtime/common/src/weights/pallet_multisig.rs | 124 +- .../src/weights/pallet_parachain_staking.rs | 1374 +++++++++-------- runtime/common/src/weights/pallet_preimage.rs | 162 +- runtime/common/src/weights/pallet_proxy.rs | 198 +-- .../common/src/weights/pallet_scheduler.rs | 160 +- .../common/src/weights/pallet_timestamp.rs | 24 +- runtime/common/src/weights/pallet_treasury.rs | 128 +- runtime/common/src/weights/pallet_utility.rs | 36 +- runtime/common/src/weights/pallet_vesting.rs | 252 +-- runtime/zeitgeist/Cargo.toml | 7 - .../xcm/genesis/zeitgeist.rs | 11 +- .../src/integration_tests/xcm/setup.rs | 15 +- .../src/integration_tests/xcm/test_net.rs | 1 - .../xcm/tests/currency_id_convert.rs | 57 +- .../integration_tests/xcm/tests/transfers.rs | 74 +- runtime/zeitgeist/src/lib.rs | 33 +- runtime/zeitgeist/src/parameters.rs | 63 +- .../src/xcm_config/asset_registry.rs | 10 +- runtime/zeitgeist/src/xcm_config/config.rs | 162 +- runtime/zeitgeist/src/xcm_config/fees.rs | 4 +- scripts/benchmarks/configuration.sh | 6 +- zrml/asset-router/Cargo.toml | 39 - zrml/asset-router/README.md | 61 - zrml/asset-router/src/lib.rs | 520 ------- zrml/asset-router/src/macros.rs | 151 -- zrml/asset-router/src/mock.rs | 299 ---- zrml/asset-router/src/pallet_impl/balanced.rs | 24 - zrml/asset-router/src/pallet_impl/create.rs | 37 - zrml/asset-router/src/pallet_impl/destroy.rs | 42 - zrml/asset-router/src/pallet_impl/inspect.rs | 77 - .../src/pallet_impl/managed_destroy.rs | 73 - zrml/asset-router/src/pallet_impl/mod.rs | 29 - .../src/pallet_impl/multi_currency.rs | 277 ---- .../pallet_impl/multi_currency_extended.rs | 80 - .../pallet_impl/multi_lockable_currency.rs | 81 - .../pallet_impl/multi_reserveable_currency.rs | 82 - .../named_multi_reserveable_currency.rs | 130 -- .../src/pallet_impl/transfer_all.rs | 26 - .../src/pallet_impl/unbalanced.rs | 95 -- zrml/asset-router/src/tests/create.rs | 61 - zrml/asset-router/src/tests/custom_types.rs | 86 -- zrml/asset-router/src/tests/destroy.rs | 101 -- zrml/asset-router/src/tests/inspect.rs | 132 -- .../asset-router/src/tests/managed_destroy.rs | 337 ---- zrml/asset-router/src/tests/mod.rs | 48 - zrml/asset-router/src/tests/multi_currency.rs | 152 -- .../src/tests/multi_lockable_currency.rs | 99 -- .../src/tests/multi_reservable_currency.rs | 100 -- .../tests/named_multi_reservable_currency.rs | 118 -- zrml/asset-router/src/tests/unbalanced.rs | 166 -- zrml/asset-router/src/types.rs | 120 -- zrml/authorized/src/lib.rs | 9 +- zrml/authorized/src/weights.rs | 92 +- zrml/court/src/benchmarks.rs | 4 +- zrml/court/src/lib.rs | 13 +- zrml/court/src/tests.rs | 8 +- zrml/court/src/weights.rs | 586 +++---- zrml/global-disputes/src/utils.rs | 3 +- zrml/global-disputes/src/weights.rs | 226 +-- zrml/hybrid-router/Cargo.toml | 5 - zrml/hybrid-router/src/benchmarking.rs | 44 +- zrml/hybrid-router/src/lib.rs | 14 +- zrml/hybrid-router/src/mock.rs | 189 +-- zrml/hybrid-router/src/tests/buy.rs | 97 +- zrml/hybrid-router/src/tests/mod.rs | 19 +- zrml/hybrid-router/src/tests/sell.rs | 96 +- zrml/hybrid-router/src/utils.rs | 10 +- zrml/hybrid-router/src/weights.rs | 124 +- zrml/liquidity-mining/src/tests.rs | 6 +- zrml/liquidity-mining/src/weights.rs | 12 +- zrml/market-commons/src/lib.rs | 19 +- zrml/market-commons/src/migrations.rs | 374 ----- zrml/market-commons/src/tests.rs | 4 +- .../src/types/market_builder.rs | 22 +- zrml/neo-swaps/Cargo.toml | 8 +- zrml/neo-swaps/src/benchmarking.rs | 2 +- zrml/neo-swaps/src/lib.rs | 10 +- zrml/neo-swaps/src/macros.rs | 6 +- zrml/neo-swaps/src/mock.rs | 193 +-- zrml/neo-swaps/src/tests/buy.rs | 2 + zrml/neo-swaps/src/tests/deploy_pool.rs | 52 +- zrml/neo-swaps/src/tests/join.rs | 3 +- zrml/neo-swaps/src/tests/mod.rs | 18 +- zrml/neo-swaps/src/tests/sell.rs | 2 +- zrml/neo-swaps/src/types/max_assets.rs | 2 +- zrml/neo-swaps/src/weights.rs | 266 ++-- zrml/orderbook/Cargo.toml | 14 +- zrml/orderbook/src/benchmarks.rs | 6 +- zrml/orderbook/src/lib.rs | 201 ++- zrml/orderbook/src/mock.rs | 160 +- zrml/orderbook/src/tests.rs | 286 +--- zrml/orderbook/src/utils.rs | 9 +- zrml/orderbook/src/weights.rs | 80 +- zrml/parimutuel/Cargo.toml | 5 - zrml/parimutuel/src/benchmarking.rs | 84 +- zrml/parimutuel/src/lib.rs | 257 +-- zrml/parimutuel/src/mock.rs | 178 +-- zrml/parimutuel/src/tests/buy.rs | 67 +- zrml/parimutuel/src/tests/claim.rs | 103 +- zrml/parimutuel/src/tests/mod.rs | 1 - zrml/parimutuel/src/tests/refund.rs | 51 +- zrml/parimutuel/src/utils.rs | 4 +- zrml/parimutuel/src/weights.rs | 134 +- zrml/prediction-markets/Cargo.toml | 8 +- .../fuzz/pm_full_workflow.rs | 4 +- .../prediction-markets/runtime-api/src/lib.rs | 6 +- zrml/prediction-markets/src/benchmarks.rs | 18 +- zrml/prediction-markets/src/lib.rs | 203 +-- zrml/prediction-markets/src/mock.rs | 261 +--- .../src/tests/admin_move_market_to_closed.rs | 10 +- .../tests/admin_move_market_to_resolved.rs | 17 +- .../src/tests/approve_market.rs | 33 +- .../src/tests/buy_complete_set.rs | 30 +- ...lose_market.rs => close_trusted_market.rs} | 23 +- .../src/tests/create_market.rs | 80 +- .../tests/create_market_and_deploy_pool.rs | 2 +- zrml/prediction-markets/src/tests/dispute.rs | 45 +- .../src/tests/dispute_early_close.rs | 16 +- .../src/tests/edit_market.rs | 18 +- .../src/tests/integration.rs | 81 +- .../src/tests/manually_close_market.rs | 8 +- zrml/prediction-markets/src/tests/mod.rs | 51 +- .../src/tests/on_initialize.rs | 2 +- .../src/tests/on_market_close.rs | 30 +- .../src/tests/on_resolution.rs | 140 +- .../src/tests/redeem_shares.rs | 56 +- .../src/tests/reject_early_close.rs | 10 +- .../src/tests/reject_market.rs | 25 +- zrml/prediction-markets/src/tests/report.rs | 66 +- .../src/tests/request_edit.rs | 6 +- .../src/tests/schedule_early_close.rs | 12 +- .../src/tests/sell_complete_set.rs | 33 +- .../src/tests/start_global_dispute.rs | 2 +- zrml/prediction-markets/src/weights.rs | 1074 ++++++------- zrml/simple-disputes/src/lib.rs | 7 +- zrml/simple-disputes/src/mock.rs | 10 +- zrml/simple-disputes/src/tests.rs | 4 +- zrml/styx/src/weights.rs | 26 +- zrml/swaps/Cargo.toml | 4 +- zrml/swaps/fuzz/create_pool.rs | 7 +- zrml/swaps/fuzz/pool_exit.rs | 14 +- .../fuzz/pool_exit_with_exact_asset_amount.rs | 15 +- .../fuzz/pool_exit_with_exact_pool_amount.rs | 14 +- zrml/swaps/fuzz/pool_join.rs | 14 +- .../fuzz/pool_join_with_exact_asset_amount.rs | 14 +- .../fuzz/pool_join_with_exact_pool_amount.rs | 14 +- zrml/swaps/fuzz/swap_exact_amount_in.rs | 20 +- zrml/swaps/fuzz/swap_exact_amount_out.rs | 12 +- zrml/swaps/rpc/src/lib.rs | 30 +- zrml/swaps/runtime-api/src/lib.rs | 14 +- zrml/swaps/src/benchmarks.rs | 6 +- zrml/swaps/src/lib.rs | 54 +- zrml/swaps/src/mock.rs | 18 +- zrml/swaps/src/utils.rs | 20 +- zrml/swaps/src/weights.rs | 290 ++-- 219 files changed, 6463 insertions(+), 14143 deletions(-) rename primitives/src/{assets.rs => asset.rs} (54%) delete mode 100644 primitives/src/assets/all_assets.rs delete mode 100644 primitives/src/assets/campaign_assets.rs delete mode 100644 primitives/src/assets/currencies.rs delete mode 100644 primitives/src/assets/custom_assets.rs delete mode 100644 primitives/src/assets/market_assets.rs delete mode 100644 primitives/src/assets/subsets/base_assets.rs delete mode 100644 primitives/src/assets/subsets/mod.rs delete mode 100644 primitives/src/assets/subsets/parimutuel.rs delete mode 100644 primitives/src/assets/subsets/xcm_assets.rs delete mode 100644 primitives/src/assets/tests.rs delete mode 100644 primitives/src/assets/tests/conversion.rs delete mode 100644 primitives/src/assets/tests/scale_codec.rs create mode 100644 primitives/src/serde_wrapper.rs delete mode 100644 primitives/src/traits/market_transition_api.rs delete mode 100644 zrml/asset-router/Cargo.toml delete mode 100644 zrml/asset-router/README.md delete mode 100644 zrml/asset-router/src/lib.rs delete mode 100644 zrml/asset-router/src/macros.rs delete mode 100644 zrml/asset-router/src/mock.rs delete mode 100644 zrml/asset-router/src/pallet_impl/balanced.rs delete mode 100644 zrml/asset-router/src/pallet_impl/create.rs delete mode 100644 zrml/asset-router/src/pallet_impl/destroy.rs delete mode 100644 zrml/asset-router/src/pallet_impl/inspect.rs delete mode 100644 zrml/asset-router/src/pallet_impl/managed_destroy.rs delete mode 100644 zrml/asset-router/src/pallet_impl/mod.rs delete mode 100644 zrml/asset-router/src/pallet_impl/multi_currency.rs delete mode 100644 zrml/asset-router/src/pallet_impl/multi_currency_extended.rs delete mode 100644 zrml/asset-router/src/pallet_impl/multi_lockable_currency.rs delete mode 100644 zrml/asset-router/src/pallet_impl/multi_reserveable_currency.rs delete mode 100644 zrml/asset-router/src/pallet_impl/named_multi_reserveable_currency.rs delete mode 100644 zrml/asset-router/src/pallet_impl/transfer_all.rs delete mode 100644 zrml/asset-router/src/pallet_impl/unbalanced.rs delete mode 100644 zrml/asset-router/src/tests/create.rs delete mode 100644 zrml/asset-router/src/tests/custom_types.rs delete mode 100644 zrml/asset-router/src/tests/destroy.rs delete mode 100644 zrml/asset-router/src/tests/inspect.rs delete mode 100644 zrml/asset-router/src/tests/managed_destroy.rs delete mode 100644 zrml/asset-router/src/tests/mod.rs delete mode 100644 zrml/asset-router/src/tests/multi_currency.rs delete mode 100644 zrml/asset-router/src/tests/multi_lockable_currency.rs delete mode 100644 zrml/asset-router/src/tests/multi_reservable_currency.rs delete mode 100644 zrml/asset-router/src/tests/named_multi_reservable_currency.rs delete mode 100644 zrml/asset-router/src/tests/unbalanced.rs delete mode 100644 zrml/asset-router/src/types.rs rename zrml/prediction-markets/src/tests/{close_market.rs => close_trusted_market.rs} (91%) diff --git a/CODEOWNERS b/CODEOWNERS index 03f736322..059ede2ac 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,7 +8,6 @@ # Ignore everything but mod.rs in /runtime/common/src/weights/ /runtime/common/src/weights/* /runtime/common/src/weights/mod.rs @sea212 -/zrml/asset-router/ @sea212 /zrml/authorized/ @Chralt98 /zrml/court/ @Chralt98 /zrml/global-disputes/ @Chralt98 diff --git a/Cargo.lock b/Cargo.lock index b2d23edff..279e2b189 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -819,7 +819,6 @@ dependencies = [ "orml-xcm-support", "orml-xtokens", "pallet-asset-tx-payment", - "pallet-assets", "pallet-aura", "pallet-author-inherent", "pallet-author-mapping", @@ -882,7 +881,6 @@ dependencies = [ "test-case", "xcm-emulator", "zeitgeist-primitives", - "zrml-asset-router", "zrml-authorized", "zrml-court", "zrml-global-disputes", @@ -1460,7 +1458,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "pallet-asset-tx-payment", - "pallet-assets", "pallet-author-inherent", "pallet-author-mapping", "pallet-author-slot-filter", @@ -6137,7 +6134,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/zeitgeistpm/polkadot-sdk?branch=zeitgeist-polkadot-v1.1.0#6dd8bed6e375b6310fb990b7baa5a30f5f7ccada" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#39482e78cc1580c9f16a8f8d8261baf914ab5559" dependencies = [ "frame-benchmarking", "frame-support", @@ -14940,7 +14937,6 @@ dependencies = [ "fixed", "frame-support", "frame-system", - "impl-trait-for-tuples", "more-asserts", "num-traits", "orml-currencies", @@ -14989,7 +14985,6 @@ dependencies = [ "orml-xcm-support", "orml-xtokens", "pallet-asset-tx-payment", - "pallet-assets", "pallet-aura", "pallet-author-inherent", "pallet-author-mapping", @@ -15050,7 +15045,6 @@ dependencies = [ "test-case", "xcm-emulator", "zeitgeist-primitives", - "zrml-asset-router", "zrml-authorized", "zrml-court", "zrml-global-disputes", @@ -15108,26 +15102,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "zrml-asset-router" -version = "0.5.3" -dependencies = [ - "frame-support", - "frame-system", - "log", - "orml-tokens", - "orml-traits", - "pallet-assets", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "test-case", - "zeitgeist-macros", - "zeitgeist-primitives", -] - [[package]] name = "zrml-authorized" version = "0.5.3" @@ -15208,7 +15182,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "orml-traits", - "pallet-assets", "pallet-balances", "pallet-insecure-randomness-collective-flip", "pallet-timestamp", @@ -15223,7 +15196,6 @@ dependencies = [ "staging-xcm-builder", "test-case", "zeitgeist-primitives", - "zrml-asset-router", "zrml-authorized", "zrml-court", "zrml-global-disputes", @@ -15292,7 +15264,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "orml-traits", - "pallet-assets", "pallet-balances", "pallet-insecure-randomness-collective-flip", "pallet-timestamp", @@ -15309,7 +15280,6 @@ dependencies = [ "test-case", "typenum", "zeitgeist-primitives", - "zrml-asset-router", "zrml-authorized", "zrml-court", "zrml-global-disputes", @@ -15333,7 +15303,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "orml-traits", - "pallet-assets", "pallet-balances", "pallet-timestamp", "parity-scale-codec", @@ -15341,9 +15310,7 @@ dependencies = [ "sp-io", "sp-runtime", "test-case", - "zeitgeist-macros", "zeitgeist-primitives", - "zrml-asset-router", "zrml-market-commons", "zrml-orderbook", ] @@ -15371,7 +15338,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "orml-traits", - "pallet-assets", "pallet-balances", "pallet-timestamp", "parity-scale-codec", @@ -15379,9 +15345,7 @@ dependencies = [ "sp-io", "sp-runtime", "test-case", - "zeitgeist-macros", "zeitgeist-primitives", - "zrml-asset-router", "zrml-market-commons", ] @@ -15400,7 +15364,6 @@ dependencies = [ "orml-currencies", "orml-tokens", "orml-traits", - "pallet-assets", "pallet-balances", "pallet-insecure-randomness-collective-flip", "pallet-timestamp", @@ -15415,7 +15378,6 @@ dependencies = [ "staging-xcm", "test-case", "zeitgeist-primitives", - "zrml-asset-router", "zrml-authorized", "zrml-court", "zrml-global-disputes", diff --git a/Cargo.toml b/Cargo.toml index c8deb0325..784f637e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ default-members = [ "runtime/battery-station", "runtime/zeitgeist", "zrml/authorized", - "zrml/asset-router", "zrml/court", "zrml/hybrid-router", "zrml/global-disputes", @@ -40,7 +39,6 @@ members = [ "runtime/battery-station", "runtime/zeitgeist", "zrml/authorized", - "zrml/asset-router", "zrml/court", "zrml/hybrid-router", "zrml/global-disputes", @@ -254,7 +252,6 @@ zrml-swaps-rpc = { path = "zrml/swaps/rpc" } common-runtime = { path = "runtime/common", default-features = false } zeitgeist-macros = { path = "macros", default-features = false } zeitgeist-primitives = { path = "primitives", default-features = false } -zrml-asset-router = { path = "zrml/asset-router", default-features = false } zrml-authorized = { path = "zrml/authorized", default-features = false } zrml-court = { path = "zrml/court", default-features = false } zrml-global-disputes = { path = "zrml/global-disputes", default-features = false } @@ -287,7 +284,6 @@ arbitrary = { version = "1.3.2", default-features = false } arrayvec = { version = "0.7.4", default-features = false } cfg-if = { version = "1.0.0" } fixed = { version = "=1.15.0", default-features = false, features = ["num-traits"] } -impl-trait-for-tuples = { version = "0.2.2" } # Hashbrown works in no_std by default and default features are used in Rikiddo hashbrown = { version = "0.14.3", default-features = true } hex-literal = { version = "0.4.1", default-features = false } @@ -354,14 +350,11 @@ opt-level = 3 # Zeitgeist runtime requires unwinding. panic = "unwind" -[patch."https://github.com/paritytech/polkadot-sdk"] -# pallet-asset adjustments (managed asset destruction) -# Commits: -# - cb803be8cdc52d020890308a2076d752a8c4ce5c -pallet-assets = { git = "https://github.com/zeitgeistpm/polkadot-sdk", branch = "zeitgeist-polkadot-v1.1.0" } + # xcm-emulator incompatible block number type fixed # Commits: # - +[patch."https://github.com/paritytech/polkadot-sdk"] xcm-emulator = { git = "https://github.com/zeitgeistpm/polkadot-sdk", branch = "release-polkadot-v1.1.0-xcm-emulator-type-fix" } [patch."https://github.com/galacticcouncil/HydraDX-node"] diff --git a/Makefile b/Makefile index feb781af6..c4b4241c1 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ try-runtime-upgrade-zeitgeist: @$(MAKE) TRYRUNTIME_URL="wss://zeitgeist-rpc.dwellir.com:443" \ RUNTIME_PATH="./target/release/wbuild/zeitgeist-runtime/zeitgeist_runtime.compact.compressed.wasm" \ -- \ - -execute--try-runtime + --execute-try-runtime build: SKIP_WASM_BUILD= cargo build diff --git a/README.md b/README.md index 1fa93686c..7350560e5 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ decentralized court. ## Modules -- [asset-router](./zrml/asset-router) - Routes all asset classes to the - respective pallets and provides a garbage collection for destructible assets. - [authorized](./zrml/authorized) - Offers authorized resolution of disputes. - [court](./zrml/court) - An implementation of a court mechanism used to resolve disputes in a decentralized fashion. diff --git a/docs/changelog_for_devs.md b/docs/changelog_for_devs.md index e12a38733..69c4109a4 100644 --- a/docs/changelog_for_devs.md +++ b/docs/changelog_for_devs.md @@ -128,28 +128,22 @@ if ztg_supply / campaign_asset_supply >= 100 { [#1197]: https://github.com/zeitgeistpm/zeitgeist/pull/1197 [#1178]: https://github.com/zeitgeistpm/zeitgeist/pull/1178 -### Changed +### Changes -- ⚠️ Move the `zeitgeist_primitives::Pool` struct to `zrml_swaps::types::Pool` - and change the following fields ([#1197]): - - Remove `market_id` - - Make `swap_fee` non-optional - - Remove `total_subsidy` - - Make `total_weight` non-optional - - Make `weights` non-optional -- ⚠️ Change the type of `liquidity_shares_manager` in - `zrml_neo_swaps::types::Pool` from `zrml_neo_swaps::types::SoloLp` to - `zrml_neo_swaps::types::LiquidityTree`. Details on the liquidity tree can be - found in the `README.md` of zrml-neo-swaps and the documentation of the - `LiquidityTree` object ([#1179]). +- ⚠️ Move the `zeitgeist_primitives::Pool` struct to `zrml_swaps::types::Pool` and change the following fields ([#1197]): + - Remove `market_id` + - Make `swap_fee` non-optional + - Remove `total_subsidy` + - Make `total_weight` non-optional + - Make `weights` non-optional +- ⚠️ Change the type of `liquidity_shares_manager` in `zrml_neo_swaps::types::Pool` from `zrml_neo_swaps::types::SoloLp` to `zrml_neo_swaps::types::LiquidityTree`. Details on the liquidity tree can be found in the `README.md` of zrml-neo-swaps and the documentation of the `LiquidityTree` object ([#1179]). ### Migrations - Closed all CPMM pools. Withdrawals are still allowed. Creating new pools will be impossible until further updates are deployed. ([#1197]) - Remove all Rikiddo storage elements. ([#1197]) -- Migrate neo-swaps `Pools` storage. The market creator's liquidity position is - translated into a position in the liquidity tree of the same value ([#1178]). +- Migrate neo-swaps `Pools` storage. The market creator's liquidity position is translated into a position in the liquidity tree of the same value ([#1178]). ### Removed diff --git a/integration-tests/configs/zeitgeist.yml b/integration-tests/configs/zeitgeist.yml index db262ed48..fd886a6e6 100644 --- a/integration-tests/configs/zeitgeist.yml +++ b/integration-tests/configs/zeitgeist.yml @@ -1,6 +1,4 @@ -# endpoint: wss://main.rpc.zeitgeist.pm/ws -endpoint: wss://zeitgeist-rpc.dwellir.com -# endpoint: wss://zeitgeist.api.onfinality.io/public-ws +endpoint: wss://main.rpc.zeitgeist.pm/ws mock-signature-host: true db: ./tmp/ztg_db_mba.sqlite # wasm-override: zeitgeist-runtime.compact.compressed.wasm @@ -26,4 +24,4 @@ import-storage: Members: [5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY] AuthorFilter: EligibleRatio: 100 - EligibleCount: 100 \ No newline at end of file + EligibleCount: 100 diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 6b4609b19..b6ee80362 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -50,7 +50,7 @@ macro_rules! create_b_tree_map { #[macro_export] macro_rules! unreachable_non_terminating { ($condition: expr, $message: literal, $($message_args: tt)*) => { - let message = alloc::format!($message, $($message_args)*); + let message = format!($message, $($message_args)*); #[cfg(test)] assert!($condition, "{}", message); @@ -60,7 +60,7 @@ macro_rules! unreachable_non_terminating { } }; ($condition: expr, $log_target: ident, $message: literal, $($message_args: tt)*) => { - let message = alloc::format!($message, $($message_args)*); + let message = format!($message, $($message_args)*); #[cfg(test)] assert!($condition, "{}", message); @@ -70,7 +70,7 @@ macro_rules! unreachable_non_terminating { } }; ($condition: expr, $extra_code: expr, $message: literal, $($message_args: tt)*) => { - let message = alloc::format!($message, $($message_args)*); + let message = format!($message, $($message_args)*); #[cfg(test)] assert!($condition, "{}", message); @@ -81,7 +81,7 @@ macro_rules! unreachable_non_terminating { } }; ($condition: expr, $log_target: ident, $extra_code: expr, $message: literal, $($message_args: tt)*) => { - let message = alloc::format!($message, $($message_args)*); + let message = format!($message, $($message_args)*); #[cfg(test)] assert!($condition, "{}", message); diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 508801557..ae559d519 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -3,7 +3,6 @@ arbitrary = { workspace = true, optional = true } fixed = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } -impl-trait-for-tuples = { workspace = true } num-traits = { workspace = true } orml-currencies = { workspace = true } orml-tokens = { workspace = true } diff --git a/primitives/src/assets.rs b/primitives/src/asset.rs similarity index 54% rename from primitives/src/assets.rs rename to primitives/src/asset.rs index a32f7c4cf..d5c923537 100644 --- a/primitives/src/assets.rs +++ b/primitives/src/asset.rs @@ -20,26 +20,54 @@ use crate::traits::ZeitgeistAssetEnumerator; use crate::{ traits::PoolSharesId, - types::{CampaignAssetId, CategoryIndex, CustomAssetId, PoolId}, + types::{CategoryIndex, PoolId}, }; -use parity_scale_codec::{Compact, CompactAs, Decode, Encode, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; -pub use all_assets::Asset; -pub use campaign_assets::CampaignAssetClass; -pub use currencies::CurrencyClass; -pub use custom_assets::CustomAssetClass; -pub use market_assets::MarketAssetClass; -pub use subsets::{BaseAssetClass, ParimutuelAssetClass, XcmAssetClass}; +/// The `Asset` enum represents all types of assets available in the Zeitgeist +/// system. +#[derive( + Clone, + Copy, + Debug, + Decode, + Default, + Deserialize, + Eq, + Encode, + MaxEncodedLen, + Ord, + PartialEq, + PartialOrd, + Serialize, + TypeInfo, +)] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub enum Asset { + CategoricalOutcome(MarketId, CategoryIndex), + ScalarOutcome(MarketId, ScalarPosition), + CombinatorialOutcome, + PoolShare(PoolId), + #[default] + Ztg, + ForeignAsset(u32), + ParimutuelShare(MarketId, CategoryIndex), +} -mod all_assets; -mod campaign_assets; -mod currencies; -mod custom_assets; -mod market_assets; -mod subsets; -#[cfg(test)] -mod tests; +#[cfg(feature = "runtime-benchmarks")] +impl ZeitgeistAssetEnumerator for Asset { + fn create_asset_id(t: MarketId) -> Self { + Asset::CategoricalOutcome(t, 0) + } +} + +impl PoolSharesId for Asset { + fn pool_shares_id(pool_id: PoolId) -> Self { + Self::PoolShare(pool_id) + } +} /// In a scalar market, users can either choose a `Long` position, /// meaning that they think the outcome will be closer to the upper bound @@ -50,15 +78,15 @@ mod tests; Copy, Debug, Decode, + Deserialize, Eq, Encode, MaxEncodedLen, Ord, PartialEq, PartialOrd, + Serialize, TypeInfo, - serde::Deserialize, - serde::Serialize, )] #[serde(rename_all = "camelCase")] pub enum ScalarPosition { diff --git a/primitives/src/assets/all_assets.rs b/primitives/src/assets/all_assets.rs deleted file mode 100644 index a14acc5b7..000000000 --- a/primitives/src/assets/all_assets.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2023-2024 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 super::*; - -/// The `Asset` enum represents all types of assets available in the Zeitgeist -/// system. -/// -/// This complete enumeration is intended to abstract the common interaction -/// with tokens away. For example, the developer is not forced to be aware -/// about which exact implementation will handle the desired asset class to -/// instruct operations such as `transfer` or `freeze`, instead it is -/// sufficient to call a crate that manages the routing. -/// While it is not recommended to use this enum in storage, it should not pose -/// a problem as long as all other asset types use the same scale encoding for -/// a matching asset variant in this enum. -/// -/// **Deprecated:** Market and Pool assets are "lazy" migrated to -/// pallet-assets. -/// Do not create any new market or pool assets using the deprecated variants -/// in this enum. -/// -/// # Types -/// -/// * `MI`: Market Id -#[derive( - Clone, - Copy, - Debug, - Decode, - Default, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum Asset { - #[codec(index = 0)] - CategoricalOutcome(MI, CategoryIndex), - - #[codec(index = 1)] - ScalarOutcome(MI, ScalarPosition), - - #[codec(index = 3)] - PoolShare(PoolId), - - #[codec(index = 4)] - #[default] - Ztg, - - #[codec(index = 5)] - ForeignAsset(u32), - - #[codec(index = 6)] - ParimutuelShare(MI, CategoryIndex), - - #[codec(index = 7)] - CampaignAsset(#[codec(compact)] CampaignAssetId), - - #[codec(index = 8)] - CustomAsset(#[codec(compact)] CustomAssetId), -} - -impl PoolSharesId for Asset { - fn pool_shares_id(pool_id: PoolId) -> Self { - Self::PoolShare(pool_id) - } -} - -#[cfg(feature = "runtime-benchmarks")] -impl ZeitgeistAssetEnumerator for Asset { - fn create_asset_id(t: MI) -> Self { - Asset::CategoricalOutcome(t, 0) - } -} - -impl From> for Asset { - fn from(value: MarketAssetClass) -> Self { - match value { - MarketAssetClass::::CategoricalOutcome(market_id, cat_id) => { - Self::CategoricalOutcome(market_id, cat_id) - } - MarketAssetClass::::ScalarOutcome(market_id, scalar_pos) => { - Self::ScalarOutcome(market_id, scalar_pos) - } - MarketAssetClass::::ParimutuelShare(market_id, cat_id) => { - Self::ParimutuelShare(market_id, cat_id) - } - MarketAssetClass::::PoolShare(pool_id) => Self::PoolShare(pool_id), - } - } -} - -impl From for Asset { - fn from(value: CampaignAssetClass) -> Self { - Self::CampaignAsset(value.0) - } -} - -impl From for Asset { - fn from(value: CustomAssetClass) -> Self { - Self::CustomAsset(value.0) - } -} - -impl From> for Asset { - fn from(value: CurrencyClass) -> Self { - match value { - CurrencyClass::::CategoricalOutcome(market_id, cat_id) => { - Self::CategoricalOutcome(market_id, cat_id) - } - CurrencyClass::::ScalarOutcome(market_id, scalar_pos) => { - Self::ScalarOutcome(market_id, scalar_pos) - } - CurrencyClass::::ParimutuelShare(market_id, cat_id) => { - Self::ParimutuelShare(market_id, cat_id) - } - CurrencyClass::::PoolShare(pool_id) => Self::PoolShare(pool_id), - CurrencyClass::::ForeignAsset(asset_id) => Self::ForeignAsset(asset_id), - } - } -} - -impl From for Asset { - fn from(value: BaseAssetClass) -> Self { - match value { - BaseAssetClass::Ztg => Self::Ztg, - BaseAssetClass::ForeignAsset(id) => Self::ForeignAsset(id), - BaseAssetClass::CampaignAsset(id) => Self::CampaignAsset(id), - } - } -} - -impl From> for Asset { - fn from(value: ParimutuelAssetClass) -> Self { - match value { - ParimutuelAssetClass::::Share(market_id, cat_id) => { - Self::ParimutuelShare(market_id, cat_id) - } - } - } -} - -impl From for Asset { - fn from(value: XcmAssetClass) -> Self { - match value { - XcmAssetClass::Ztg => Self::Ztg, - XcmAssetClass::ForeignAsset(id) => Self::ForeignAsset(id), - } - } -} diff --git a/primitives/src/assets/campaign_assets.rs b/primitives/src/assets/campaign_assets.rs deleted file mode 100644 index 9461f369e..000000000 --- a/primitives/src/assets/campaign_assets.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023-2024 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 super::*; - -/// The `CampaignAsset` tuple struct represents all campaign assets. -/// Campaign assets can have special properties, such as the capability -/// to pay fees. -#[derive( - Clone, - CompactAs, - Copy, - Debug, - Decode, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub struct CampaignAssetClass(#[codec(compact)] pub CampaignAssetId); - -impl From> for CampaignAssetClass { - fn from(value: Compact) -> CampaignAssetClass { - CampaignAssetClass(value.into()) - } -} - -impl From for Compact { - fn from(value: CampaignAssetClass) -> Compact { - value.0.into() - } -} - -impl TryFrom> for CampaignAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::CampaignAsset(id) => Ok(Self(id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/currencies.rs b/primitives/src/assets/currencies.rs deleted file mode 100644 index a432d657d..000000000 --- a/primitives/src/assets/currencies.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023-2024 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 super::*; - -/// The `CurrencyClass` enum represents all non-ztg currencies -// used in orml-tokens -#[derive( - Clone, - Copy, - Debug, - Decode, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum CurrencyClass { - // All Outcome and Share variants will be removed once the lazy migration from - // orml-tokens to pallet-assets is complete - #[codec(index = 0)] - CategoricalOutcome(MI, CategoryIndex), - - #[codec(index = 1)] - ScalarOutcome(MI, ScalarPosition), - - #[codec(index = 3)] - PoolShare(PoolId), - - #[codec(index = 5)] - ForeignAsset(u32), - - #[codec(index = 6)] - ParimutuelShare(MI, CategoryIndex), -} - -impl CurrencyClass { - pub fn is_foreign_asset(&self) -> bool { - matches!(self, Self::ForeignAsset(_)) - } -} - -impl Default for CurrencyClass { - fn default() -> Self { - Self::ForeignAsset(u32::default()) - } -} - -impl TryFrom> for CurrencyClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::CategoricalOutcome(market_id, cat_id) => { - Ok(Self::CategoricalOutcome(market_id, cat_id)) - } - Asset::::ScalarOutcome(market_id, scalar_pos) => { - Ok(Self::ScalarOutcome(market_id, scalar_pos)) - } - Asset::::ParimutuelShare(market_id, cat_id) => { - Ok(Self::ParimutuelShare(market_id, cat_id)) - } - Asset::::PoolShare(pool_id) => Ok(Self::PoolShare(pool_id)), - Asset::::ForeignAsset(id) => Ok(Self::ForeignAsset(id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/custom_assets.rs b/primitives/src/assets/custom_assets.rs deleted file mode 100644 index 65398c526..000000000 --- a/primitives/src/assets/custom_assets.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023-2024 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 super::*; - -/// The `CustomAsset` tuple struct represents all custom assets. -#[derive( - Clone, - CompactAs, - Copy, - Debug, - Decode, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub struct CustomAssetClass(#[codec(compact)] pub CustomAssetId); - -impl From> for CustomAssetClass { - fn from(value: Compact) -> CustomAssetClass { - CustomAssetClass(value.into()) - } -} - -impl From for Compact { - fn from(value: CustomAssetClass) -> Compact { - value.0.into() - } -} - -impl TryFrom> for CustomAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::CustomAsset(id) => Ok(Self(id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/market_assets.rs b/primitives/src/assets/market_assets.rs deleted file mode 100644 index e675f7c67..000000000 --- a/primitives/src/assets/market_assets.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023-2024 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 super::*; - -/// The `MarketAsset` enum represents all types of assets available in the -/// Prediction Market protocol -/// -/// # Types -/// -/// * `MI`: Market Id -#[derive( - Clone, - Copy, - Debug, - Decode, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum MarketAssetClass { - #[codec(index = 0)] - CategoricalOutcome(MI, CategoryIndex), - - #[codec(index = 1)] - ScalarOutcome(MI, ScalarPosition), - - #[codec(index = 3)] - PoolShare(PoolId), - - #[codec(index = 6)] - ParimutuelShare(MI, CategoryIndex), -} - -impl TryFrom> for MarketAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::CategoricalOutcome(market_id, cat_id) => { - Ok(Self::CategoricalOutcome(market_id, cat_id)) - } - Asset::::ScalarOutcome(market_id, scalar_pos) => { - Ok(Self::ScalarOutcome(market_id, scalar_pos)) - } - Asset::::ParimutuelShare(market_id, cat_id) => { - Ok(Self::ParimutuelShare(market_id, cat_id)) - } - Asset::::PoolShare(pool_id) => Ok(Self::PoolShare(pool_id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/subsets/base_assets.rs b/primitives/src/assets/subsets/base_assets.rs deleted file mode 100644 index 393a1ab8f..000000000 --- a/primitives/src/assets/subsets/base_assets.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2024 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 super::*; - -/// The `BaseAssetClass` enum represents all assets that can be used as collateral in -/// prediction markets. -#[derive( - Clone, - Copy, - Debug, - Decode, - Default, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum BaseAssetClass { - #[codec(index = 4)] - #[default] - Ztg, - - #[codec(index = 5)] - ForeignAsset(u32), - - #[codec(index = 7)] - CampaignAsset(#[codec(compact)] CampaignAssetId), -} - -impl TryFrom> for BaseAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::Ztg => Ok(Self::Ztg), - Asset::::ForeignAsset(id) => Ok(Self::ForeignAsset(id)), - Asset::::CampaignAsset(id) => Ok(Self::CampaignAsset(id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/subsets/mod.rs b/primitives/src/assets/subsets/mod.rs deleted file mode 100644 index eafe22f04..000000000 --- a/primitives/src/assets/subsets/mod.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2024 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 super::*; - -pub use base_assets::BaseAssetClass; -pub use parimutuel::ParimutuelAssetClass; -pub use xcm_assets::XcmAssetClass; - -mod base_assets; -mod parimutuel; -mod xcm_assets; diff --git a/primitives/src/assets/subsets/parimutuel.rs b/primitives/src/assets/subsets/parimutuel.rs deleted file mode 100644 index 5135db646..000000000 --- a/primitives/src/assets/subsets/parimutuel.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2024 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 super::*; - -/// The `ParimutuelAssetClass` enum represents all assets that are specific to parimutuel markets. -#[derive( - Clone, - Copy, - Debug, - Decode, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum ParimutuelAssetClass { - #[codec(index = 6)] - Share(MI, CategoryIndex), -} - -impl TryFrom> for ParimutuelAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::ParimutuelShare(market_id, cat_id) => Ok(Self::Share(market_id, cat_id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/subsets/xcm_assets.rs b/primitives/src/assets/subsets/xcm_assets.rs deleted file mode 100644 index 4b03ecf33..000000000 --- a/primitives/src/assets/subsets/xcm_assets.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2024 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 super::*; - -/// The `XcmAssetClass` enum represents all assets that can be transferred via XCM. -#[derive( - Clone, - Copy, - Debug, - Decode, - Default, - Eq, - Encode, - MaxEncodedLen, - Ord, - PartialEq, - PartialOrd, - TypeInfo, - serde::Deserialize, - serde::Serialize, -)] -#[serde(rename_all = "camelCase")] -pub enum XcmAssetClass { - #[codec(index = 4)] - #[default] - Ztg, - - #[codec(index = 5)] - ForeignAsset(u32), -} - -impl TryFrom> for XcmAssetClass { - type Error = (); - - fn try_from(value: Asset) -> Result { - match value { - Asset::::Ztg => Ok(Self::Ztg), - Asset::::ForeignAsset(id) => Ok(Self::ForeignAsset(id)), - _ => Err(()), - } - } -} diff --git a/primitives/src/assets/tests.rs b/primitives/src/assets/tests.rs deleted file mode 100644 index 9aa7bec90..000000000 --- a/primitives/src/assets/tests.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use crate::types::MarketId; - -mod conversion; -mod scale_codec; diff --git a/primitives/src/assets/tests/conversion.rs b/primitives/src/assets/tests/conversion.rs deleted file mode 100644 index 49829978c..000000000 --- a/primitives/src/assets/tests/conversion.rs +++ /dev/null @@ -1,358 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use test_case::test_case; - -// Assets <> MarketAssetClass -#[test_case( - Asset::::CategoricalOutcome(7, 8), - MarketAssetClass::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - Asset::::ScalarOutcome(7, ScalarPosition::Long), - MarketAssetClass::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - Asset::::PoolShare(7), - MarketAssetClass::::PoolShare(7); - "pool_share" -)] -#[test_case( - Asset::::ParimutuelShare(7, 8), - MarketAssetClass::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -fn from_all_assets_to_market_assets( - old_asset: Asset, - new_asset: MarketAssetClass, -) { - let new_asset_converted: MarketAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::Ztg; "ztg")] -#[test_case(Asset::::ForeignAsset(7); "foreign_asset")] -#[test_case(Asset::::CampaignAsset(7); "campaign_asset")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_market_assets_fails(asset: Asset) { - assert!(MarketAssetClass::::try_from(asset).is_err()); -} - -#[test_case( - MarketAssetClass::::CategoricalOutcome(7, 8), - Asset::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - MarketAssetClass::::ScalarOutcome(7, ScalarPosition::Long), - Asset::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - MarketAssetClass::::PoolShare(7), - Asset::::PoolShare(7); - "pool_share" -)] -#[test_case( - MarketAssetClass::::ParimutuelShare(7, 8), - Asset::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -fn from_market_assets_to_all_assets( - old_asset: MarketAssetClass, - new_asset: Asset, -) { - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> CurrencyClass -#[test_case( - Asset::::CategoricalOutcome(7, 8), - CurrencyClass::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - Asset::::ScalarOutcome(7, ScalarPosition::Long), - CurrencyClass::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - Asset::::PoolShare(7), - CurrencyClass::::PoolShare(7); - "pool_share" -)] -#[test_case( - Asset::::ParimutuelShare(7, 8), - CurrencyClass::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -#[test_case( - Asset::::ForeignAsset(7), - CurrencyClass::::ForeignAsset(7); - "foreign_asset" -)] -fn from_all_assets_to_currencies(old_asset: Asset, new_asset: CurrencyClass) { - let new_asset_converted: CurrencyClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::Ztg; "ztg")] -#[test_case(Asset::::CampaignAsset(7); "campaign_asset")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_currencies_fails(asset: Asset) { - assert!(CurrencyClass::::try_from(asset).is_err()); -} - -#[test_case( - CurrencyClass::::CategoricalOutcome(7, 8), - Asset::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - CurrencyClass::::ScalarOutcome(7, ScalarPosition::Long), - Asset::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - CurrencyClass::::PoolShare(7), - Asset::::PoolShare(7); - "pool_share" -)] -#[test_case( - CurrencyClass::::ParimutuelShare(7, 8), - Asset::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -#[test_case( - CurrencyClass::::ForeignAsset(7), - Asset::::ForeignAsset(7); - "foreign_asset" -)] -fn from_currencies_to_all_assets(old_asset: CurrencyClass, new_asset: Asset) { - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> CampaignAssetClass -#[test] -fn from_all_assets_to_campaign_assets() { - let old_asset = Asset::::CampaignAsset(7); - let new_asset = CampaignAssetClass(7); - - let new_asset_converted: CampaignAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::CategoricalOutcome(7, 8); "categorical_outcome")] -#[test_case(Asset::::ScalarOutcome(7, ScalarPosition::Long); "scalar_outcome")] -#[test_case(Asset::::PoolShare(7); "pool_share")] -#[test_case(Asset::::Ztg; "ztg")] -#[test_case(Asset::::ForeignAsset(7); "foreign_asset")] -#[test_case(Asset::::ParimutuelShare(7, 8); "parimutuel_share")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_campaign_assets_fails(asset: Asset) { - assert!(CampaignAssetClass::try_from(asset).is_err()); -} - -#[test] -fn from_campaign_assets_to_all_assets() { - let old_asset = CampaignAssetClass(7); - let new_asset = Asset::::CampaignAsset(7); - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> CustomAssetClass -#[test] -fn from_all_assets_to_custom_assets() { - let old_asset = Asset::::CustomAsset(7); - let new_asset = CustomAssetClass(7); - - let new_asset_converted: CustomAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::CategoricalOutcome(7, 8); "categorical_outcome")] -#[test_case(Asset::::ScalarOutcome(7, ScalarPosition::Long); "scalar_outcome")] -#[test_case(Asset::::PoolShare(7); "pool_share")] -#[test_case(Asset::::Ztg; "ztg")] -#[test_case(Asset::::ForeignAsset(7); "foreign_asset")] -#[test_case(Asset::::ParimutuelShare(7, 8); "parimutuel_share")] -#[test_case(Asset::::CampaignAsset(7); "campaign_asset")] -fn from_all_assets_to_custom_assets_fails(asset: Asset) { - assert!(CustomAssetClass::try_from(asset).is_err()); -} - -#[test] -fn from_custom_assets_to_all_assets() { - let old_asset = CampaignAssetClass(7); - let new_asset = Asset::::CampaignAsset(7); - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> BaseAssetClass -#[test_case( - Asset::::CampaignAsset(7), - BaseAssetClass::CampaignAsset(7); - "campaign_asset" -)] -#[test_case( - Asset::::ForeignAsset(7), - BaseAssetClass::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - Asset::::Ztg, - BaseAssetClass::Ztg; - "ztg" -)] -fn from_all_assets_to_base_assets(old_asset: Asset, new_asset: BaseAssetClass) { - let new_asset_converted: BaseAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::CategoricalOutcome(7, 8); "categorical_outcome")] -#[test_case(Asset::::ScalarOutcome(7, ScalarPosition::Long); "scalar_outcome")] -#[test_case(Asset::::PoolShare(7); "pool_share")] -#[test_case(Asset::::ParimutuelShare(7, 8); "parimutuel_share")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_base_assets_fails(asset: Asset) { - assert!(BaseAssetClass::try_from(asset).is_err()); -} - -#[test_case( - BaseAssetClass::CampaignAsset(7), - Asset::::CampaignAsset(7); - "campaign_asset" -)] -#[test_case( - BaseAssetClass::ForeignAsset(7), - Asset::::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - BaseAssetClass::Ztg, - Asset::::Ztg; - "ztg" -)] -fn from_base_assets_to_all_assets(old_asset: BaseAssetClass, new_asset: Asset) { - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> ParimutuelAssetClass -#[test_case( - Asset::::ParimutuelShare(7, 8), - ParimutuelAssetClass::::Share(7, 8); - "parimutuel_share" -)] -fn from_all_assets_to_parimutuel_assets( - old_asset: Asset, - new_asset: ParimutuelAssetClass, -) { - let new_asset_converted: ParimutuelAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::CategoricalOutcome(7, 8); "categorical_outcome")] -#[test_case(Asset::::ScalarOutcome(7, ScalarPosition::Long); "scalar_outcome")] -#[test_case(Asset::::PoolShare(7); "pool_share")] -#[test_case(Asset::::Ztg; "ztg")] -#[test_case(Asset::::ForeignAsset(7); "foreign_asset")] -#[test_case(Asset::::CampaignAsset(7); "campaign_asset")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_parimutuel_assets_fails(asset: Asset) { - assert!(ParimutuelAssetClass::::try_from(asset).is_err()); -} - -#[test_case( - ParimutuelAssetClass::::Share(7, 8), - Asset::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -fn from_parimutuel_assets_to_all_assets( - old_asset: ParimutuelAssetClass, - new_asset: Asset, -) { - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// Assets <> XcmAssetClass -#[test_case( - Asset::::ForeignAsset(7), - XcmAssetClass::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - Asset::::Ztg, - XcmAssetClass::Ztg; - "ztg" -)] -fn from_all_assets_to_xcm_assets(old_asset: Asset, new_asset: XcmAssetClass) { - let new_asset_converted: XcmAssetClass = old_asset.try_into().unwrap(); - assert_eq!(new_asset, new_asset_converted); -} - -#[test_case(Asset::::CategoricalOutcome(7, 8); "categorical_outcome")] -#[test_case(Asset::::ScalarOutcome(7, ScalarPosition::Long); "scalar_outcome")] -#[test_case(Asset::::PoolShare(7); "pool_share")] -#[test_case(Asset::::CampaignAsset(7); "campaign_asset")] -#[test_case(Asset::::CustomAsset(7); "custom_asset")] -fn from_all_assets_to_xcm_assets_fails(asset: Asset) { - assert!(XcmAssetClass::try_from(asset).is_err()); -} - -#[test_case( - XcmAssetClass::ForeignAsset(7), - Asset::::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - XcmAssetClass::Ztg, - Asset::::Ztg; - "ztg" -)] -fn from_xcm_assets_to_all_assets(old_asset: XcmAssetClass, new_asset: Asset) { - let new_asset_converted: Asset = old_asset.into(); - assert_eq!(new_asset, new_asset_converted); -} - -// CampaignAssetId <> CampaignAssetClass -#[test] -fn from_campaign_asset_id_to_campaign_asset() { - let campaign_asset_id = Compact(7); - let campaign_asset = CampaignAssetClass::from(campaign_asset_id); - let campaign_asset_id_converted = campaign_asset.into(); - assert_eq!(campaign_asset_id, campaign_asset_id_converted); -} - -// CustomAssetId <> CustomAssetClass -#[test] -fn from_custom_asset_id_to_custom_asset() { - let custom_asset_id = Compact(7); - let custom_asset = CustomAssetClass::from(custom_asset_id); - let custom_asset_id_converted = custom_asset.into(); - assert_eq!(custom_asset_id, custom_asset_id_converted); -} diff --git a/primitives/src/assets/tests/scale_codec.rs b/primitives/src/assets/tests/scale_codec.rs deleted file mode 100644 index 050da1db5..000000000 --- a/primitives/src/assets/tests/scale_codec.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use test_case::test_case; - -// Assets <> BaseAssetClass -#[test_case( - Asset::::CampaignAsset(7), - BaseAssetClass::CampaignAsset(7); - "campaign_asset" -)] -#[test_case( - Asset::::ForeignAsset(7), - BaseAssetClass::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - Asset::::Ztg, - BaseAssetClass::Ztg; - "ztg" -)] -fn index_matching_works_for_base_assets(old_asset: Asset, new_asset: BaseAssetClass) { - let old_asset_encoded: Vec = old_asset.encode(); - let new_asset_decoded = - ::decode(&mut old_asset_encoded.as_slice()).unwrap(); - assert_eq!(new_asset_decoded, new_asset); -} - -// Assets <> CurrencyClass -#[test_case( - Asset::::CategoricalOutcome(7, 8), - CurrencyClass::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - Asset::::ScalarOutcome(7, ScalarPosition::Long), - CurrencyClass::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - Asset::::PoolShare(7), - CurrencyClass::::PoolShare(7); - "pool_share" -)] -#[test_case( - Asset::::ParimutuelShare(7, 8), - CurrencyClass::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -#[test_case( - Asset::::ForeignAsset(7), - CurrencyClass::::ForeignAsset(7); - "foreign_asset" -)] -fn index_matching_works_for_currencies( - old_asset: Asset, - new_asset: CurrencyClass, -) { - let old_asset_encoded: Vec = old_asset.encode(); - let new_asset_decoded = - as Decode>::decode(&mut old_asset_encoded.as_slice()).unwrap(); - assert_eq!(new_asset_decoded, new_asset); -} - -// Assets <> MarketAssetClass -#[test_case( - Asset::::CategoricalOutcome(7, 8), - MarketAssetClass::::CategoricalOutcome(7, 8); - "categorical_outcome" -)] -#[test_case( - Asset::::ScalarOutcome(7, ScalarPosition::Long), - MarketAssetClass::::ScalarOutcome(7, ScalarPosition::Long); - "scalar_outcome" -)] -#[test_case( - Asset::::PoolShare(7), - MarketAssetClass::::PoolShare(7); - "pool_share" -)] -#[test_case( - Asset::::ParimutuelShare(7, 8), - MarketAssetClass::::ParimutuelShare(7, 8); - "parimutuel_share" -)] -fn index_matching_works_for_market_assets( - old_asset: Asset, - new_asset: MarketAssetClass, -) { - let old_asset_encoded: Vec = old_asset.encode(); - let new_asset_decoded = - as Decode>::decode(&mut old_asset_encoded.as_slice()).unwrap(); - assert_eq!(new_asset_decoded, new_asset); -} - -// Assets <> ParimutuelAssetClass -#[test_case( - Asset::::ParimutuelShare(7, 8), - ParimutuelAssetClass::Share(7, 8); - "parimutuel_share" -)] -fn index_matching_works_for_parimutuel_assets( - old_asset: Asset, - new_asset: ParimutuelAssetClass, -) { - let old_asset_encoded: Vec = old_asset.encode(); - let new_asset_decoded = - as Decode>::decode(&mut old_asset_encoded.as_slice()) - .unwrap(); - assert_eq!(new_asset_decoded, new_asset); -} - -// Assets <> XcmAssetClass -#[test_case( - Asset::::ForeignAsset(7), - XcmAssetClass::ForeignAsset(7); - "foreign_asset" -)] -#[test_case( - Asset::::Ztg, - XcmAssetClass::Ztg; - "ztg" -)] -fn index_matching_works_for_xcm_assets(old_asset: Asset, new_asset: XcmAssetClass) { - let old_asset_encoded: Vec = old_asset.encode(); - let new_asset_decoded = - ::decode(&mut old_asset_encoded.as_slice()).unwrap(); - assert_eq!(new_asset_decoded, new_asset); -} diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index d5f42caf9..b48768d01 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -22,7 +22,7 @@ clippy::arithmetic_side_effects )] -#[cfg(feature = "mock")] +// #[cfg(any(feature = "mock", feature = "runtime-benchmarks"))] pub mod base_multiples; #[cfg(feature = "mock")] pub mod mock; diff --git a/primitives/src/constants/base_multiples.rs b/primitives/src/constants/base_multiples.rs index e714d61d5..2f8c41d8e 100644 --- a/primitives/src/constants/base_multiples.rs +++ b/primitives/src/constants/base_multiples.rs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -#![cfg(feature = "mock")] - use crate::constants::BASE; pub const _1: u128 = BASE; diff --git a/primitives/src/constants/mock.rs b/primitives/src/constants/mock.rs index e38b7b97e..4f2b16655 100644 --- a/primitives/src/constants/mock.rs +++ b/primitives/src/constants/mock.rs @@ -20,30 +20,13 @@ pub use super::*; use crate::{ - assets::Asset, - types::{Assets, Balance, Currencies, Moment}, + asset::Asset, + types::{Balance, CurrencyId, Moment}, }; -use frame_support::{pallet_prelude::Weight, parameter_types, traits::LockIdentifier, PalletId}; +use frame_support::{parameter_types, traits::LockIdentifier, PalletId}; use orml_traits::parameter_type_with_key; use sp_arithmetic::Perbill; -// Asset-Router -parameter_types! { - pub const DestroyAccountWeight: Weight = Weight::from_all(1000); - pub const DestroyApprovalWeight: Weight = Weight::from_all(1000); - pub const DestroyFinishWeight: Weight = Weight::from_all(1000); -} - -// Assets -parameter_types! { - pub const AssetsAccountDeposit: Balance = 0; - pub const AssetsApprovalDeposit: Balance = 0; - pub const AssetsDeposit: Balance = 0; - pub const AssetsStringLimit: u32 = 256; - pub const AssetsMetadataDepositBase: Balance = 0; - pub const AssetsMetadataDepositPerByte: Balance = 0; -} - // Authorized parameter_types! { pub const AuthorizedPalletId: PalletId = PalletId(*b"zge/atzd"); @@ -178,15 +161,16 @@ parameter_types! { // ORML parameter_types! { // ORML - pub const GetNativeCurrencyId: Assets = Asset::Ztg; -} - -parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: Currencies| -> Balance {2}; + pub const GetNativeCurrencyId: CurrencyId = Asset::Ztg; } parameter_type_with_key! { - pub ExistentialDepositsAssets: |_asset_id: Assets| -> Balance {2}; + pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { + match currency_id { + Asset::Ztg => ExistentialDeposit::get(), + _ => 10 + } + }; } // System diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 2002bcd97..de0033306 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -20,7 +20,7 @@ extern crate alloc; -mod assets; +mod asset; pub mod constants; pub mod hybrid_router_api_types; mod market; @@ -29,5 +29,6 @@ mod max_runtime_usize; pub mod orderbook; mod outcome_report; mod proxy_type; +mod serde_wrapper; pub mod traits; pub mod types; diff --git a/primitives/src/market.rs b/primitives/src/market.rs index 46b1deef8..3b727f4e6 100644 --- a/primitives/src/market.rs +++ b/primitives/src/market.rs @@ -16,68 +16,58 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::types::{MarketAssetClass, OutcomeReport, ScalarPosition}; +use crate::types::{Asset, OutcomeReport, ScalarPosition}; use alloc::{vec, vec::Vec}; use core::ops::{Range, RangeInclusive}; -use parity_scale_codec::{Decode, Encode, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_arithmetic::per_things::Perbill; use sp_runtime::RuntimeDebug; -/// Types -/// -/// * `AI`: Account id -/// * `BA`: Balance type -/// * `BN`: Block number -/// * `M`: Moment (time moment) -/// * `A`: Asset -/// * `MI`: Market ID #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct Market { - pub market_id: MI, +pub struct Market { + pub market_id: MarketId, /// Base asset of the market. - pub base_asset: A, + pub base_asset: Asset, /// Creator of this market. - pub creator: AI, + pub creator: AccountId, /// Creation type. pub creation: MarketCreation, /// A fee that is charged each trade and given to the market creator. pub creator_fee: Perbill, /// Oracle that reports the outcome of this market. - pub oracle: AI, + pub oracle: AccountId, /// Metadata for the market, usually a content address of IPFS /// hosted JSON. Currently limited to 66 bytes (see `MaxEncodedLen` implementation) pub metadata: Vec, /// The type of the market. pub market_type: MarketType, /// Market start and end - pub period: MarketPeriod, + pub period: MarketPeriod, /// Market deadlines. - pub deadlines: Deadlines, + pub deadlines: Deadlines, /// The scoring rule used for the market. pub scoring_rule: ScoringRule, /// The current status of the market. pub status: MarketStatus, /// The report of the market. Only `Some` if it has been reported. - pub report: Option>, + pub report: Option>, /// The resolved outcome. pub resolved_outcome: Option, /// See [`MarketDisputeMechanism`]. pub dispute_mechanism: Option, /// The bonds reserved for this market. - pub bonds: MarketBonds, + pub bonds: MarketBonds, /// The time at which the market was closed early. - pub early_close: Option>, + pub early_close: Option>, } -impl Market +impl + Market where - MI: Copy + HasCompact + MaxEncodedLen, + MarketId: Copy + MaxEncodedLen, { - /// Returns the `ResolutionMechanism` of market, currently either: - /// - `RedeemTokens`, which implies that the module that handles the state transitions of - /// a market is also responsible to provide means for redeeming rewards - /// - `Noop`, which implies that another module provides the means for redeeming rewards + /// Returns the `ResolutionMechanism` of this market. pub fn resolution_mechanism(&self) -> ResolutionMechanism { match self.scoring_rule { ScoringRule::AmmCdaHybrid => ResolutionMechanism::RedeemTokens, @@ -85,13 +75,11 @@ where } } - /// Returns whether the market is redeemable, i.e. reward payout is managed within - /// the same module that controls the state transitions of the underlying market. pub fn is_redeemable(&self) -> bool { matches!(self.resolution_mechanism(), ResolutionMechanism::RedeemTokens) } - /// Returns the number of outcomes for a market. + /// Returns the number of outcomes of this market. pub fn outcomes(&self) -> u16 { match self.market_type { MarketType::Categorical(categories) => categories, @@ -116,17 +104,18 @@ where } /// Returns a `Vec` of all outcomes for `market_id`. - pub fn outcome_assets(&self) -> Vec> { + pub fn outcome_assets(&self) -> Vec> { match self.market_type { MarketType::Categorical(categories) => { let mut assets = Vec::new(); for i in 0..categories { match self.scoring_rule { - ScoringRule::AmmCdaHybrid => assets - .push(MarketAssetClass::::CategoricalOutcome(self.market_id, i)), + ScoringRule::AmmCdaHybrid => { + assets.push(Asset::::CategoricalOutcome(self.market_id, i)) + } ScoringRule::Parimutuel => { - assets.push(MarketAssetClass::::ParimutuelShare(self.market_id, i)) + assets.push(Asset::::ParimutuelShare(self.market_id, i)) } }; } @@ -135,8 +124,8 @@ where } MarketType::Scalar(_) => { vec![ - MarketAssetClass::::ScalarOutcome(self.market_id, ScalarPosition::Long), - MarketAssetClass::::ScalarOutcome(self.market_id, ScalarPosition::Short), + Asset::::ScalarOutcome(self.market_id, ScalarPosition::Long), + Asset::::ScalarOutcome(self.market_id, ScalarPosition::Short), ] } } @@ -146,7 +135,7 @@ where /// returns `None` if not possible. Cases where `None` is returned are: /// - The reported outcome does not exist /// - The reported outcome does not have a corresponding asset type - pub fn report_into_asset(&self) -> Option> { + pub fn report_into_asset(&self) -> Option> { let outcome = if let Some(ref report) = self.report { &report.outcome } else { @@ -160,24 +149,21 @@ where /// returns `None` if not possible. Cases where `None` is returned are: /// - The resolved outcome does not exist /// - The resolved outcome does not have a corresponding asset type - pub fn resolved_outcome_into_asset(&self) -> Option> { + pub fn resolved_outcome_into_asset(&self) -> Option> { let outcome = self.resolved_outcome.as_ref()?; self.outcome_report_into_asset(outcome) } /// Tries to convert a `outcome_report` for `market_id` into an asset, /// returns `None` if not possible. - fn outcome_report_into_asset( - &self, - outcome_report: &OutcomeReport, - ) -> Option> { + fn outcome_report_into_asset(&self, outcome_report: &OutcomeReport) -> Option> { match outcome_report { OutcomeReport::Categorical(idx) => match self.scoring_rule { ScoringRule::AmmCdaHybrid => { - Some(MarketAssetClass::::CategoricalOutcome(self.market_id, *idx)) + Some(Asset::::CategoricalOutcome(self.market_id, *idx)) } ScoringRule::Parimutuel => { - Some(MarketAssetClass::::ParimutuelShare(self.market_id, *idx)) + Some(Asset::::ParimutuelShare(self.market_id, *idx)) } }, OutcomeReport::Scalar(_) => None, @@ -187,38 +173,40 @@ where /// Tracks the status of a bond. #[derive(Clone, Decode, Encode, MaxEncodedLen, PartialEq, Eq, RuntimeDebug, TypeInfo)] -pub struct Bond { +pub struct Bond { /// The account that reserved the bond. - pub who: AI, + pub who: AccountId, /// The amount reserved. - pub value: BA, + pub value: Balance, /// `true` if and only if the bond is unreserved and/or (partially) slashed. pub is_settled: bool, } -impl Bond { - pub fn new(who: AI, value: BA) -> Bond { +impl Bond { + pub fn new(who: AccountId, value: Balance) -> Bond { Bond { who, value, is_settled: false } } } /// Tracks bonds associated with a prediction market. #[derive(Clone, Decode, Encode, MaxEncodedLen, PartialEq, Eq, RuntimeDebug, TypeInfo)] -pub struct MarketBonds { - pub creation: Option>, - pub oracle: Option>, - pub outsider: Option>, - pub dispute: Option>, - pub close_request: Option>, - pub close_dispute: Option>, +pub struct MarketBonds { + pub creation: Option>, + pub oracle: Option>, + pub outsider: Option>, + pub dispute: Option>, + pub close_request: Option>, + pub close_dispute: Option>, } -impl MarketBonds { +impl + MarketBonds +{ /// Return the combined value of the open bonds for `who`. - pub fn total_amount_bonded(&self, who: &AI) -> BA { - let value_or_default = |bond: &Option>| match bond { + pub fn total_amount_bonded(&self, who: &AccountId) -> Balance { + let value_or_default = |bond: &Option>| match bond { Some(bond) if bond.who == *who => bond.value, - _ => BA::zero(), + _ => Balance::zero(), }; value_or_default(&self.creation) .saturating_add(value_or_default(&self.oracle)) @@ -230,7 +218,7 @@ impl MarketBonds { } // Used primarily for testing purposes. -impl Default for MarketBonds { +impl Default for MarketBonds { fn default() -> Self { MarketBonds { creation: None, @@ -243,34 +231,34 @@ impl Default for MarketBonds { } } -impl MaxEncodedLen for Market +impl MaxEncodedLen + for Market where - AI: MaxEncodedLen, - BA: MaxEncodedLen, - BN: MaxEncodedLen, - M: MaxEncodedLen, - A: MaxEncodedLen, - MI: MaxEncodedLen, + AccountId: MaxEncodedLen, + Balance: MaxEncodedLen, + BlockNumber: MaxEncodedLen, + Moment: MaxEncodedLen, + MarketId: MaxEncodedLen, { fn max_encoded_len() -> usize { - AI::max_encoded_len() - .saturating_add(MI::max_encoded_len()) - .saturating_add(A::max_encoded_len()) + AccountId::max_encoded_len() + .saturating_add(MarketId::max_encoded_len()) + .saturating_add(Asset::::max_encoded_len()) .saturating_add(MarketCreation::max_encoded_len()) .saturating_add(Perbill::max_encoded_len()) - .saturating_add(AI::max_encoded_len()) + .saturating_add(AccountId::max_encoded_len()) // We assume that at max. a 512 bit hash function is used .saturating_add(u8::max_encoded_len().saturating_mul(68)) .saturating_add(MarketType::max_encoded_len()) - .saturating_add(>::max_encoded_len()) - .saturating_add(Deadlines::::max_encoded_len()) + .saturating_add(>::max_encoded_len()) + .saturating_add(Deadlines::::max_encoded_len()) .saturating_add(ScoringRule::max_encoded_len()) .saturating_add(MarketStatus::max_encoded_len()) - .saturating_add(>>::max_encoded_len()) + .saturating_add(>>::max_encoded_len()) .saturating_add(>::max_encoded_len()) .saturating_add(>::max_encoded_len()) - .saturating_add(>::max_encoded_len()) - .saturating_add(>>::max_encoded_len()) + .saturating_add(>::max_encoded_len()) + .saturating_add(>>::max_encoded_len()) } } @@ -326,22 +314,27 @@ pub enum MarketDisputeMechanism { /// 3. With inclusive ranges it is not possible to express empty ranges and this feature /// mostly conflicts with existent tests and corner cases. #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub enum MarketPeriod { - Block(Range), - Timestamp(Range), +pub enum MarketPeriod { + Block(Range), + Timestamp(Range), } -impl MaxEncodedLen for MarketPeriod { +impl MaxEncodedLen + for MarketPeriod +{ fn max_encoded_len() -> usize { // Since it is an enum, the biggest element is the only one of interest here. - BN::max_encoded_len().max(M::max_encoded_len()).saturating_mul(2).saturating_add(1) + BlockNumber::max_encoded_len() + .max(Moment::max_encoded_len()) + .saturating_mul(2) + .saturating_add(1) } } #[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] -pub struct EarlyClose { - pub old: MarketPeriod, - pub new: MarketPeriod, +pub struct EarlyClose { + pub old: MarketPeriod, + pub new: MarketPeriod, pub state: EarlyCloseState, } @@ -357,10 +350,10 @@ pub enum EarlyCloseState { #[derive( Clone, Copy, Decode, Default, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo, )] -pub struct Deadlines { - pub grace_period: BN, - pub oracle_duration: BN, - pub dispute_duration: BN, +pub struct Deadlines { + pub grace_period: BlockNumber, + pub oracle_duration: BlockNumber, + pub dispute_duration: BlockNumber, } #[derive(TypeInfo, Clone, Copy, Encode, Eq, Decode, MaxEncodedLen, PartialEq, RuntimeDebug)] @@ -424,13 +417,10 @@ pub enum ResolutionMechanism { #[cfg(test)] mod tests { - use crate::{ - market::*, - types::{Asset, MarketAsset}, - }; + use crate::{market::*, types::Asset}; use test_case::test_case; type MarketId = u128; - type Market = crate::market::Market, MarketId>; + type Market = crate::market::Market; #[test_case( MarketType::Categorical(6), @@ -514,28 +504,28 @@ mod tests { #[test_case( MarketType::Categorical(2), ScoringRule::AmmCdaHybrid, - vec![MarketAsset::CategoricalOutcome(0, 0), MarketAsset::CategoricalOutcome(0, 1)]; + vec![Asset::CategoricalOutcome(0, 0), Asset::CategoricalOutcome(0, 1)]; "categorical_market_amm_cda_hybrid" )] #[test_case( MarketType::Categorical(2), ScoringRule::Parimutuel, - vec![MarketAsset::ParimutuelShare(0, 0), MarketAsset::ParimutuelShare(0, 1)]; + vec![Asset::ParimutuelShare(0, 0), Asset::ParimutuelShare(0, 1)]; "categorical_market_parimutuel" )] #[test_case( MarketType::Scalar(12..=34), ScoringRule::AmmCdaHybrid, vec![ - MarketAsset::ScalarOutcome(0, ScalarPosition::Long), - MarketAsset::ScalarOutcome(0, ScalarPosition::Short), + Asset::ScalarOutcome(0, ScalarPosition::Long), + Asset::ScalarOutcome(0, ScalarPosition::Short), ]; "scalar_market" )] fn provides_correct_list_of_assets( market_type: MarketType, scoring_rule: ScoringRule, - expected: Vec, + expected: Vec>, ) { let market = Market { market_id: 0, @@ -567,14 +557,14 @@ mod tests { MarketType::Categorical(2), ScoringRule::AmmCdaHybrid, OutcomeReport::Categorical(2), - Some(MarketAsset::CategoricalOutcome(0, 2)); + Some(Asset::CategoricalOutcome(0, 2)); "categorical_market_amm_cda_hybrid" )] #[test_case( MarketType::Categorical(2), ScoringRule::Parimutuel, OutcomeReport::Categorical(2), - Some(MarketAsset::ParimutuelShare(0, 2)); + Some(Asset::ParimutuelShare(0, 2)); "categorical_market_parimutuel" )] #[test_case( @@ -588,7 +578,7 @@ mod tests { market_type: MarketType, scoring_rule: ScoringRule, outcome: OutcomeReport, - expected: Option, + expected: Option>, ) { let report = Some(Report { at: Default::default(), diff --git a/primitives/src/serde_wrapper.rs b/primitives/src/serde_wrapper.rs new file mode 100644 index 000000000..cf1a9861b --- /dev/null +++ b/primitives/src/serde_wrapper.rs @@ -0,0 +1,66 @@ +// Copyright 2024 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 . + +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +#[cfg(feature = "std")] +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +/// Used to workaround serde serialization/deserialization problems involving `u128`. +/// +/// # Types +/// +/// * `B`: Balance +#[derive( + scale_info::TypeInfo, + Clone, + Copy, + Debug, + Decode, + Default, + Encode, + Eq, + MaxEncodedLen, + Ord, + PartialEq, + PartialOrd, +)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub struct SerdeWrapper( + #[cfg_attr(feature = "std", serde(bound(serialize = "B: std::fmt::Display")))] + #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] + #[cfg_attr(feature = "std", serde(bound(deserialize = "B: std::str::FromStr")))] + #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] + pub B, +); + +#[cfg(feature = "std")] +fn serialize_as_string( + t: &T, + serializer: S, +) -> Result { + serializer.serialize_str(&t.to_string()) +} + +#[cfg(feature = "std")] +fn deserialize_from_string<'de, D: Deserializer<'de>, T: std::str::FromStr>( + deserializer: D, +) -> Result { + let s = String::deserialize(deserializer)?; + s.parse::().map_err(|_| serde::de::Error::custom("Parse from string failed")) +} diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index d4e987ce8..1298baa68 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -25,7 +25,6 @@ mod hybrid_router_orderbook_api; mod market_builder; mod market_commons_pallet_api; mod market_id; -mod market_transition_api; mod swaps; mod zeitgeist_asset; @@ -38,6 +37,5 @@ pub use hybrid_router_orderbook_api::*; pub use market_builder::*; pub use market_commons_pallet_api::*; pub use market_id::*; -pub use market_transition_api::*; pub use swaps::*; pub use zeitgeist_asset::*; diff --git a/primitives/src/traits/dispute_api.rs b/primitives/src/traits/dispute_api.rs index 8ef6b952b..c8e2c279f 100644 --- a/primitives/src/traits/dispute_api.rs +++ b/primitives/src/traits/dispute_api.rs @@ -20,11 +20,11 @@ extern crate alloc; use crate::{ outcome_report::OutcomeReport, - types::{BaseAsset, GlobalDisputeItem, Market, ResultWithWeightInfo}, + types::{GlobalDisputeItem, Market, ResultWithWeightInfo}, }; use alloc::vec::Vec; use frame_support::pallet_prelude::Weight; -use parity_scale_codec::{HasCompact, MaxEncodedLen}; +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 @@ -34,7 +34,6 @@ pub type MarketOfDisputeApi = Market< ::Balance, ::BlockNumber, ::Moment, - BaseAsset, ::MarketId, >; @@ -46,7 +45,7 @@ pub trait DisputeApi { type Balance; type NegativeImbalance; type BlockNumber; - type MarketId: MaxEncodedLen + HasCompact; + type MarketId: MaxEncodedLen; type Moment; type Origin; @@ -151,7 +150,6 @@ pub type MarketOfDisputeResolutionApi = Market< ::Balance, ::BlockNumber, ::Moment, - BaseAsset, ::MarketId, >; @@ -159,7 +157,7 @@ pub trait DisputeResolutionApi { type AccountId; type Balance; type BlockNumber; - type MarketId: MaxEncodedLen + HasCompact; + type MarketId: MaxEncodedLen; type Moment; /// Resolve a market. diff --git a/primitives/src/traits/market_builder.rs b/primitives/src/traits/market_builder.rs index 7f682c8d7..0bf0d2cf3 100644 --- a/primitives/src/traits/market_builder.rs +++ b/primitives/src/traits/market_builder.rs @@ -16,7 +16,7 @@ // along with Zeitgeist. If not, see . use crate::types::{ - Deadlines, EarlyClose, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, + Asset, Deadlines, EarlyClose, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, OutcomeReport, Report, ScoringRule, }; use alloc::vec::Vec; @@ -36,26 +36,28 @@ macro_rules! builder_methods { /// builder.field1(value1).field2(value2); /// builder.clone().build() /// ``` -pub trait MarketBuilderTrait { - fn build(self) -> Result, DispatchError>; +pub trait MarketBuilderTrait { + fn build( + self, + ) -> Result, DispatchError>; builder_methods! { - market_id: MI, - base_asset: A, - creator: AI, + market_id: MarketId, + base_asset: Asset, + creator: AccountId, creation: MarketCreation, creator_fee: Perbill, - oracle: AI, + oracle: AccountId, metadata: Vec, market_type: MarketType, - period: MarketPeriod, - deadlines: Deadlines, + period: MarketPeriod, + deadlines: Deadlines, scoring_rule: ScoringRule, status: MarketStatus, - report: Option>, + report: Option>, resolved_outcome: Option, dispute_mechanism: Option, - bonds: MarketBonds, - early_close: Option>, + bonds: MarketBonds, + early_close: Option>, } } diff --git a/primitives/src/traits/market_commons_pallet_api.rs b/primitives/src/traits/market_commons_pallet_api.rs index 77e347d87..a24eecefa 100644 --- a/primitives/src/traits/market_commons_pallet_api.rs +++ b/primitives/src/traits/market_commons_pallet_api.rs @@ -20,7 +20,7 @@ use crate::{ traits::MarketBuilderTrait, - types::{BaseAsset, Market, PoolId}, + types::{Market, PoolId}, }; use alloc::fmt::Debug; use frame_support::{ @@ -29,7 +29,7 @@ use frame_support::{ storage::PrefixIterator, Parameter, }; -use parity_scale_codec::{FullCodec, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{FullCodec, MaxEncodedLen}; use sp_runtime::{ traits::{AtLeast32Bit, AtLeast32BitUnsigned}, DispatchError, @@ -37,12 +37,11 @@ use sp_runtime::{ // Abstraction of the market type, which is not a part of `MarketCommonsPalletApi` because Rust // doesn't support type aliases in traits. -pub type MarketOf = Market< +type MarketOf = Market< ::AccountId, ::Balance, ::BlockNumber, ::Moment, - BaseAsset, ::MarketId, >; @@ -63,7 +62,6 @@ pub trait MarketCommonsPalletApi { + Default + MaybeSerializeDeserialize + MaxEncodedLen - + HasCompact + Member + Parameter; type Moment: AtLeast32Bit + Copy + Default + Parameter + MaxEncodedLen; @@ -109,7 +107,6 @@ pub trait MarketCommonsPalletApi { Self::Balance, Self::BlockNumber, Self::Moment, - BaseAsset, Self::MarketId, >; diff --git a/primitives/src/traits/market_id.rs b/primitives/src/traits/market_id.rs index 1965d408c..cd0007fb5 100644 --- a/primitives/src/traits/market_id.rs +++ b/primitives/src/traits/market_id.rs @@ -1,4 +1,4 @@ -// Copyright 2023-2024 Forecasting Technologies LTD. +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -20,18 +20,11 @@ use frame_support::{ pallet_prelude::{MaybeSerializeDeserialize, Member}, Parameter, }; -use parity_scale_codec::{HasCompact, MaxEncodedLen}; +use parity_scale_codec::MaxEncodedLen; use sp_runtime::traits::AtLeast32Bit; pub trait MarketId: - AtLeast32Bit - + Copy - + Default - + HasCompact - + MaxEncodedLen - + MaybeSerializeDeserialize - + Member - + Parameter + AtLeast32Bit + Copy + Default + MaxEncodedLen + MaybeSerializeDeserialize + Member + Parameter { } @@ -39,7 +32,6 @@ impl MarketId for T where T: AtLeast32Bit + Copy + Default - + HasCompact + MaxEncodedLen + MaybeSerializeDeserialize + Member diff --git a/primitives/src/traits/market_transition_api.rs b/primitives/src/traits/market_transition_api.rs deleted file mode 100644 index 46a613eaa..000000000 --- a/primitives/src/traits/market_transition_api.rs +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright 2024 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 crate::types::ResultWithWeightInfo; -use frame_support::pallet_prelude::{DispatchResult, Weight}; - -/// API that is used to catch market state transitions. -pub trait MarketTransitionApi { - fn on_proposal(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_activation(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_closure(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_report(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_dispute(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_resolution(_market_id: &MI) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } -} - -#[impl_trait_for_tuples::impl_for_tuples(8)] -#[allow(clippy::let_and_return)] -/// Implementation returns on first error or after successful execution of all elements. -impl MarketTransitionApi for Tuple { - fn on_proposal(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_proposal(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } - fn on_activation(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_activation(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } - fn on_closure(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_closure(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } - fn on_report(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_report(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } - fn on_dispute(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_dispute(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } - fn on_resolution(market_id: &MI) -> ResultWithWeightInfo { - let mut collective_result = ResultWithWeightInfo::new(Ok(()), Weight::zero()); - for_tuples!( #( - let result = Tuple::on_resolution(market_id); - collective_result.result = result.result; - collective_result.weight = collective_result.weight.saturating_add(result.weight); - if collective_result.result.is_err() { - return collective_result; - } - )* ); - collective_result - } -} - -#[cfg(test)] -mod tests { - use super::*; - use frame_support::pallet_prelude::DispatchError; - - const DEFAULT_ERROR: DispatchResult = Err(DispatchError::Other("unimportant")); - const ONE: Weight = Weight::from_all(1); - const TWO: Weight = Weight::from_all(2); - const THREE: Weight = Weight::from_all(3); - - struct ExecutionPath; - impl MarketTransitionApi for ExecutionPath { - fn on_proposal(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_proposal"); - } - fn on_activation(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_activation"); - } - fn on_closure(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_closure"); - } - fn on_report(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_report"); - } - fn on_dispute(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_dispute"); - } - fn on_resolution(_market_id: &u128) -> ResultWithWeightInfo { - panic!("on_resolution"); - } - } - - struct SuccessPath; - impl MarketTransitionApi for SuccessPath { - fn on_proposal(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - fn on_activation(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - fn on_closure(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - fn on_report(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - fn on_dispute(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - fn on_resolution(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(Ok(()), ONE) - } - } - - struct FailurePath; - impl MarketTransitionApi for FailurePath { - fn on_proposal(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - fn on_activation(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - fn on_closure(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - fn on_report(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - fn on_dispute(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - fn on_resolution(_market_id: &u128) -> ResultWithWeightInfo { - ResultWithWeightInfo::new(DEFAULT_ERROR, TWO) - } - } - - #[test] - #[should_panic(expected = "on_proposal")] - fn correct_execution_path_for_tuples_on_proposal() { - <(ExecutionPath,)>::on_proposal(&0); - } - - #[test] - #[should_panic(expected = "on_activation")] - fn correct_execution_path_for_tuples_on_activation() { - <(ExecutionPath,)>::on_activation(&0); - } - - #[test] - #[should_panic(expected = "on_closure")] - fn correct_execution_path_for_tuples_on_closure() { - <(ExecutionPath,)>::on_closure(&0); - } - - #[test] - #[should_panic(expected = "on_report")] - fn correct_execution_path_for_tuples_on_report() { - <(ExecutionPath,)>::on_report(&0); - } - - #[test] - #[should_panic(expected = "on_dispute")] - fn correct_execution_path_for_tuples_on_dispute() { - <(ExecutionPath,)>::on_dispute(&0); - } - - #[test] - #[should_panic(expected = "on_resolution")] - fn correct_execution_path_for_tuples_on_resolution() { - <(ExecutionPath,)>::on_resolution(&0); - } - - #[test] - fn provides_correct_result_on_proposal() { - let mut result = <(SuccessPath,)>::on_proposal(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_proposal(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_proposal(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } - - #[test] - fn provides_correct_result_on_activation() { - let mut result = <(SuccessPath,)>::on_activation(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_activation(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_activation(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } - - #[test] - fn provides_correct_result_on_closure() { - let mut result = <(SuccessPath,)>::on_closure(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_closure(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_closure(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } - - #[test] - fn provides_correct_result_on_report() { - let mut result = <(SuccessPath,)>::on_report(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_report(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_report(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } - - #[test] - fn provides_correct_result_on_dispute() { - let mut result = <(SuccessPath,)>::on_dispute(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_dispute(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_dispute(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } - - #[test] - fn provides_correct_result_on_resolution() { - let mut result = <(SuccessPath,)>::on_resolution(&0); - assert_eq!(result.result, Ok(())); - assert_eq!(result.weight, ONE); - - result = <(SuccessPath, FailurePath)>::on_resolution(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, THREE); - - result = <(FailurePath, SuccessPath)>::on_resolution(&0); - assert_eq!(result.result, DEFAULT_ERROR); - assert_eq!(result.weight, TWO); - } -} diff --git a/primitives/src/traits/swaps.rs b/primitives/src/traits/swaps.rs index 3a9093ee4..a46d873ef 100644 --- a/primitives/src/traits/swaps.rs +++ b/primitives/src/traits/swaps.rs @@ -18,13 +18,12 @@ use crate::types::PoolId; use alloc::vec::Vec; -use frame_support::{dispatch::DispatchResult, weights::Weight}; -use parity_scale_codec::{HasCompact, MaxEncodedLen}; -use sp_runtime::DispatchError; +use frame_support::weights::Weight; +use sp_runtime::{DispatchError, DispatchResult}; pub trait Swaps { - type Asset: MaxEncodedLen; - type Balance: HasCompact + MaxEncodedLen; + type Asset; + type Balance; /// Creates a new pool. /// diff --git a/primitives/src/types.rs b/primitives/src/types.rs index a48a5b00d..411197330 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -17,7 +17,8 @@ // along with Zeitgeist. If not, see . pub use crate::{ - assets::*, market::*, max_runtime_usize::*, outcome_report::OutcomeReport, proxy_type::*, + asset::*, market::*, max_runtime_usize::*, outcome_report::OutcomeReport, proxy_type::*, + serde_wrapper::*, }; #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Result, Unstructured}; @@ -77,38 +78,10 @@ impl<'a> Arbitrary<'a> for MultiHash { } } -/// ORML adapter. +/// ORML adapter pub type BasicCurrencyAdapter = orml_currencies::BasicCurrencyAdapter; -/// ID type for any asset class. -pub type Assets = Asset; - -/// Asset type representing base assets used by prediction markets. -pub type BaseAsset = BaseAssetClass; - -/// Asset type representing campaign assets. -pub type CampaignAsset = CampaignAssetClass; - -// ID type of the campaign asset class. -pub type CampaignAssetId = u128; - -/// Asset type representing custom assets. -pub type CustomAsset = CustomAssetClass; - -// ID type of the custom asset class. -pub type CustomAssetId = u128; - -// Asset type representing currencies (excluding ZTG). -pub type Currencies = CurrencyClass; - -/// Asset type representing assets used by prediction markets. -pub type MarketAsset = MarketAssetClass; - -/// Asset type representing assets used in parimutuel markets. -pub type ParimutuelAsset = ParimutuelAssetClass; - -/// Asset type representing assets that can be transferred via XCM. -pub type XcmAsset = XcmAssetClass; +pub type CurrencyId = Asset; /// The asset id specifically used for pallet_assets_tx_payment for /// paying transaction fees in different assets. @@ -156,12 +129,6 @@ pub struct ResultWithWeightInfo { pub weight: Weight, } -impl ResultWithWeightInfo { - pub fn new(result: R, weight: Weight) -> Self { - ResultWithWeightInfo { result, weight } - } -} - #[derive( Clone, Copy, diff --git a/runtime/battery-station/Cargo.toml b/runtime/battery-station/Cargo.toml index 6cad18f89..9d12fc821 100644 --- a/runtime/battery-station/Cargo.toml +++ b/runtime/battery-station/Cargo.toml @@ -11,7 +11,6 @@ orml-currencies = { workspace = true } orml-tokens = { workspace = true } orml-traits = { workspace = true } pallet-asset-tx-payment = { workspace = true } -pallet-assets = { workspace = true } pallet-balances = { workspace = true } pallet-bounties = { workspace = true } pallet-collective = { workspace = true } @@ -110,7 +109,6 @@ xcm-executor = { workspace = true, optional = true } common-runtime = { workspace = true } zeitgeist-primitives = { workspace = true } -zrml-asset-router = { workspace = true } zrml-authorized = { workspace = true } zrml-court = { workspace = true } zrml-global-disputes = { workspace = true, optional = true } @@ -193,7 +191,6 @@ runtime-benchmarks = [ "orml-benchmarking", "orml-tokens/runtime-benchmarks", "orml-xtokens?/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", "pallet-author-inherent?/runtime-benchmarks", "pallet-author-mapping?/runtime-benchmarks", "pallet-author-slot-filter?/runtime-benchmarks", @@ -244,7 +241,6 @@ std = [ "orml-currencies/std", "orml-tokens/std", "orml-traits/std", - "pallet-assets/std", "pallet-asset-tx-payment/std", "pallet-balances/std", "pallet-bounties/std", @@ -337,7 +333,6 @@ std = [ # Zeitgeist "zeitgeist-primitives/std", - "zrml-asset-router/std", "zrml-authorized/std", "zrml-court/std", "zrml-hybrid-router/std", @@ -369,7 +364,6 @@ try-runtime = [ "pallet-preimage/try-runtime", # Money runtime pallets - "pallet-assets/try-runtime", "pallet-asset-tx-payment/try-runtime", "pallet-balances/try-runtime", "pallet-bounties/try-runtime", @@ -396,7 +390,6 @@ try-runtime = [ "orml-xtokens?/try-runtime", # Zeitgeist runtime pallets - "zrml-asset-router/try-runtime", "zrml-authorized/try-runtime", "zrml-court/try-runtime", "zrml-hybrid-router/try-runtime", diff --git a/runtime/battery-station/src/integration_tests/xcm/genesis/battery_station.rs b/runtime/battery-station/src/integration_tests/xcm/genesis/battery_station.rs index 139765e7d..0e7d6afa1 100644 --- a/runtime/battery-station/src/integration_tests/xcm/genesis/battery_station.rs +++ b/runtime/battery-station/src/integration_tests/xcm/genesis/battery_station.rs @@ -21,7 +21,6 @@ use crate::{ }, parachain_params::MinCandidateStk, parameters::ZeitgeistTreasuryAccount, - Asset, }; use nimbus_primitives::NimbusId; use sp_core::storage::Storage; @@ -63,10 +62,10 @@ pub(crate) fn genesis(parachain_id: u32) -> Storage { .chain([(ZeitgeistTreasuryAccount::get())].iter()) .flat_map(|k| { vec![ - (k.clone(), Asset::from(FOREIGN_PARENT_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(FOREIGN_SIBLING_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(FOREIGN_ZTG_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(BTC_ID).try_into().unwrap(), ENDOWMENT), + (k.clone(), FOREIGN_PARENT_ID, ENDOWMENT), + (k.clone(), FOREIGN_SIBLING_ID, ENDOWMENT), + (k.clone(), FOREIGN_ZTG_ID, ENDOWMENT), + (k.clone(), BTC_ID, ENDOWMENT), ] }) .collect::>(), diff --git a/runtime/battery-station/src/integration_tests/xcm/setup.rs b/runtime/battery-station/src/integration_tests/xcm/setup.rs index 7c54fc5e5..7d2464f50 100644 --- a/runtime/battery-station/src/integration_tests/xcm/setup.rs +++ b/runtime/battery-station/src/integration_tests/xcm/setup.rs @@ -17,7 +17,8 @@ use crate::{ xcm_config::config::{battery_station, general_key}, - AccountId, AssetRegistry, AssetRegistryStringLimit, Balance, ExistentialDeposit, RuntimeOrigin, + AccountId, AssetRegistry, AssetRegistryStringLimit, Balance, CurrencyId, ExistentialDeposit, + RuntimeOrigin, }; use frame_support::assert_ok; use orml_traits::asset_registry::AssetMetadata; @@ -27,7 +28,7 @@ use xcm::{ VersionedMultiLocation, }; use xcm_emulator::helpers::get_account_id_from_seed; -use zeitgeist_primitives::types::{CustomMetadata, XcmAsset}; +use zeitgeist_primitives::types::{Asset, CustomMetadata}; pub(super) mod accounts { use super::*; @@ -83,10 +84,10 @@ pub const PARA_ID_SIBLING: u32 = 3000; pub const PARA_ID_BATTERY_STATION: u32 = battery_station::ID; /// IDs that are used to represent tokens from other chains -pub const FOREIGN_ZTG_ID: XcmAsset = XcmAsset::ForeignAsset(0); -pub const FOREIGN_PARENT_ID: XcmAsset = XcmAsset::ForeignAsset(1); -pub const FOREIGN_SIBLING_ID: XcmAsset = XcmAsset::ForeignAsset(2); -pub const BTC_ID: XcmAsset = XcmAsset::ForeignAsset(3); +pub const FOREIGN_ZTG_ID: Asset = CurrencyId::ForeignAsset(0); +pub const FOREIGN_PARENT_ID: Asset = CurrencyId::ForeignAsset(1); +pub const FOREIGN_SIBLING_ID: Asset = CurrencyId::ForeignAsset(2); +pub const BTC_ID: Asset = CurrencyId::ForeignAsset(3); #[inline] pub(super) const fn ztg(amount: Balance) -> Balance { 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 c568b95a1..3efef4810 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 @@ -26,13 +26,14 @@ use crate::{ test_net::BatteryStation, }, xcm_config::config::{battery_station, general_key, AssetConvert}, - Assets, CustomMetadata, ScalarPosition, XcmAsset, + CurrencyId, }; use core::fmt::Debug; use sp_runtime::traits::{Convert, MaybeEquivalence}; use test_case::test_case; use xcm::latest::{Junction::*, Junctions::*, MultiLocation}; use xcm_emulator::TestExt; +use zeitgeist_primitives::types::{Asset, CustomMetadata, ScalarPosition}; fn convert_common_native(expected: T) where @@ -70,7 +71,7 @@ fn convert_common_non_native( BatteryStation::execute_with(|| { assert_eq!(>::convert(&multilocation), None); assert_eq!(>::convert(expected), None); - // Register parent as foreign asset in the BatteryStation parachain + // Register parent as foreign asset in the Battery Station parachain register(None); assert_eq!( >::convert(&multilocation), @@ -82,18 +83,13 @@ fn convert_common_non_native( #[test] fn convert_native_assets() { - convert_common_native(Assets::Ztg); -} - -#[test] -fn convert_native_xcm_assets() { - convert_common_native(XcmAsset::Ztg); + convert_common_native(Asset::Ztg); } #[test] fn convert_any_registered_parent_multilocation_assets() { convert_common_non_native( - Assets::from(FOREIGN_PARENT_ID), + FOREIGN_PARENT_ID, foreign_parent_multilocation(), register_foreign_parent, ); @@ -102,7 +98,7 @@ fn convert_any_registered_parent_multilocation_assets() { #[test] fn convert_any_registered_parent_multilocation_xcm_assets() { convert_common_non_native( - XcmAsset::try_from(Assets::from(FOREIGN_PARENT_ID)).unwrap(), + FOREIGN_PARENT_ID, foreign_parent_multilocation(), register_foreign_parent, ); @@ -111,7 +107,7 @@ fn convert_any_registered_parent_multilocation_xcm_assets() { #[test] fn convert_any_registered_sibling_multilocation_assets() { convert_common_non_native( - Assets::from(FOREIGN_SIBLING_ID), + FOREIGN_SIBLING_ID, foreign_sibling_multilocation(), register_foreign_sibling, ); @@ -120,7 +116,7 @@ fn convert_any_registered_sibling_multilocation_assets() { #[test] fn convert_any_registered_sibling_multilocation_xcm_assets() { convert_common_non_native( - XcmAsset::try_from(Assets::from(FOREIGN_SIBLING_ID)).unwrap(), + FOREIGN_SIBLING_ID, foreign_sibling_multilocation(), register_foreign_sibling, ); @@ -133,43 +129,16 @@ fn convert_unkown_multilocation() { BatteryStation::execute_with(|| { assert!( - >::convert(&unknown_location).is_none() + >::convert(&unknown_location).is_none() ); }); } -#[test_case( - Assets::CategoricalOutcome(7, 8); - "assets_categorical" -)] -#[test_case( - Assets::ScalarOutcome(7, ScalarPosition::Long); - "assets_scalar" -)] -#[test_case( - Assets::PoolShare(7); - "assets_pool_share" -)] -#[test_case( - Assets::ForeignAsset(7); - "assets_foreign" -)] -#[test_case( - Assets::ParimutuelShare(7, 8); - "assets_parimutuel_share" -)] -#[test_case( - Assets::CampaignAsset(7); - "assets_campaign_asset" -)] -#[test_case( - Assets::CustomAsset(7); - "assets_custom_asset" -)] -#[test_case( - XcmAsset::ForeignAsset(7); - "xcm_assets_foreign" -)] +#[test_case(Asset::CategoricalOutcome(7, 8))] +#[test_case(Asset::ScalarOutcome(7, ScalarPosition::Long))] +#[test_case(Asset::PoolShare(7))] +#[test_case(Asset::ForeignAsset(7))] +#[test_case(Asset::ParimutuelShare(7, 8))] fn convert_unsupported_asset(asset: T) where T: Copy + Debug + PartialEq, 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 825bbdbc1..ed5b786d5 100644 --- a/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs +++ b/runtime/battery-station/src/integration_tests/xcm/tests/transfers.rs @@ -27,7 +27,8 @@ use crate::{ test_net::{BatteryStation, Rococo, Sibling}, }, xcm_config::fees::default_per_second, - AssetManager, Balance, Balances, RuntimeOrigin, XTokens, ZeitgeistTreasuryAccount, + AssetManager, Balance, Balances, CurrencyId, RuntimeOrigin, Tokens, XTokens, + ZeitgeistTreasuryAccount, }; use frame_support::{assert_ok, traits::tokens::fungible::Mutate}; @@ -36,7 +37,7 @@ use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, WeightLimi use xcm_emulator::{RelayChain, TestExt}; use zeitgeist_primitives::{ constants::{BalanceFractionalDecimals, BASE}, - types::{CustomMetadata, XcmAsset, XcmMetadata}, + types::{Asset, CustomMetadata, XcmMetadata}, }; #[test] @@ -48,8 +49,8 @@ fn transfer_ztg_to_sibling() { Sibling::execute_with(|| { treasury_initial_balance = - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); register_foreign_ztg(None); }); @@ -58,7 +59,7 @@ fn transfer_ztg_to_sibling() { assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), - XcmAsset::Ztg, + CurrencyId::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -80,15 +81,12 @@ fn transfer_ztg_to_sibling() { }); Sibling::execute_with(|| { - let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let bob_expected = bob_initial_balance + transfer_amount - ztg_fee(); let treasury_expected = treasury_initial_balance + ztg_fee(); - - // Verify that bob() now has (amount transferred - fee) assert_eq!(current_balance, bob_expected); - // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()), + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -104,8 +102,8 @@ fn transfer_ztg_to_sibling_with_custom_fee() { Sibling::execute_with(|| { treasury_initial_balance = - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let custom_metadata = CustomMetadata { xcm: XcmMetadata { fee_factor: Some(fee_factor) }, ..Default::default() @@ -118,7 +116,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), - XcmAsset::Ztg, + Asset::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -139,7 +137,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { }); Sibling::execute_with(|| { - let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let custom_fee = ztg_fee() * fee_factor / BASE; let bob_expected = bob_initial_balance + transfer_amount - custom_fee; let treasury_expected = treasury_initial_balance + custom_fee; @@ -148,7 +146,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { assert_eq!(current_balance, bob_expected); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()), + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -172,7 +170,7 @@ fn transfer_ztg_sibling_to_zeitgeist() { Sibling::execute_with(|| { register_foreign_ztg(None); - let bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(bob()), @@ -192,7 +190,7 @@ fn transfer_ztg_sibling_to_zeitgeist() { )); // Confirm that Bobs's balance is initial balance - amount transferred assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()), + AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()), bob_initial_balance - transfer_amount ); }); @@ -225,8 +223,8 @@ fn transfer_btc_sibling_to_zeitgeist() { BatteryStation::execute_with(|| { register_btc(None); treasury_initial_balance = - AssetManager::free_balance(BTC_ID.into(), &ZeitgeistTreasuryAccount::get()); - zeitgeist_alice_initial_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + AssetManager::free_balance(BTC_ID, &ZeitgeistTreasuryAccount::get()); + zeitgeist_alice_initial_balance = AssetManager::free_balance(BTC_ID, &alice()); }); Sibling::execute_with(|| { @@ -241,7 +239,7 @@ fn transfer_btc_sibling_to_zeitgeist() { assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), // Target chain will interpret XcmAsset::Ztg as BTC in this context. - XcmAsset::Ztg, + CurrencyId::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -271,12 +269,12 @@ fn transfer_btc_sibling_to_zeitgeist() { // Verify that remote Alice now has initial balance + amount transferred - fee assert_eq!( - AssetManager::free_balance(BTC_ID.into(), &alice()), + AssetManager::free_balance(BTC_ID, &alice()), zeitgeist_alice_initial_balance + expected_adjusted, ); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(BTC_ID.into(), &ZeitgeistTreasuryAccount::get()), + Tokens::free_balance(BTC_ID, &ZeitgeistTreasuryAccount::get()), // Align decimal fractional places expected_treasury ) @@ -300,7 +298,7 @@ fn transfer_btc_zeitgeist_to_sibling() { BatteryStation::execute_with(|| { register_btc(None); - let alice_initial_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + let alice_initial_balance = AssetManager::free_balance(BTC_ID, &alice()); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), @@ -319,8 +317,7 @@ fn transfer_btc_zeitgeist_to_sibling() { WeightLimit::Limited(4_000_000_000.into()), )); - // Confirm that Alice's balance is initial_balance - amount_transferred - let alice_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + let alice_balance = AssetManager::free_balance(BTC_ID, &alice()); let alice_expected = alice_initial_balance - adjusted_balance(btc(1), transfer_amount); assert_eq!(alice_balance, alice_expected); }); @@ -345,8 +342,8 @@ fn transfer_roc_from_relay_chain() { BatteryStation::execute_with(|| { register_foreign_parent(None); treasury_initial_balance = - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_PARENT_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID, &bob()); }); Rococo::execute_with(|| { @@ -367,10 +364,10 @@ fn transfer_roc_from_relay_chain() { let bob_expected = bob_initial_balance + adjusted_balance(roc(1), expected); let treasury_expected = treasury_initial_balance + adjusted_balance(roc(1), roc_fee()); - assert_eq!(AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &bob()), bob_expected); + assert_eq!(AssetManager::free_balance(FOREIGN_PARENT_ID, &bob()), bob_expected); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &ZeitgeistTreasuryAccount::get()), + AssetManager::free_balance(FOREIGN_PARENT_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -393,7 +390,7 @@ fn transfer_roc_to_relay_chain() { BatteryStation::execute_with(|| { register_foreign_parent(None); - let initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &alice()); + let initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID, &alice()); assert!(initial_balance >= transfer_amount_local); assert_ok!(XTokens::transfer( @@ -411,7 +408,7 @@ fn transfer_roc_to_relay_chain() { )); assert_eq!( - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &alice()), + AssetManager::free_balance(FOREIGN_PARENT_ID, &alice()), initial_balance - transfer_amount_local ) }); diff --git a/runtime/battery-station/src/lib.rs b/runtime/battery-station/src/lib.rs index 51bab0a57..b1d287da2 100644 --- a/runtime/battery-station/src/lib.rs +++ b/runtime/battery-station/src/lib.rs @@ -30,7 +30,7 @@ use common_runtime::{ }; pub use frame_system::{ Call as SystemCall, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, - CheckTxVersion, CheckWeight, EnsureNever, + CheckTxVersion, CheckWeight, }; #[cfg(feature = "parachain")] pub use pallet_author_slot_filter::EligibilityValue; @@ -42,17 +42,12 @@ pub use crate::parachain_params::*; pub use crate::parameters::*; use alloc::vec; use frame_support::{ - traits::{ - AsEnsureOriginWithArg, ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, - InstanceFilter, - }, + traits::{ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter}, weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight}, }; -use frame_system::{EnsureRoot, EnsureSigned, EnsureWithSuccess}; +use frame_system::{EnsureRoot, EnsureWithSuccess}; use orml_currencies::Call::transfer; -use pallet_assets::Call::{destroy_accounts, destroy_approvals, finish_destroy}; use pallet_collective::{EnsureProportionAtLeast, PrimeDefaultVote}; -use parity_scale_codec::Compact; use sp_runtime::traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -69,7 +64,7 @@ use zrml_swaps::Call::{ }; #[cfg(feature = "parachain")] use { - frame_support::traits::{Everything, Nothing}, + frame_support::traits::{AsEnsureOriginWithArg, Everything, Nothing}, xcm_builder::{EnsureXcmOrigin, FixedWeightBounds}, xcm_config::{ asset_registry::CustomAssetProcessor, @@ -172,26 +167,6 @@ impl Contains for IsCallable { fn contains(call: &RuntimeCall) -> bool { #[allow(clippy::match_like_matches_macro)] match call { - // Asset destruction is managed. Instead of deleting those dispatchable calls, they are - // filtered here instead to allow root to interact in case of emergency. - RuntimeCall::CampaignAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, - RuntimeCall::CustomAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, - RuntimeCall::MarketAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, RuntimeCall::SimpleDisputes(_) => false, RuntimeCall::LiquidityMining(_) => false, RuntimeCall::PredictionMarkets(inner_call) => match inner_call { diff --git a/runtime/battery-station/src/parameters.rs b/runtime/battery-station/src/parameters.rs index 9b06c07b8..adb216b19 100644 --- a/runtime/battery-station/src/parameters.rs +++ b/runtime/battery-station/src/parameters.rs @@ -22,7 +22,7 @@ clippy::arithmetic_side_effects )] -use super::{CampaignAssetsInstance, Runtime, VERSION}; +use super::{Runtime, VERSION}; use frame_support::{ dispatch::DispatchClass, parameter_types, @@ -35,7 +35,6 @@ use frame_support::{ }; use frame_system::limits::{BlockLength, BlockWeights}; use orml_traits::parameter_type_with_key; -use pallet_assets::WeightInfo; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ traits::{AccountIdConversion, Bounded}, @@ -65,46 +64,6 @@ parameter_types! { } parameter_types! { - // Asset-Router - pub DestroyAccountWeight: Weight = - >::WeightInfo::destroy_accounts(1); - pub DestroyApprovalWeight: Weight = - >::WeightInfo::destroy_approvals(1); - pub DestroyFinishWeight: Weight = - >::WeightInfo::finish_destroy(); - - // Assets (Campaign) - pub const CampaignAssetsAccountDeposit: Balance = deposit(1, 16); - pub const CampaignAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - /// The amount of native currency that is frozen during the whole lifetime - /// if an asset class. Freezing happens at asset class creation. - /// Irrelevant - No origin can successfully call the associated dispatchable call. - pub const CampaignAssetsDeposit: Balance = BASE; - pub const CampaignAssetsStringLimit: u32 = 256; - pub const CampaignAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const CampaignAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - - // Assets (Custom) - pub const CustomAssetsAccountDeposit: Balance = deposit(1, 16); - pub const CustomAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - /// The amount of native currency that is frozen during the whole lifetime - /// of an asset class. Freezing happens at asset class creation. - pub const CustomAssetsDeposit: Balance = BASE; - pub const CustomAssetsStringLimit: u32 = 50; - pub const CustomAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const CustomAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - - // Assets (Market) - pub const MarketAssetsAccountDeposit: Balance = deposit(1, 16); - pub const MarketAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - /// The amount of native currency that is frozen during the whole lifetime - /// of an asset class. Freezing happens at asset class creation. - /// Irrelevant - No origin can successfully call the associated dispatchable call. - pub const MarketAssetsDeposit: Balance = BASE; - pub const MarketAssetsStringLimit: u32 = 50; - pub const MarketAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const MarketAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - // Authorized pub const AuthorizedPalletId: PalletId = AUTHORIZED_PALLET_ID; pub const CorrectionPeriod: BlockNumber = BLOCKS_PER_DAY; @@ -244,7 +203,7 @@ parameter_types! { pub const MaxLiquidityTreeDepth: u32 = 9u32; // ORML - pub const GetNativeCurrencyId: Assets = Asset::Ztg; + pub const GetNativeCurrencyId: CurrencyId = Asset::Ztg; // Prediction Market parameters /// (Slashable) Bond that is provided for creating an advised market that needs approval. @@ -403,8 +362,6 @@ parameter_types! { .build_or_panic(); // Transaction payment - /// A fee multiplier applied to the calculated fee factor for `CampaignAsset` - pub const CampaignAssetFeeMultiplier: u32 = 100; /// A fee mulitplier for Operational extrinsics to compute “virtual tip” /// to boost their priority. pub const OperationalFeeMultiplier: u8 = 5; @@ -512,17 +469,17 @@ parameter_type_with_key! { // 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: Currencies| -> Balance { + pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { - Currencies::CategoricalOutcome(_, _) => ExistentialDeposit::get(), - Currencies::ParimutuelShare(_, _) => ExistentialDeposit::get(), - Currencies::PoolShare(_) => ExistentialDeposit::get(), - Currencies::ScalarOutcome(_, _) => ExistentialDeposit::get(), + Asset::CategoricalOutcome(_,_) => ExistentialDeposit::get(), + Asset::CombinatorialOutcome => ExistentialDeposit::get(), + Asset::PoolShare(_) => ExistentialDeposit::get(), + Asset::ScalarOutcome(_,_) => ExistentialDeposit::get(), #[cfg(feature = "parachain")] - Currencies::ForeignAsset(id) => { + Asset::ForeignAsset(id) => { let maybe_metadata = < orml_asset_registry::Pallet as orml_traits::asset_registry::Inspect - >::metadata(&XcmAsset::ForeignAsset(*id)); + >::metadata(&Asset::ForeignAsset(*id)); if let Some(metadata) = maybe_metadata { return metadata.existential_deposit; @@ -531,7 +488,9 @@ parameter_type_with_key! { 1 } #[cfg(not(feature = "parachain"))] - Currencies::ForeignAsset(_) => ExistentialDeposit::get(), + Asset::ForeignAsset(_) => ExistentialDeposit::get(), + Asset::Ztg => ExistentialDeposit::get(), + Asset::ParimutuelShare(_,_) => ExistentialDeposit::get(), } }; } diff --git a/runtime/battery-station/src/xcm_config/asset_registry.rs b/runtime/battery-station/src/xcm_config/asset_registry.rs index ab6c618a4..4b3b044a6 100644 --- a/runtime/battery-station/src/xcm_config/asset_registry.rs +++ b/runtime/battery-station/src/xcm_config/asset_registry.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{AssetRegistryStringLimit, Balance, XcmAsset}; +use crate::{AssetRegistryStringLimit, Balance, CurrencyId}; use orml_traits::asset_registry::{AssetMetadata, AssetProcessor}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; @@ -29,14 +29,14 @@ use zeitgeist_primitives::types::CustomMetadata; /// Only pre check is to ensure an asset id was passed. pub struct CustomAssetProcessor; -impl AssetProcessor> +impl AssetProcessor> for CustomAssetProcessor { fn pre_register( - id: Option, + id: Option, metadata: AssetMetadata, ) -> Result< - (XcmAsset, AssetMetadata), + (CurrencyId, AssetMetadata), DispatchError, > { match id { @@ -46,7 +46,7 @@ impl AssetProcessor, ) -> Result<(), DispatchError> { Ok(()) diff --git a/runtime/battery-station/src/xcm_config/config.rs b/runtime/battery-station/src/xcm_config/config.rs index f9008fea9..b30c2b92b 100644 --- a/runtime/battery-station/src/xcm_config/config.rs +++ b/runtime/battery-station/src/xcm_config/config.rs @@ -1,4 +1,5 @@ // Copyright 2022-2024 Forecasting Technologies LTD. +// Copyright 2023 Centrifuge Foundation (centrifuge.io). // // This file is part of Zeitgeist. // @@ -17,11 +18,12 @@ use super::fees::{native_per_second, FixedConversionRateProvider}; use crate::{ - AccountId, AssetManager, AssetRegistry, Assets, Balance, MaxAssetsIntoHolding, MaxInstructions, - ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, RuntimeCall, - RuntimeOrigin, UnitWeightCost, UniversalLocation, UnknownTokens, XcmpQueue, + AccountId, AssetManager, AssetRegistry, Balance, CurrencyId, MaxAssetsIntoHolding, + MaxInstructions, ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, + RuntimeCall, RuntimeOrigin, UnitWeightCost, UniversalLocation, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, }; + use alloc::vec::Vec; use core::{cmp::min, marker::PhantomData}; use frame_support::{ @@ -50,8 +52,8 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, WithComputedOrigin, }; -use xcm_executor::{traits::TransactAsset, Assets as ExecutorAssets}; -use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::XcmAsset}; +use xcm_executor::{traits::TransactAsset, Assets}; +use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::Asset}; pub mod battery_station { #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -163,7 +165,7 @@ impl TakeRevenue for ToTreasury { if let MultiAsset { id: Concrete(location), fun: Fungible(_amount) } = revenue { if let Some(asset_id) = - >::convert(&location) + >::convert(&location) { let adj_am = AlignedFractionalMultiAssetTransactor::adjust_fractional_places(&revenue).fun; @@ -188,7 +190,7 @@ parameter_types! { native_per_second(), 0, ); - /// The amount of canonical ZTG charged per second of execution. + /// The amount of ZTG charged per second of execution. pub ZtgPerSecond: (AssetId, u128, u128) = ( MultiLocation::new( 1, @@ -219,9 +221,9 @@ pub struct AlignedFractionalTransactAsset< } impl< - AssetRegistry: Inspect, + AssetRegistry: Inspect, FracDecPlaces: Get, - CurrencyIdConvert: Convert>, + CurrencyIdConvert: Convert>, TransactAssetDelegate: TransactAsset, > AlignedFractionalTransactAsset< @@ -232,41 +234,29 @@ impl< > { fn adjust_fractional_places(asset: &MultiAsset) -> MultiAsset { - let (asset_id, amount) = - if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { - if let Fungible(amount) = asset.fun { - (*asset_id, amount) - } else { - return asset.clone(); + if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { + if let Fungible(amount) = asset.fun { + let mut asset_updated = asset.clone(); + let native_decimals = u32::from(FracDecPlaces::get()); + let metadata = AssetRegistry::metadata(asset_id); + + if let Some(metadata) = metadata { + let decimals = metadata.decimals; + + asset_updated.fun = if decimals > native_decimals { + let power = decimals.saturating_sub(native_decimals); + let adjust_factor = 10u128.saturating_pow(power); + // Floors the adjusted token amount, thus no tokens are generated + Fungible(amount.saturating_div(adjust_factor)) + } else { + let power = native_decimals.saturating_sub(decimals); + let adjust_factor = 10u128.saturating_pow(power); + Fungible(amount.saturating_mul(adjust_factor)) + }; + + return asset_updated; } - } else { - return asset.clone(); - }; - - let currency = if let Ok(currency) = XcmAsset::try_from(asset_id) { - currency - } else { - return asset.clone(); - }; - - let metadata = AssetRegistry::metadata(¤cy); - if let Some(metadata) = metadata { - let mut asset_adjusted = asset.clone(); - let decimals = metadata.decimals; - let native_decimals = u32::from(FracDecPlaces::get()); - - asset_adjusted.fun = if decimals > native_decimals { - let power = decimals.saturating_sub(native_decimals); - let adjust_factor = 10u128.saturating_pow(power); - // Floors the adjusted token amount, thus no tokens are generated - Fungible(amount.saturating_div(adjust_factor)) - } else { - let power = native_decimals.saturating_sub(decimals); - let adjust_factor = 10u128.saturating_pow(power); - Fungible(amount.saturating_mul(adjust_factor)) - }; - - return asset_adjusted; + } } asset.clone() @@ -274,8 +264,8 @@ impl< } impl< - AssetRegistry: Inspect, - CurrencyIdConvert: Convert>, + AssetRegistry: Inspect, + CurrencyIdConvert: Convert>, FracDecPlaces: Get, TransactAssetDelegate: TransactAsset, > TransactAsset @@ -299,7 +289,7 @@ impl< asset: &MultiAsset, location: &MultiLocation, maybe_context: Option<&XcmContext>, - ) -> Result { + ) -> Result { let asset_adjusted = Self::adjust_fractional_places(asset); TransactAssetDelegate::withdraw_asset(&asset_adjusted, location, maybe_context) } @@ -309,7 +299,7 @@ impl< from: &MultiLocation, to: &MultiLocation, context: &XcmContext, - ) -> Result { + ) -> Result { let asset_adjusted = Self::adjust_fractional_places(asset); TransactAssetDelegate::transfer_asset(&asset_adjusted, from, to, context) } @@ -330,17 +320,17 @@ pub type MultiAssetTransactor = MultiCurrencyAdapter< UnknownTokens, // This means that this adapter should handle any token that `AssetConvert` can convert // using AssetManager and UnknownTokens in all other cases. - IsNativeConcrete, + IsNativeConcrete, // Our chain's account ID type (we can't get away without mentioning it explicitly). AccountId, // Convert an XCM `MultiLocation` into a local account id. LocationToAccountId, // The AssetId that corresponds to the native currency. - Assets, + CurrencyId, // Struct that provides functions to convert `Asset` <=> `MultiLocation`. AssetConvert, // In case of deposit failure, known assets will be placed in treasury. - DepositToAlternative, + DepositToAlternative, >; /// AssetConvert @@ -352,35 +342,33 @@ pub struct AssetConvert; /// Convert our `Asset` type into its `MultiLocation` representation. /// Other chains need to know how this conversion takes place in order to /// handle it on their side. -impl Convert> for AssetConvert { - fn convert(id: Assets) -> Option { - >::convert_back(&id) - } -} - -impl Convert> for AssetConvert { - fn convert(location: MultiLocation) -> Option { - >::convert(&location) - } -} - -impl Convert> for AssetConvert { - fn convert(id: XcmAsset) -> Option { - >::convert_back(&id) +impl Convert> for AssetConvert { + fn convert(id: CurrencyId) -> Option { + match id { + Asset::Ztg => Some(MultiLocation::new( + 1, + X2( + Junction::Parachain(ParachainInfo::parachain_id().into()), + general_key(battery_station::KEY), + ), + )), + Asset::ForeignAsset(_) => AssetRegistry::multilocation(&id).ok()?, + _ => None, + } } } /// Convert an incoming `MultiLocation` into a `Asset` if possible. /// Here we need to know the canonical representation of all the tokens we handle in order to /// correctly convert their `MultiLocation` representation into our internal `Asset` type. -impl MaybeEquivalence for AssetConvert { - fn convert(location: &MultiLocation) -> Option { +impl MaybeEquivalence for AssetConvert { + fn convert(location: &MultiLocation) -> Option { match location { MultiLocation { parents: 0, interior: X1(GeneralKey { data, length }) } => { let key = &data[..data.len().min(*length as usize)]; if key == battery_station::KEY { - return Some(Assets::Ztg); + return Some(CurrencyId::Ztg); } None @@ -392,50 +380,32 @@ impl MaybeEquivalence for AssetConvert { let key = &data[..data.len().min(*length as usize)]; if *para_id == u32::from(ParachainInfo::parachain_id()) { - if key == battery_station::KEY { - return Some(Assets::Ztg); - } - - return None; + if key == battery_station::KEY { Some(CurrencyId::Ztg) } else { None } + } else { + AssetRegistry::location_to_asset_id(location) } - - AssetRegistry::location_to_asset_id(location).map(|a| a.into()) } - _ => AssetRegistry::location_to_asset_id(location).map(|a| a.into()), + _ => AssetRegistry::location_to_asset_id(location), } } - fn convert_back(id: &Assets) -> Option { + fn convert_back(id: &CurrencyId) -> Option { match id { - Assets::Ztg => Some(MultiLocation::new( + Asset::Ztg => Some(MultiLocation::new( 1, X2( Junction::Parachain(ParachainInfo::parachain_id().into()), general_key(battery_station::KEY), ), )), - Assets::ForeignAsset(_) => { - let asset = XcmAsset::try_from(*id).ok()?; - AssetRegistry::multilocation(&asset).ok()? - } + Asset::ForeignAsset(_) => AssetRegistry::multilocation(id).ok()?, _ => None, } } } -impl MaybeEquivalence for AssetConvert { - fn convert(location: &MultiLocation) -> Option { - >::convert(location) - .and_then(|asset| asset.try_into().ok()) - } - - fn convert_back(id: &XcmAsset) -> Option { - >::convert_back(&Assets::from(*id)) - } -} - -impl Convert> for AssetConvert { - fn convert(asset: MultiAsset) -> Option { +impl Convert> for AssetConvert { + fn convert(asset: MultiAsset) -> Option { if let MultiAsset { id: Concrete(location), .. } = asset { >::convert(&location) } else { @@ -444,6 +414,12 @@ impl Convert> for AssetConvert { } } +impl Convert> for AssetConvert { + fn convert(location: MultiLocation) -> Option { + >::convert(&location) + } +} + pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { diff --git a/runtime/battery-station/src/xcm_config/fees.rs b/runtime/battery-station/src/xcm_config/fees.rs index bc6178eee..21936a5b1 100644 --- a/runtime/battery-station/src/xcm_config/fees.rs +++ b/runtime/battery-station/src/xcm_config/fees.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{Balance, XcmAsset}; +use crate::{Balance, CurrencyId}; use core::marker::PhantomData; use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}; use xcm::latest::MultiLocation; @@ -56,7 +56,7 @@ pub struct FixedConversionRateProvider(PhantomData impl< AssetRegistry: orml_traits::asset_registry::Inspect< - AssetId = XcmAsset, + AssetId = CurrencyId, Balance = Balance, CustomMetadata = CustomMetadata, >, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index d1c481e52..19d5eb756 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -6,7 +6,6 @@ frame-system = { workspace = true } orml-currencies = { workspace = true } orml-tokens = { workspace = true } pallet-asset-tx-payment = { workspace = true } -pallet-assets = { workspace = true } pallet-author-inherent = { workspace = true, optional = true } pallet-author-mapping = { workspace = true, optional = true } pallet-author-slot-filter = { workspace = true, optional = true } @@ -50,7 +49,6 @@ std = [ "frame-support/std", "orml-currencies/std", "orml-tokens/std", - "pallet-assets/std", "pallet-asset-tx-payment/std", "pallet-author-inherent?/std", "pallet-author-mapping?/std", diff --git a/runtime/common/src/fees.rs b/runtime/common/src/fees.rs index ffa268f68..d9aa1c621 100644 --- a/runtime/common/src/fees.rs +++ b/runtime/common/src/fees.rs @@ -40,8 +40,9 @@ macro_rules! impl_fee_types { } pub struct DealWithForeignFees; - impl OnUnbalanced> for DealWithForeignFees { - fn on_unbalanced(fees_and_tips: Credit) { + + impl OnUnbalanced> for DealWithForeignFees { + fn on_unbalanced(fees_and_tips: Credit) { // We have to manage the mint / burn ratio on the Zeitgeist chain, // but we do not have the responsibility and necessary knowledge to // manage the mint / burn ratio for any other chain. @@ -50,7 +51,7 @@ macro_rules! impl_fee_types { // on_unbalanced is not implemented for other currencies than the native currency // https://github.com/paritytech/substrate/blob/85415fb3a452dba12ff564e6b093048eed4c5aad/frame/treasury/src/lib.rs#L618-L627 // https://github.com/paritytech/substrate/blob/5ea6d95309aaccfa399c5f72e5a14a4b7c6c4ca1/frame/treasury/src/lib.rs#L490 - let res = AssetRouter::resolve( + let res = >::resolve( &TreasuryPalletId::get().into_account_truncating(), fees_and_tips, ); @@ -63,8 +64,6 @@ macro_rules! impl_fee_types { #[macro_export] macro_rules! impl_foreign_fees { () => { - #[cfg(feature = "parachain")] - use frame_support::ensure; use frame_support::{ pallet_prelude::InvalidTransaction, traits::{ @@ -88,7 +87,7 @@ macro_rules! impl_foreign_fees { }; use zeitgeist_primitives::{ math::fixed::{FixedDiv, FixedMul}, - types::{Assets, TxPaymentAssetId}, + types::TxPaymentAssetId, }; #[repr(u8)] @@ -98,13 +97,12 @@ macro_rules! impl_foreign_fees { NoAssetMetadata = 2, NoFeeFactor = 3, NonForeignAssetPaid = 4, - InvalidAssetType = 5, } // It does calculate foreign fees by extending transactions to include an optional // `AssetId` that specifies the asset to be used for payment (defaulting to the native // token on `None`), such that for each transaction the asset id can be specified. - // For real ZTG `None` is used and for DOT `Some(Currencies::ForeignAsset(0))` is used. + // For real ZTG `None` is used and for DOT `Some(Asset::Foreign(0))` is used. pub(crate) fn calculate_fee( native_fee: Balance, @@ -125,64 +123,15 @@ macro_rules! impl_foreign_fees { Ok(converted_fee) } - fn get_fee_factor_campaign_asset( - campaign_asset: CampaignAsset, - ) -> Result { - let ztg_supply = Balances::total_issuance(); - let campaign_asset_supply = AssetManager::total_issuance(campaign_asset.into()); - let fee_multiplier = Balance::from(CampaignAssetFeeMultiplier::get()); - - let ztg_div_campaign_supply = ztg_supply.checked_div(campaign_asset_supply).ok_or( - TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::FeeConversionArith as u8, - )), - )?; - - // Use neutral fee multiplier if the ZTG supply is 100x greater than the campaign - // asset supply. - if ztg_div_campaign_supply >= fee_multiplier { - Ok(BASE) - } else { - campaign_asset_supply.saturating_mul(fee_multiplier).bdiv(ztg_supply).map_err( - |_| { - TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::FeeConversionArith as u8, - )) - }, - ) - } - } - - #[cfg(not(feature = "parachain"))] - fn get_fee_factor_foreign_asset( - _foreign_asset: Currencies, - ) -> Result { - Err(TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::NoForeignAssetsOnStandaloneChain as u8, - ))) - } - #[cfg(feature = "parachain")] - fn get_fee_factor_foreign_asset( - foreign_asset: Currencies, + pub(crate) fn get_fee_factor( + currency_id: CurrencyId, ) -> Result { - ensure!( - foreign_asset.is_foreign_asset(), + let metadata = ::metadata(¤cy_id).ok_or( TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::InvalidAssetType as u8, - )) - ); - let metadata_asset: XcmAsset = - Assets::from(foreign_asset).try_into().map_err(|_| { - TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::InvalidAssetType as u8, - )) - })?; - - let metadata = ::metadata(&metadata_asset) - .ok_or(TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTxError::NoAssetMetadata as u8, - )))?; + )), + )?; let fee_factor = metadata.additional.xcm.fee_factor.ok_or(TransactionValidityError::Invalid( InvalidTransaction::Custom(CustomTxError::NoFeeFactor as u8), @@ -190,75 +139,70 @@ macro_rules! impl_foreign_fees { Ok(fee_factor) } - pub(crate) fn get_fee_factor(asset: Assets) -> Result { - if let Ok(campaign_asset) = CampaignAsset::try_from(asset) { - return get_fee_factor_campaign_asset(campaign_asset); - } else if let Ok(currency) = Currencies::try_from(asset) { - return get_fee_factor_foreign_asset(currency); - } - - Err(TransactionValidityError::Invalid(InvalidTransaction::Custom( - CustomTxError::InvalidAssetType as u8, - ))) - } - pub struct TTCBalanceToAssetBalance; - impl ConversionToAssetBalance for TTCBalanceToAssetBalance { + impl ConversionToAssetBalance + for TTCBalanceToAssetBalance + { type Error = TransactionValidityError; fn to_asset_balance( native_fee: Balance, - asset: Assets, + asset_id: TxPaymentAssetId, ) -> Result { - let fee_factor = get_fee_factor(asset)?; - let converted_fee = calculate_fee(native_fee, fee_factor)?; - Ok(converted_fee) + #[cfg(feature = "parachain")] + { + let currency_id = Asset::ForeignAsset(asset_id); + let fee_factor = get_fee_factor(currency_id)?; + let converted_fee = calculate_fee(native_fee, fee_factor)?; + Ok(converted_fee) + } + #[cfg(not(feature = "parachain"))] + { + Err(TransactionValidityError::Invalid(InvalidTransaction::Custom( + CustomTxError::NoForeignAssetsOnStandaloneChain as u8, + ))) + } } } pub struct TTCHandleCredit; - impl HandleCredit for TTCHandleCredit { - fn handle_credit(final_fee: Credit) { - let asset = final_fee.asset(); - - if CampaignAsset::try_from(asset).is_ok() { - drop(final_fee); - } else if Currencies::try_from(asset).is_ok() { - DealWithForeignFees::on_unbalanced(final_fee); - } + impl HandleCredit for TTCHandleCredit { + fn handle_credit(final_fee: Credit) { + // Handle the final fee and tip, e.g. by transferring to the treasury. + DealWithForeignFees::on_unbalanced(final_fee); } } - pub struct TxCharger; - impl pallet_asset_tx_payment::OnChargeAssetTransaction for TxCharger { - type AssetId = Assets; + pub struct TokensTxCharger; + impl pallet_asset_tx_payment::OnChargeAssetTransaction for TokensTxCharger { + type AssetId = TxPaymentAssetId; type Balance = Balance; - type LiquidityInfo = Credit; + type LiquidityInfo = Credit; fn withdraw_fee( who: &AccountId, - _call: &RuntimeCall, + call: &RuntimeCall, _dispatch_info: &DispatchInfoOf, asset_id: Self::AssetId, native_fee: Self::Balance, _tip: Self::Balance, ) -> Result { - // We don't know the precision of the underlying asset. Because the converted fee could be - // less than one (e.g. 0.5) but gets rounded down by integer division we introduce a minimum - // fee. + // We don't know the precision of the underlying asset. Because the converted fee + // could be less than one (e.g. 0.5) but gets rounded down by integer division we + // introduce a minimum fee. let min_converted_fee = if native_fee.is_zero() { Zero::zero() } else { One::one() }; let converted_fee = TTCBalanceToAssetBalance::to_asset_balance(native_fee, asset_id)? .max(min_converted_fee); - + let currency_id = Asset::ForeignAsset(asset_id); let can_withdraw = - >::can_withdraw(asset_id, who, converted_fee); + >::can_withdraw(currency_id, who, converted_fee); if can_withdraw != WithdrawConsequence::Success { return Err(InvalidTransaction::Payment.into()); } - >::withdraw( - asset_id, + >::withdraw( + currency_id, who, converted_fee, Precision::Exact, @@ -278,20 +222,32 @@ macro_rules! impl_foreign_fees { ) -> Result<(Self::Balance, Self::Balance), TransactionValidityError> { let min_converted_fee = if corrected_native_fee.is_zero() { Zero::zero() } else { One::one() }; - - let asset = paid.asset(); + let asset_id = match paid.asset() { + Asset::ForeignAsset(asset_id) => asset_id, + _ => { + return Err(TransactionValidityError::Invalid(InvalidTransaction::Custom( + CustomTxError::NonForeignAssetPaid as u8, + ))); + } + }; // Convert the corrected fee and tip into the asset used for payment. let converted_fee = - TTCBalanceToAssetBalance::to_asset_balance(corrected_native_fee, asset)? + TTCBalanceToAssetBalance::to_asset_balance(corrected_native_fee, asset_id)? .max(min_converted_fee); + let converted_tip = TTCBalanceToAssetBalance::to_asset_balance(tip, asset_id)?; - // Refund to the account that paid the fees. If this fails, the account might have dropped - // below the existential balance. In that case we don't refund anything. + // Calculate how much refund we should return. let (final_fee, refund) = paid.split(converted_fee); - let _ = AssetRouter::resolve(who, refund); - let final_fee_raw = final_fee.peek(); + // Refund to the account that paid the fees. If this fails, the account might have + // dropped below the existential balance. In that case we don't refund anything. + let _ = >::resolve(who, refund); + + // Handle the final fee and tip, e.g. by transferring to the treasury. + // Note: The `corrected_native_fee` already includes the `tip`. + let final_fee_peek = final_fee.peek(); TTCHandleCredit::handle_credit(final_fee); - Ok((final_fee_raw, tip)) + + Ok((final_fee_peek, tip)) } } }; @@ -302,9 +258,9 @@ macro_rules! impl_market_creator_fees { () => { pub struct MarketCreatorFee; - /// Uses the `creator_fee` field defined by the specified market to deduct a fee for the market's - /// creator. Calling `distribute` is noop if the market doesn't exist or the transfer fails for any - /// reason. + /// Uses the `creator_fee` field defined by the specified market to deduct a fee for the + /// market's creator. Calling `distribute` is noop if the market doesn't exist or the + /// transfer fails for any reason. impl DistributeFees for MarketCreatorFee { type Asset = Asset; type AccountId = AccountId; @@ -355,18 +311,13 @@ macro_rules! impl_market_creator_fees { #[macro_export] macro_rules! fee_tests { - () => { + () => { use crate::*; - use frame_support::{ - assert_noop, assert_ok, - dispatch::DispatchClass, - traits::{fungible::Unbalanced, fungibles::Create}, - weights::Weight, - }; + use frame_support::{assert_noop, assert_ok, dispatch::DispatchClass, weights::Weight}; use orml_traits::MultiCurrency; use pallet_asset_tx_payment::OnChargeAssetTransaction; use sp_core::H256; - use sp_runtime::{traits::Convert, BuildStorage}; + use sp_runtime::BuildStorage; use zeitgeist_primitives::constants::BASE; fn run_with_system_weight(w: Weight, mut assertions: F) @@ -405,126 +356,21 @@ macro_rules! fee_tests { frame_system::GenesisConfig::::default().build_storage().unwrap().into(); t.execute_with(|| { let fee_and_tip_balance = 10 * ExistentialDeposit::get(); - let fees_and_tips = AssetRouter::issue(Asset::ForeignAsset(0), fee_and_tip_balance); + let fees_and_tips = >::issue( + Asset::ForeignAsset(0), + fee_and_tip_balance, + ); assert!( - AssetRouter::free_balance(Asset::ForeignAsset(0), &Treasury::account_id()) - .is_zero() + Tokens::free_balance(Asset::ForeignAsset(0), &Treasury::account_id()).is_zero() ); DealWithForeignFees::on_unbalanced(fees_and_tips); assert_eq!( - AssetRouter::free_balance(Asset::ForeignAsset(0), &Treasury::account_id()), + Tokens::free_balance(Asset::ForeignAsset(0), &Treasury::account_id()), fee_and_tip_balance, ); }); } - #[test] - fn fee_payment_campaign_assets_withdraws_correct_amount() { - let mut t: sp_io::TestExternalities = - frame_system::GenesisConfig::::default().build_storage().unwrap().into(); - t.execute_with(|| { - let asset = Asset::CampaignAsset(0); - let alice = AccountId::from([0u8; 32]); - let initial_balance: Balance = 1_000_000_000_000; - let native_fee: Balance = 1_000_000; - let fee_multiplier: Balance = CampaignAssetFeeMultiplier::get().into(); - - let ztg_supply = initial_balance * fee_multiplier - 1; - let fee_factor = - initial_balance.saturating_mul(fee_multiplier).bdiv(ztg_supply).unwrap(); - let expected_fee = calculate_fee(native_fee, fee_factor).unwrap(); - let mock_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); - - Balances::set_total_issuance(ztg_supply); - assert_ok!(AssetRouter::create(asset, alice.clone(), true, 1)); - assert_ok!(AssetManager::deposit(asset, &alice, initial_balance)); - - assert_eq!( - TxCharger::withdraw_fee( - &alice, - &mock_call, - &Default::default(), - asset, - native_fee, - 0 - ) - .unwrap() - .peek(), - expected_fee - ); - assert_eq!( - AssetManager::total_balance(asset, &alice), - initial_balance - expected_fee - ); - }); - } - - fn campaign_asset_throttled_fee_common() -> Credit { - let asset = Asset::CampaignAsset(0); - let alice = AccountId::from([0u8; 32]); - let initial_balance: Balance = 1_000_000_000_000; - let native_fee: Balance = 1_000_000; - let fee_multiplier: Balance = CampaignAssetFeeMultiplier::get().into(); - - let ztg_supply = initial_balance.bmul(fee_multiplier * initial_balance + 1).unwrap(); - let mock_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); - - Balances::set_total_issuance(ztg_supply); - assert_ok!(AssetRouter::create(asset, alice.clone(), true, 1)); - assert_ok!(AssetManager::deposit(asset, &alice, initial_balance)); - - let withdrawn = TxCharger::withdraw_fee( - &alice, - &mock_call, - &Default::default(), - asset, - native_fee, - 0, - ) - .unwrap(); - assert_eq!(withdrawn.peek(), native_fee); - assert_eq!(AssetManager::total_balance(asset, &alice), initial_balance - native_fee); - - withdrawn - } - - #[test] - fn fee_payment_campaign_assets_withdraws_correct_amount_throttled() { - let mut t: sp_io::TestExternalities = - frame_system::GenesisConfig::::default().build_storage().unwrap().into(); - t.execute_with(|| { - let _ = campaign_asset_throttled_fee_common(); - }); - } - - #[test] - fn fee_payment_campaign_assets_corrects_reimburses_and_burns_fees_properly() { - let mut t: sp_io::TestExternalities = - frame_system::GenesisConfig::::default().build_storage().unwrap().into(); - t.execute_with(|| { - let asset = Asset::CampaignAsset(0); - let withdrawn = campaign_asset_throttled_fee_common(); - let amount = withdrawn.peek(); - let native_fee_adjusted: Balance = 1_000_000 / 2; - let alice = AccountId::from([0u8; 32]); - let initial_balance: Balance = 1_000_000_000_000; - let fee_multiplier = get_fee_factor(asset).unwrap(); - let fee = calculate_fee(native_fee_adjusted, fee_multiplier).unwrap(); - let expected = initial_balance - fee; - - assert_ok!(TxCharger::correct_and_deposit_fee( - &alice, - &Default::default(), - &Default::default(), - native_fee_adjusted, - 0, - withdrawn - )); - assert_eq!(AssetManager::total_balance(asset, &alice), expected); - assert_eq!(AssetManager::total_issuance(Asset::CampaignAsset(0)), expected); - }); - } - #[test] fn fee_multiplier_can_grow_from_zero() { let minimum_multiplier = MinimumMultiplier::get(); @@ -551,60 +397,65 @@ macro_rules! fee_tests { .unwrap() .into(); t.execute_with(|| { - let alice = AccountId::from([0u8; 32]); - let fee_factor = 143_120_520; - let custom_metadata = CustomMetadata { - xcm: XcmMetadata { fee_factor: Some(fee_factor) }, - ..Default::default() - }; - let meta: AssetMetadata = - AssetMetadata { + { + let alice = AccountId::from([0u8; 32]); + let fee_factor = 143_120_520; + let custom_metadata = CustomMetadata { + xcm: XcmMetadata { fee_factor: Some(fee_factor) }, + ..Default::default() + }; + let meta: AssetMetadata = AssetMetadata { decimals: 10, name: "Polkadot".as_bytes().to_vec().try_into().unwrap(), symbol: "DOT".as_bytes().to_vec().try_into().unwrap(), existential_deposit: ExistentialDeposit::get(), - location: Some(xcm::VersionedMultiLocation::V3( - xcm::latest::MultiLocation::parent(), - )), + location: Some(xcm::VersionedMultiLocation::V3(xcm::latest::MultiLocation::parent())), additional: custom_metadata, }; - let dot = Asset::ForeignAsset(0); + let dot = Asset::ForeignAsset(0); + + assert_ok!(AssetRegistry::register_asset(RuntimeOrigin::root(), meta.clone(), Some(dot))); - assert_ok!(AssetRegistry::register_asset( - RuntimeOrigin::root(), - meta.clone(), - Some(dot.try_into().unwrap()) - )); - assert_ok!(AssetManager::deposit(dot, &Treasury::account_id(), BASE)); - - let free_balance_treasury_before = - AssetManager::free_balance(dot, &Treasury::account_id()); - let free_balance_alice_before = AssetManager::free_balance(dot, &alice); - let corrected_native_fee = BASE; - let paid = AssetRouter::issue(dot, 2 * BASE); - let paid_balance = paid.peek(); - let tip = 0u128; - assert_ok!(TxCharger::correct_and_deposit_fee( - &alice, - &Default::default(), - &Default::default(), - corrected_native_fee, - tip, - paid, - )); - let treasury_gain = AssetManager::free_balance(dot, &Treasury::account_id()) - - free_balance_treasury_before; - let alice_gain = - AssetManager::free_balance(dot, &alice) - free_balance_alice_before; + assert_ok!(>::deposit(dot, &Treasury::account_id(), BASE)); - let decimals = meta.decimals; - let base = 10u128.checked_pow(decimals).unwrap(); + let mock_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); + let mock_dispatch_info = frame_support::dispatch::DispatchInfo { + weight: frame_support::weights::Weight::zero(), + class: DispatchClass::Normal, + pays_fee: frame_support::dispatch::Pays::Yes, + }; + let mock_post_info = frame_support::dispatch::PostDispatchInfo { + actual_weight: Some(frame_support::weights::Weight::zero()), + pays_fee: frame_support::dispatch::Pays::Yes, + }; - let dot_fee = ((corrected_native_fee * fee_factor) + (base / 2)) / base; - assert_eq!(dot_fee, treasury_gain); - assert_eq!(143_120_520, treasury_gain); - assert_eq!(paid_balance - treasury_gain, alice_gain); + let free_balance_treasury_before = Tokens::free_balance(dot, &Treasury::account_id()); + let free_balance_alice_before = Tokens::free_balance(dot, &alice); + let corrected_native_fee = BASE; + let paid = >::issue(dot, 2 * BASE); + let paid_balance = paid.peek(); + let tip = 0u128; + assert_ok!(>::correct_and_deposit_fee( + &alice, + &mock_dispatch_info, + &mock_post_info, + corrected_native_fee, + tip, + paid, + )); + + let treasury_gain = Tokens::free_balance(dot, &Treasury::account_id()) - free_balance_treasury_before; + let alice_gain = Tokens::free_balance(dot, &alice) - free_balance_alice_before; + + let decimals = meta.decimals; + let base = 10u128.checked_pow(decimals).unwrap(); + + let dot_fee = ((corrected_native_fee * fee_factor) + (base / 2)) / base; + assert_eq!(dot_fee, treasury_gain); + assert_eq!(143_120_520, treasury_gain); + assert_eq!(paid_balance - treasury_gain, alice_gain); + } }); } @@ -632,7 +483,7 @@ macro_rules! fee_tests { additional: custom_metadata, }; let dot_asset_id = 0u32; - let dot = XcmAsset::ForeignAsset(dot_asset_id); + let dot = Asset::ForeignAsset(dot_asset_id); assert_ok!(AssetRegistry::register_asset( RuntimeOrigin::root(), @@ -640,7 +491,7 @@ macro_rules! fee_tests { Some(dot) )); - assert_eq!(get_fee_factor(dot.into()).unwrap(), 143_120_520u128); + assert_eq!(get_fee_factor(dot).unwrap(), 143_120_520u128); }); } @@ -686,7 +537,7 @@ macro_rules! fee_tests { additional: custom_metadata, }; let dot_asset_id = 0u32; - let dot = XcmAsset::ForeignAsset(dot_asset_id); + let dot = Asset::ForeignAsset(dot_asset_id); assert_ok!(AssetRegistry::register_asset( RuntimeOrigin::root(), @@ -695,7 +546,7 @@ macro_rules! fee_tests { )); assert_noop!( - get_fee_factor(dot.into()), + get_fee_factor(dot), TransactionValidityError::Invalid(InvalidTransaction::Custom(3u8)) ); }); @@ -722,15 +573,15 @@ macro_rules! fee_tests { location: None, additional: custom_metadata, }; - let non_location_token = XcmAsset::ForeignAsset(1); + let non_location_token = Asset::ForeignAsset(1); assert_ok!(AssetRegistry::register_asset( RuntimeOrigin::root(), meta, - Some(Assets::from(non_location_token).try_into().unwrap()) + Some(non_location_token) )); - assert_eq!(get_fee_factor(non_location_token.into()).unwrap(), 10_393); + assert_eq!(get_fee_factor(non_location_token).unwrap(), 10_393); }); } @@ -764,20 +615,29 @@ macro_rules! fee_tests { assert_ok!(AssetRegistry::register_asset( RuntimeOrigin::root(), meta, - Some(dot.try_into().unwrap()) + Some(dot) )); - let fees_and_tips = AssetRouter::issue(dot, 0); - assert_ok!(AssetManager::deposit(dot, &Treasury::account_id(), BASE)); + let fees_and_tips = >::issue(dot, 0); + assert_ok!(>::deposit( + dot, + &Treasury::account_id(), + BASE + )); let mock_call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); + let mock_dispatch_info = frame_support::dispatch::DispatchInfo { + weight: frame_support::weights::Weight::zero(), + class: DispatchClass::Normal, + pays_fee: frame_support::dispatch::Pays::Yes, + }; assert_eq!( - TxCharger::withdraw_fee( + >::withdraw_fee( &Treasury::account_id(), &mock_call, - &Default::default(), - dot, + &mock_dispatch_info, + dot_asset_id, BASE / 2, 0, ) @@ -788,5 +648,5 @@ macro_rules! fee_tests { }); } } - }; + } } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 4efb91c1b..49465d932 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -74,9 +74,11 @@ macro_rules! decl_common_types { traits::{Currency, Get, Imbalance, NeverEnsureOrigin, OnRuntimeUpgrade, OnUnbalanced}, BoundedVec, Twox64Concat, }; + use frame_system::EnsureSigned; #[cfg(feature = "try-runtime")] use frame_try_runtime::{TryStateSelect, UpgradeCheckSelect}; use orml_traits::MultiCurrency; + use pallet_balances::CreditOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_core::storage::ChildInfo; @@ -84,8 +86,6 @@ macro_rules! decl_common_types { generic, DispatchError, DispatchResult, RuntimeDebug, SaturatedConversion, }; use zeitgeist_primitives::traits::{DeployPoolApi, DistributeFees, MarketCommonsPalletApi}; - use zrml_market_commons::migrations::MigrateScoringRuleAmmCdaHybridAndMarketId; - use zrml_neo_swaps::migration::MigratePoolReservesToBoundedBTreeMap; pub type Block = generic::Block; @@ -104,12 +104,9 @@ macro_rules! decl_common_types { StorageVersion::new(4).put::(); StorageVersion::new(4).put::(); StorageVersion::new(4).put::(); - StorageVersion::new(1).put::(); - StorageVersion::new(1).put::(); - StorageVersion::new(1).put::(); StorageVersion::new(15).put::(); log::info!("FixStorageVersions: Done!"); - ::DbWeight::get().writes(12) + ::DbWeight::get().writes(9) } #[cfg(feature = "try-runtime")] @@ -217,11 +214,6 @@ macro_rules! decl_common_types { pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - // Asset instances - type CustomAssetsInstance = pallet_assets::Instance1; - type CampaignAssetsInstance = pallet_assets::Instance2; - type MarketAssetsInstance = pallet_assets::Instance3; - // Governance type AdvisoryCommitteeInstance = pallet_collective::Instance1; type AdvisoryCommitteeMembershipInstance = pallet_membership::Instance1; @@ -404,9 +396,6 @@ macro_rules! create_runtime { Multisig: pallet_multisig::{Call, Event, Pallet, Storage} = 14, Bounties: pallet_bounties::{Call, Event, Pallet, Storage} = 15, AssetTxPayment: pallet_asset_tx_payment::{Event, Pallet} = 16, - CustomAssets: pallet_assets::::{Call, Pallet, Storage, Event} = 17, - CampaignAssets: pallet_assets::::{Call, Pallet, Storage, Event} = 18, - MarketAssets: pallet_assets::::{Call, Pallet, Storage, Event} = 19, // Governance Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 20, @@ -441,7 +430,6 @@ macro_rules! create_runtime { NeoSwaps: zrml_neo_swaps::{Call, Event, Pallet, Storage} = 60, Orderbook: zrml_orderbook::{Call, Event, Pallet, Storage} = 61, Parimutuel: zrml_parimutuel::{Call, Event, Pallet, Storage} = 62, - AssetRouter: zrml_asset_router::{Pallet} = 63, HybridRouter: zrml_hybrid_router::{Call, Event, Pallet, Storage} = 64, $($additional_pallets)* @@ -707,7 +695,7 @@ macro_rules! impl_config_traits { #[cfg(feature = "parachain")] impl orml_asset_registry::Config for Runtime { - type AssetId = XcmAsset; + type AssetId = CurrencyId; type AssetProcessor = CustomAssetProcessor; type AuthorityOrigin = AsEnsureOriginWithArg; type Balance = Balance; @@ -719,14 +707,14 @@ macro_rules! impl_config_traits { impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = weights::orml_currencies::WeightInfo; } pub struct CurrencyHooks(sp_std::marker::PhantomData); impl - orml_traits::currency::MutationHooks + orml_traits::currency::MutationHooks for CurrencyHooks { type OnDust = orml_tokens::TransferDust; @@ -743,7 +731,7 @@ macro_rules! impl_config_traits { type Amount = Amount; type Balance = Balance; type CurrencyHooks = CurrencyHooks; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = DustRemovalWhitelist; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -763,7 +751,7 @@ macro_rules! impl_config_traits { type AccountIdToMultiLocation = AccountIdToMultiLocation; type Balance = Balance; type BaseXcmWeight = BaseXcmWeight; - type CurrencyId = XcmAsset; + type CurrencyId = CurrencyId; type CurrencyIdConvert = AssetConvert; type RuntimeEvent = RuntimeEvent; type MaxAssetsForTransfer = MaxAssetsForTransfer; @@ -776,111 +764,8 @@ macro_rules! impl_config_traits { type XcmExecutor = xcm_executor::XcmExecutor; } - // Required for runtime benchmarks - pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } - } - - impl pallet_assets::Config for Runtime { - type ApprovalDeposit = CustomAssetsApprovalDeposit; - type AssetAccountDeposit = CustomAssetsAccountDeposit; - type AssetDeposit = CustomAssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Destroyer = AssetRouter; - type Extra = (); - type ForceOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; - type Freezer = (); - type MetadataDepositBase = CustomAssetsMetadataDepositBase; - type MetadataDepositPerByte = CustomAssetsMetadataDepositPerByte; - // TODO(#1176): Figure out sensible number after benchmark on reference machine - type RemoveItemsLimit = ConstU32<{ 50 }>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = CustomAssetsStringLimit; - type WeightInfo = weights::pallet_assets::WeightInfo; - } - - impl pallet_assets::Config for Runtime { - type ApprovalDeposit = CampaignAssetsApprovalDeposit; - type AssetAccountDeposit = CampaignAssetsAccountDeposit; - type AssetDeposit = CampaignAssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Destroyer = AssetRouter; - type Extra = (); - type ForceOrigin = EnsureRootOrTwoThirdsCouncil; - type Freezer = (); - type MetadataDepositBase = CampaignAssetsMetadataDepositBase; - type MetadataDepositPerByte = CampaignAssetsMetadataDepositPerByte; - // TODO(#1176): Figure out sensible number after benchmark on reference machine - type RemoveItemsLimit = ConstU32<{ 50 }>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = CampaignAssetsStringLimit; - type WeightInfo = weights::pallet_assets::WeightInfo; - } - - // Required for runtime benchmarks - pallet_assets::runtime_benchmarks_enabled! { - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } - } - - impl pallet_assets::Config for Runtime { - type ApprovalDeposit = MarketAssetsApprovalDeposit; - type AssetAccountDeposit = MarketAssetsAccountDeposit; - type AssetDeposit = MarketAssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Destroyer = AssetRouter; - type Extra = (); - type ForceOrigin = EnsureRootOrAllTechnicalCommittee; - type Freezer = (); - type MetadataDepositBase = MarketAssetsMetadataDepositBase; - type MetadataDepositPerByte = MarketAssetsMetadataDepositPerByte; - // TODO(#1176): Figure out sensible number after benchmark on reference machine - type RemoveItemsLimit = ConstU32<{ 50 }>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = MarketAssetsStringLimit; - type WeightInfo = weights::pallet_assets::WeightInfo; - } - pub struct DustIntoTreasury; - type CreditOfBalances = pallet_balances::CreditOf; + type CreditOfBalances = CreditOf; impl OnUnbalanced for DustIntoTreasury { fn on_nonzero_unbalanced(mut dust: CreditOfBalances) { let imbalance = NegativeImbalance::new(dust.peek()); @@ -1269,8 +1154,8 @@ macro_rules! impl_config_traits { impl pallet_asset_tx_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Fungibles = AssetRouter; - type OnChargeAssetTransaction = TxCharger; + type Fungibles = Tokens; + type OnChargeAssetTransaction = TokensTxCharger; } impl pallet_transaction_payment::Config for Runtime { @@ -1341,22 +1226,6 @@ macro_rules! impl_config_traits { #[cfg(feature = "parachain")] impl parachain_info::Config for Runtime {} - impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; - } - impl zrml_authorized::Config for Runtime { type AuthorizedDisputeResolutionOrigin = EnsureRootOrMoreThanHalfAdvisoryCommittee; type Currency = Balances; @@ -1434,12 +1303,7 @@ macro_rules! impl_config_traits { impl zrml_prediction_markets::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; type ApproveOrigin = EnsureRootOrMoreThanOneThirdAdvisoryCommittee; - type AssetManager = AssetManager; - #[cfg(feature = "parachain")] - type AssetRegistry = AssetRegistry; type Authorized = Authorized; type Currency = Balances; type Court = Court; @@ -1469,8 +1333,6 @@ macro_rules! impl_config_traits { type MinCategories = MinCategories; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; - // Can be a tuple of hooks - type OnStateTransition = (Parimutuel,); type OracleBond = OracleBond; type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; @@ -1479,6 +1341,9 @@ macro_rules! impl_config_traits { 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 ValidityBond = ValidityBond; @@ -1530,8 +1395,9 @@ macro_rules! impl_config_traits { } impl zrml_swaps::Config for Runtime { - type Asset = Assets; + type Asset = Asset; type RuntimeEvent = RuntimeEvent; + type MultiCurrency = AssetManager; type ExitFee = ExitFee; type MinAssets = MinAssets; type MaxAssets = MaxAssets; @@ -1540,7 +1406,6 @@ macro_rules! impl_config_traits { type MaxWeight = MaxWeight; type MinWeight = MinWeight; type PalletId = SwapsPalletId; - type AssetManager = AssetManager; type WeightInfo = zrml_swaps::weights::WeightInfo; } @@ -1575,14 +1440,12 @@ macro_rules! impl_config_traits { } impl zrml_parimutuel::Config for Runtime { - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; - type AssetManager = AssetManager; type ExternalFees = MarketCreatorFee; + type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; + type AssetManager = AssetManager; type MinBetSize = MinBetSize; type PalletId = ParimutuelPalletId; - type RuntimeEvent = RuntimeEvent; type WeightInfo = zrml_parimutuel::weights::WeightInfo; } @@ -1698,7 +1561,6 @@ macro_rules! create_runtime_api { list_benchmark!(list, extra, frame_system, SystemBench::); orml_list_benchmark!(list, extra, orml_currencies, crate::benchmarks::currencies); orml_list_benchmark!(list, extra, orml_tokens, crate::benchmarks::tokens); - list_benchmark!(list, extra, pallet_assets, CustomAssets); list_benchmark!(list, extra, pallet_balances, Balances); list_benchmark!(list, extra, pallet_bounties, Bounties); list_benchmark!(list, extra, pallet_collective, AdvisoryCommittee); @@ -1790,7 +1652,6 @@ macro_rules! create_runtime_api { add_benchmark!(params, batches, frame_system, SystemBench::); orml_add_benchmark!(params, batches, orml_currencies, crate::benchmarks::currencies); orml_add_benchmark!(params, batches, orml_tokens, crate::benchmarks::tokens); - add_benchmark!(params, batches, pallet_assets, CustomAssets); add_benchmark!(params, batches, pallet_balances, Balances); add_benchmark!(params, batches, pallet_bounties, Bounties); add_benchmark!(params, batches, pallet_collective, AdvisoryCommittee); @@ -2112,15 +1973,15 @@ macro_rules! create_runtime_api { asset_in: &Asset, asset_out: &Asset, with_fees: bool, - ) -> Balance { - Swaps::get_spot_price(pool_id, asset_in, asset_out, with_fees).ok().unwrap_or(0) + ) -> SerdeWrapper { + SerdeWrapper(Swaps::get_spot_price(pool_id, asset_in, asset_out, with_fees).ok().unwrap_or(0)) } fn pool_account_id(pool_id: &PoolId) -> AccountId { Swaps::pool_account_id(pool_id) } - fn pool_shares_id(pool_id: PoolId) -> Asset { + fn pool_shares_id(pool_id: PoolId) -> Asset> { Asset::PoolShare(pool_id) } } @@ -2185,29 +2046,26 @@ macro_rules! create_runtime_api { #[macro_export] macro_rules! create_common_benchmark_logic { - {} => { + () => { #[cfg(feature = "runtime-benchmarks")] pub(crate) mod benchmarks { pub(crate) mod currencies { use super::utils::{lookup_of_account, set_balance}; use crate::{ - AccountId, Amount, AssetManager, Balance, Assets, ExistentialDeposit, - GetNativeCurrencyId, Runtime + AccountId, Amount, AssetManager, Balance, CurrencyId, ExistentialDeposit, + GetNativeCurrencyId, Runtime, }; use alloc::vec; use frame_benchmarking::{account, whitelisted_caller}; use frame_system::RawOrigin; - use sp_runtime::traits::UniqueSaturatedInto; use orml_benchmarking::runtime_benchmarks; use orml_traits::MultiCurrency; - use zeitgeist_primitives::{ - constants::BASE, - types::Asset, - }; + use sp_runtime::traits::UniqueSaturatedInto; + use zeitgeist_primitives::{constants::BASE, types::Asset}; const SEED: u32 = 0; - const NATIVE: Assets = GetNativeCurrencyId::get(); - const ASSET: Assets = Asset::CategoricalOutcome(0, 0); + const NATIVE: CurrencyId = GetNativeCurrencyId::get(); + const ASSET: CurrencyId = Asset::CategoricalOutcome(0, 0); runtime_benchmarks! { { Runtime, orml_currencies } @@ -2222,7 +2080,10 @@ macro_rules! create_common_benchmark_logic { let to_lookup = lookup_of_account(to.clone()); }: transfer(RawOrigin::Signed(from), to_lookup, ASSET, amount) verify { - assert_eq!(>::total_balance(ASSET, &to), amount); + assert_eq!( + >::total_balance(ASSET, &to), + amount, + ); } // `transfer` native currency and in worst case @@ -2237,7 +2098,10 @@ macro_rules! create_common_benchmark_logic { let to_lookup = lookup_of_account(to.clone()); }: transfer(RawOrigin::Signed(from), to_lookup, NATIVE, amount) verify { - assert_eq!(>::total_balance(NATIVE, &to), amount); + assert_eq!( + >::total_balance(NATIVE, &to), + amount, + ); } // `transfer_native_currency` in worst case @@ -2253,7 +2117,10 @@ macro_rules! create_common_benchmark_logic { let to_lookup = lookup_of_account(to.clone()); }: _(RawOrigin::Signed(from), to_lookup, amount) verify { - assert_eq!(>::total_balance(NATIVE, &to), amount); + assert_eq!( + >::total_balance(NATIVE, &to), + amount, + ); } // `update_balance` for non-native currency @@ -2264,7 +2131,10 @@ macro_rules! create_common_benchmark_logic { let who_lookup = lookup_of_account(who.clone()); }: update_balance(RawOrigin::Root, who_lookup, ASSET, amount) verify { - assert_eq!(>::total_balance(ASSET, &who), balance); + assert_eq!( + >::total_balance(ASSET, &who), + balance, + ); } // `update_balance` for native currency @@ -2277,7 +2147,10 @@ macro_rules! create_common_benchmark_logic { let who_lookup = lookup_of_account(who.clone()); }: update_balance(RawOrigin::Root, who_lookup, NATIVE, amount) verify { - assert_eq!(>::total_balance(NATIVE, &who), balance); + assert_eq!( + >::total_balance(NATIVE, &who), + balance, + ); } // `update_balance` for native currency @@ -2291,7 +2164,10 @@ macro_rules! create_common_benchmark_logic { set_balance(NATIVE, &who, balance); }: update_balance(RawOrigin::Root, who_lookup, NATIVE, -amount) verify { - assert_eq!(>::free_balance(NATIVE, &who), 0); + assert_eq!( + >::free_balance(NATIVE, &who), + 0, + ); } } @@ -2307,16 +2183,16 @@ macro_rules! create_common_benchmark_logic { pub(crate) mod tokens { use super::utils::{lookup_of_account, set_balance as update_balance}; - use crate::{AccountId, Balance, Tokens, Runtime}; + use crate::{AccountId, Balance, CurrencyId, Runtime, Tokens}; use alloc::vec; use frame_benchmarking::{account, whitelisted_caller}; use frame_system::RawOrigin; use orml_benchmarking::runtime_benchmarks; use orml_traits::MultiCurrency; - use zeitgeist_primitives::{constants::BASE, types::Currencies}; + use zeitgeist_primitives::{constants::BASE, types::Asset}; const SEED: u32 = 0; - const ASSET: Currencies = Currencies::ForeignAsset(7); + const ASSET: CurrencyId = Asset::CategoricalOutcome(0, 0); runtime_benchmarks! { { Runtime, orml_tokens } @@ -2325,7 +2201,7 @@ macro_rules! create_common_benchmark_logic { let amount: Balance = BASE; let from: AccountId = whitelisted_caller(); - update_balance(ASSET.into(), &from, amount); + update_balance(ASSET, &from, amount); let to: AccountId = account("to", 0, SEED); let to_lookup = lookup_of_account(to.clone()); @@ -2338,7 +2214,7 @@ macro_rules! create_common_benchmark_logic { let amount: Balance = BASE; let from: AccountId = whitelisted_caller(); - update_balance(ASSET.into(), &from, amount); + update_balance(ASSET, &from, amount); let to: AccountId = account("to", 0, SEED); let to_lookup = lookup_of_account(to); @@ -2349,7 +2225,7 @@ macro_rules! create_common_benchmark_logic { transfer_keep_alive { let from: AccountId = whitelisted_caller(); - update_balance(ASSET.into(), &from, 2 * BASE); + update_balance(ASSET, &from, 2 * BASE); let to: AccountId = account("to", 0, SEED); let to_lookup = lookup_of_account(to.clone()); @@ -2361,7 +2237,7 @@ macro_rules! create_common_benchmark_logic { force_transfer { let from: AccountId = account("from", 0, SEED); let from_lookup = lookup_of_account(from.clone()); - update_balance(ASSET.into(), &from, 2 * BASE); + update_balance(ASSET, &from, 2 * BASE); let to: AccountId = account("to", 0, SEED); let to_lookup = lookup_of_account(to.clone()); @@ -2376,7 +2252,10 @@ macro_rules! create_common_benchmark_logic { }: _(RawOrigin::Root, who_lookup, ASSET, BASE, BASE) verify { - assert_eq!(>::total_balance(ASSET, &who), 2 * BASE); + assert_eq!( + >::total_balance(ASSET, &who), + 2 * BASE, + ); } } @@ -2391,8 +2270,7 @@ macro_rules! create_common_benchmark_logic { } pub(crate) mod utils { - use crate::{AccountId, AssetManager, Balance, Assets, Runtime, - }; + use crate::{AccountId, AssetManager, Balance, CurrencyId, Runtime}; use frame_support::assert_ok; use orml_traits::MultiCurrencyExtended; use sp_runtime::traits::{SaturatedConversion, StaticLookup}; @@ -2403,7 +2281,7 @@ macro_rules! create_common_benchmark_logic { ::Lookup::unlookup(who) } - pub fn set_balance(currency_id: Assets, who: &AccountId, balance: Balance) { + pub fn set_balance(currency_id: CurrencyId, who: &AccountId, balance: Balance) { assert_ok!(>::update_balance( currency_id, who, @@ -2417,17 +2295,20 @@ macro_rules! create_common_benchmark_logic { use sp_runtime::BuildStorage; pub fn new_test_ext() -> sp_io::TestExternalities { - frame_system::GenesisConfig::::default().build_storage().unwrap().into() + frame_system::GenesisConfig::::default() + .build_storage() + .unwrap() + .into() } } } } - } + }; } #[macro_export] macro_rules! create_common_tests { - {} => { + () => { #[cfg(test)] mod common_tests { common_runtime::fee_tests!(); @@ -2435,8 +2316,8 @@ macro_rules! create_common_tests { mod dust_removal { use crate::*; use frame_support::PalletId; - use test_case::test_case; use sp_runtime::BuildStorage; + use test_case::test_case; #[test_case(AuthorizedPalletId::get(); "authorized")] #[test_case(CourtPalletId::get(); "court")] @@ -2447,10 +2328,14 @@ macro_rules! create_common_tests { #[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(); + 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); + let pallet_sub_account: AccountId = + pallet_id.into_sub_account_truncating(42); assert!(DustRemovalWhitelist::contains(&pallet_main_account)); assert!(DustRemovalWhitelist::contains(&pallet_sub_account)); }); @@ -2459,7 +2344,10 @@ macro_rules! create_common_tests { #[test] fn non_whitelisted_accounts_get_reaped() { let mut t: sp_io::TestExternalities = - frame_system::GenesisConfig::::default().build_storage().unwrap().into(); + frame_system::GenesisConfig::::default() + .build_storage() + .unwrap() + .into(); t.execute_with(|| { let not_whitelisted = AccountId::from([0u8; 32]); assert!(!DustRemovalWhitelist::contains(¬_whitelisted)) @@ -2467,5 +2355,5 @@ macro_rules! create_common_tests { } } } - } + }; } diff --git a/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs b/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs index fd9f8104c..5c21871e7 100644 --- a/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/runtime/common/src/weights/cumulus_pallet_xcmp_queue.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for cumulus_pallet_xcmp_queue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,25 +52,25 @@ use frame_support::{ /// Weight functions for cumulus_pallet_xcmp_queue (automatically generated) pub struct WeightInfo(PhantomData); impl cumulus_pallet_xcmp_queue::weights::WeightInfo for WeightInfo { - /// Storage: XcmpQueue QueueConfig (r:1 w:1) - /// Proof Skipped: XcmpQueue QueueConfig (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `XcmpQueue::QueueConfig` (r:1 w:1) + /// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_config_with_u32() -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `670` - // Minimum execution time: 8_140 nanoseconds. - Weight::from_parts(9_770_000, 670) + // Measured: `142` + // Estimated: `1627` + // Minimum execution time: 11_060 nanoseconds. + Weight::from_parts(11_850_000, 1627) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: XcmpQueue QueueConfig (r:1 w:1) - /// Proof Skipped: XcmpQueue QueueConfig (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `XcmpQueue::QueueConfig` (r:1 w:1) + /// Proof: `XcmpQueue::QueueConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_config_with_weight() -> Weight { // Proof Size summary in bytes: - // Measured: `175` - // Estimated: `670` - // Minimum execution time: 9_680 nanoseconds. - Weight::from_parts(10_780_000, 670) + // Measured: `142` + // Estimated: `1627` + // Minimum execution time: 10_990 nanoseconds. + Weight::from_parts(11_590_000, 1627) .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 743242b1f..9745d05a4 100644 --- a/runtime/common/src/weights/frame_system.rs +++ b/runtime/common/src/weights/frame_system.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -57,84 +57,85 @@ impl frame_system::weights::WeightInfo for WeightInfo Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_910 nanoseconds. - Weight::from_parts(13_250_000, 0) - // Standard Error: 1 - .saturating_add(Weight::from_parts(2_749, 0).saturating_mul(b.into())) + // Minimum execution time: 14_690 nanoseconds. + Weight::from_parts(15_620_000, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(2_207, 0).saturating_mul(b.into())) } - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: unknown `0x3a686561707061676573` (r:0 w:1) - /// Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `495` - // Minimum execution time: 7_800 nanoseconds. - Weight::from_parts(8_620_000, 495) + // Estimated: `1485` + // Minimum execution time: 9_360 nanoseconds. + Weight::from_parts(10_110_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: System Digest (r:1 w:1) - /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: unknown `0x3a636f6465` (r:0 w:1) - /// Proof Skipped: unknown `0x3a636f6465` (r:0 w:1) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) fn set_code() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 84_000_503_000 picoseconds. - Weight::from_parts(87_586_619_000, 1485) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 134_361_003 nanoseconds. + Weight::from_parts(137_733_640_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_320 nanoseconds. - Weight::from_parts(3_950_000, 0) - // Standard Error: 4_796 - .saturating_add(Weight::from_parts(1_328_378, 0).saturating_mul(i.into())) + // Minimum execution time: 4_480 nanoseconds. + Weight::from_parts(4_680_000, 0) + // Standard Error: 6_558 + .saturating_add(Weight::from_parts(1_695_684, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_720 nanoseconds. - Weight::from_parts(3_950_000, 0) - // Standard Error: 4_270 - .saturating_add(Weight::from_parts(1_057_635, 0).saturating_mul(i.into())) + // Minimum execution time: 5_440 nanoseconds. + Weight::from_parts(5_580_000, 0) + // Standard Error: 3_056 + .saturating_add(Weight::from_parts(1_212_696, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `46 + p * (69 ±0)` - // Estimated: `51 + p * (70 ±0)` - // Minimum execution time: 8_230 nanoseconds. - Weight::from_parts(8_620_000, 51) - // Standard Error: 8_739 - .saturating_add(Weight::from_parts(2_466_850, 0).saturating_mul(p.into())) + // Measured: `48 + p * (69 ±0)` + // Estimated: `52 + p * (70 ±0)` + // Minimum execution time: 9_840 nanoseconds. + Weight::from_parts(10_450_000, 52) + // Standard Error: 8_838 + .saturating_add(Weight::from_parts(2_581_563, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) } diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs index 27fae644e..e1f0aac08 100644 --- a/runtime/common/src/weights/mod.rs +++ b/runtime/common/src/weights/mod.rs @@ -32,7 +32,6 @@ cfg_if::cfg_if! { pub mod frame_system; pub mod orml_currencies; pub mod orml_tokens; -pub mod pallet_assets; pub mod pallet_balances; pub mod pallet_bounties; pub mod pallet_collective; diff --git a/runtime/common/src/weights/orml_currencies.rs b/runtime/common/src/weights/orml_currencies.rs index 6e24034a0..c835e0970 100644 --- a/runtime/common/src/weights/orml_currencies.rs +++ b/runtime/common/src/weights/orml_currencies.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for orml_currencies //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -49,68 +49,64 @@ 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: MarketAssets Asset (r:1 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_non_native_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1862` - // Estimated: `10503` - // Minimum execution time: 87_580 nanoseconds. - Weight::from_parts(106_781_000, 10503) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `1690` + // Estimated: `6186` + // Minimum execution time: 100_000 nanoseconds. + Weight::from_parts(101_700_000, 6186) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_native_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1461` - // Estimated: `2607` - // Minimum execution time: 66_860 nanoseconds. - Weight::from_parts(81_550_000, 2607) + // Measured: `1545` + // Estimated: `3597` + // Minimum execution time: 155_790 nanoseconds. + Weight::from_parts(158_660_000, 3597) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: MarketAssets Asset (r:1 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn update_balance_non_native_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1470` - // Estimated: `10423` - // Minimum execution time: 62_900 nanoseconds. - Weight::from_parts(76_321_000, 10423) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `1361` + // Estimated: `3597` + // Minimum execution time: 68_300 nanoseconds. + Weight::from_parts(70_270_000, 3597) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn update_balance_native_currency_creating() -> Weight { // Proof Size summary in bytes: // Measured: `1401` - // Estimated: `2607` - // Minimum execution time: 56_990 nanoseconds. - Weight::from_parts(69_680_000, 2607) + // Estimated: `3597` + // Minimum execution time: 73_931 nanoseconds. + Weight::from_parts(86_350_000, 3597) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn update_balance_native_currency_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `1525` - // Estimated: `2607` - // Minimum execution time: 65_630 nanoseconds. - Weight::from_parts(66_850_000, 2607) + // Measured: `1493` + // Estimated: `3597` + // Minimum execution time: 73_620 nanoseconds. + Weight::from_parts(86_350_000, 3597) .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 8360b5cb7..55845e706 100644 --- a/runtime/common/src/weights/orml_tokens.rs +++ b/runtime/common/src/weights/orml_tokens.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for orml_tokens //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -49,70 +49,70 @@ 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: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1772` - // Estimated: `7803` - // Minimum execution time: 81_170 nanoseconds. - Weight::from_parts(100_570_000, 7803) + // Measured: `1690` + // Estimated: `6186` + // Minimum execution time: 99_750 nanoseconds. + Weight::from_parts(103_250_000, 6186) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_all() -> Weight { // Proof Size summary in bytes: - // Measured: `1772` - // Estimated: `7803` - // Minimum execution time: 88_531 nanoseconds. - Weight::from_parts(103_920_000, 7803) + // Measured: `1690` + // Estimated: `6186` + // Minimum execution time: 106_030 nanoseconds. + Weight::from_parts(106_950_000, 6186) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `1596` - // Estimated: `7803` - // Minimum execution time: 70_730 nanoseconds. - Weight::from_parts(80_880_000, 7803) + // Measured: `1546` + // Estimated: `6186` + // Minimum execution time: 81_751 nanoseconds. + Weight::from_parts(97_171_000, 6186) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1772` - // Estimated: `10410` - // Minimum execution time: 74_610 nanoseconds. - Weight::from_parts(75_690_000, 10410) + // Measured: `1690` + // Estimated: `6204` + // Minimum execution time: 91_060 nanoseconds. + Weight::from_parts(92_591_000, 6204) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn set_balance() -> Weight { // Proof Size summary in bytes: - // Measured: `1394` - // Estimated: `7723` - // Minimum execution time: 55_800 nanoseconds. - Weight::from_parts(69_101_000, 7723) + // Measured: `1361` + // Estimated: `3597` + // Minimum execution time: 68_000 nanoseconds. + Weight::from_parts(69_950_000, 3597) .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 8b6684d94..5f6f094e1 100644 --- a/runtime/common/src/weights/pallet_author_inherent.rs +++ b/runtime/common/src/weights/pallet_author_inherent.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_author_inherent //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,24 +52,24 @@ use frame_support::{ /// 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) - /// Proof Skipped: ParachainSystem ValidationData (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AuthorInherent HighestSlotSeen (r:1 w:1) - /// Proof: AuthorInherent HighestSlotSeen (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: AuthorInherent Author (r:1 w:0) - /// Proof: AuthorInherent Author (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: ParachainStaking SelectedCandidates (r:1 w:0) - /// Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AuthorFilter EligibleCount (r:1 w:0) - /// Proof Skipped: AuthorFilter EligibleCount (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AuthorInherent::HighestSlotSeen` (r:1 w:1) + /// Proof: `AuthorInherent::HighestSlotSeen` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AuthorInherent::Author` (r:1 w:0) + /// Proof: `AuthorInherent::Author` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::SelectedCandidates` (r:1 w:0) + /// Proof: `ParachainStaking::SelectedCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AuthorFilter::EligibleCount` (r:1 w:0) + /// Proof: `AuthorFilter::EligibleCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) fn kick_off_authorship_validation() -> Weight { // Proof Size summary in bytes: - // Measured: `605` - // Estimated: `7415` - // Minimum execution time: 33_600 nanoseconds. - Weight::from_parts(39_900_000, 7415) + // Measured: `508` + // Estimated: `4079` + // Minimum execution time: 43_860 nanoseconds. + Weight::from_parts(45_200_000, 4079) .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 58377ae98..4a0a28a6c 100644 --- a/runtime/common/src/weights/pallet_author_mapping.rs +++ b/runtime/common/src/weights/pallet_author_mapping.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_author_mapping //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,74 +52,76 @@ use frame_support::{ /// Weight functions for pallet_author_mapping (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_author_mapping::weights::WeightInfo for WeightInfo { - /// Storage: AuthorMapping MappingWithDeposit (r:1 w:1) - /// Proof Skipped: AuthorMapping MappingWithDeposit (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AuthorMapping NimbusLookup (r:0 w:1) - /// Proof Skipped: AuthorMapping NimbusLookup (max_values: None, max_size: None, mode: Measured) + /// Storage: `AuthorMapping::MappingWithDeposit` (r:1 w:1) + /// Proof: `AuthorMapping::MappingWithDeposit` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `AuthorMapping::NimbusLookup` (r:0 w:1) + /// Proof: `AuthorMapping::NimbusLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_association() -> Weight { // Proof Size summary in bytes: - // Measured: `495` - // Estimated: `6072` - // Minimum execution time: 40_210 nanoseconds. - Weight::from_parts(48_940_000, 6072) + // Measured: `430` + // Estimated: `3895` + // Minimum execution time: 60_590 nanoseconds. + Weight::from_parts(61_920_000, 3895) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: AuthorMapping MappingWithDeposit (r:2 w:2) - /// Proof Skipped: AuthorMapping MappingWithDeposit (max_values: None, max_size: None, mode: Measured) - /// Storage: AuthorMapping NimbusLookup (r:0 w:1) - /// Proof Skipped: AuthorMapping NimbusLookup (max_values: None, max_size: None, mode: Measured) + /// Storage: `AuthorMapping::MappingWithDeposit` (r:2 w:2) + /// Proof: `AuthorMapping::MappingWithDeposit` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AuthorMapping::NimbusLookup` (r:0 w:1) + /// Proof: `AuthorMapping::NimbusLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) fn update_association() -> Weight { // Proof Size summary in bytes: - // Measured: `440` - // Estimated: `5830` - // Minimum execution time: 30_800 nanoseconds. - Weight::from_parts(37_970_000, 5830) + // Measured: `375` + // Estimated: `6315` + // Minimum execution time: 40_210 nanoseconds. + Weight::from_parts(40_880_000, 6315) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: AuthorMapping MappingWithDeposit (r:1 w:1) - /// Proof Skipped: AuthorMapping MappingWithDeposit (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AuthorMapping NimbusLookup (r:0 w:1) - /// Proof Skipped: AuthorMapping NimbusLookup (max_values: None, max_size: None, mode: Measured) + /// Storage: `AuthorMapping::MappingWithDeposit` (r:1 w:1) + /// Proof: `AuthorMapping::MappingWithDeposit` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `AuthorMapping::NimbusLookup` (r:0 w:1) + /// Proof: `AuthorMapping::NimbusLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) fn clear_association() -> Weight { // Proof Size summary in bytes: - // Measured: `616` - // Estimated: `6314` - // Minimum execution time: 51_150 nanoseconds. - Weight::from_parts(52_690_000, 6314) + // Measured: `519` + // Estimated: `3984` + // Minimum execution time: 62_841 nanoseconds. + Weight::from_parts(63_960_000, 3984) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: AuthorMapping NimbusLookup (r:1 w:1) - /// Proof Skipped: AuthorMapping NimbusLookup (max_values: None, max_size: None, mode: Measured) - /// Storage: AuthorMapping MappingWithDeposit (r:1 w:1) - /// Proof Skipped: AuthorMapping MappingWithDeposit (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `AuthorMapping::NimbusLookup` (r:1 w:1) + /// Proof: `AuthorMapping::NimbusLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AuthorMapping::MappingWithDeposit` (r:1 w:1) + /// Proof: `AuthorMapping::MappingWithDeposit` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn remove_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `722` - // Estimated: `9001` - // Minimum execution time: 48_110 nanoseconds. - Weight::from_parts(58_780_000, 9001) + // Measured: `625` + // Estimated: `4090` + // Minimum execution time: 74_860 nanoseconds. + Weight::from_parts(86_720_000, 4090) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: AuthorMapping NimbusLookup (r:1 w:1) - /// Proof Skipped: AuthorMapping NimbusLookup (max_values: None, max_size: None, mode: Measured) - /// Storage: AuthorMapping MappingWithDeposit (r:2 w:2) - /// Proof Skipped: AuthorMapping MappingWithDeposit (max_values: None, max_size: None, mode: Measured) + /// Storage: `AuthorMapping::NimbusLookup` (r:1 w:1) + /// Proof: `AuthorMapping::NimbusLookup` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AuthorMapping::MappingWithDeposit` (r:1 w:1) + /// Proof: `AuthorMapping::MappingWithDeposit` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn set_keys() -> Weight { // Proof Size summary in bytes: - // Measured: `546` - // Estimated: `8517` - // Minimum execution time: 36_950 nanoseconds. - Weight::from_parts(40_320_000, 8517) + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 65_740 nanoseconds. + Weight::from_parts(67_220_000, 3963) .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 5ebfc2b03..fd82b90e0 100644 --- a/runtime/common/src/weights/pallet_author_slot_filter.rs +++ b/runtime/common/src/weights/pallet_author_slot_filter.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_author_slot_filter //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,13 +52,13 @@ use frame_support::{ /// Weight functions for pallet_author_slot_filter (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_author_slot_filter::weights::WeightInfo for WeightInfo { - /// Storage: AuthorFilter EligibleCount (r:0 w:1) - /// Proof Skipped: AuthorFilter EligibleCount (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AuthorFilter::EligibleCount` (r:0 w:1) + /// Proof: `AuthorFilter::EligibleCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_eligible() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_500 nanoseconds. - Weight::from_parts(14_590_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 14_051 nanoseconds. + Weight::from_parts(17_150_000, 0).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 012c55b91..bc1998a79 100644 --- a/runtime/common/src/weights/pallet_balances.rs +++ b/runtime/common/src/weights/pallet_balances.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,96 +52,96 @@ 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) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_allow_death() -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `3593` - // Minimum execution time: 58_474_000 picoseconds. - Weight::from_parts(59_117_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `144` + // Estimated: `6204` + // Minimum execution time: 124_529 nanoseconds. + Weight::from_parts(152_609_000, 6204) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3593` - // Minimum execution time: 44_629_000 picoseconds. - Weight::from_parts(45_798_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Estimated: `3597` + // Minimum execution time: 78_350 nanoseconds. + Weight::from_parts(79_859_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn force_set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `174` - // Estimated: `3593` - // Minimum execution time: 16_483_000 picoseconds. - Weight::from_parts(16_939_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `178` + // Estimated: `3597` + // Minimum execution time: 32_330 nanoseconds. + Weight::from_parts(34_300_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn force_set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `174` - // Estimated: `3593` - // Minimum execution time: 24_638_000 picoseconds. - Weight::from_parts(25_487_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `178` + // Estimated: `3597` + // Minimum execution time: 54_749 nanoseconds. + Weight::from_parts(55_980_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `6196` - // Minimum execution time: 60_041_000 picoseconds. - Weight::from_parts(63_365_000, 6196) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `251` + // Estimated: `8811` + // Minimum execution time: 157_759 nanoseconds. + Weight::from_parts(159_229_000, 8811) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn transfer_all() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3593` - // Minimum execution time: 54_445_000 picoseconds. - Weight::from_parts(55_623_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Estimated: `3597` + // Minimum execution time: 95_500 nanoseconds. + Weight::from_parts(117_190_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `174` - // Estimated: `3593` - // Minimum execution time: 19_309_000 picoseconds. - Weight::from_parts(19_953_000, 3593) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `178` + // Estimated: `3597` + // Minimum execution time: 38_889 nanoseconds. + Weight::from_parts(39_590_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `System::Account` (r:999 w:999) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `u` is `[1, 1000]`. fn upgrade_accounts(u: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + u * (135 ±0)` - // Estimated: `990 + u * (2603 ±0)` - // Minimum execution time: 19_362_000 picoseconds. - Weight::from_parts(19_612_000, 990) - // Standard Error: 13_108 - .saturating_add(Weight::from_parts(16_444_591, 0).saturating_mul(u.into())) + // Measured: `0 + u * (139 ±0)` + // Estimated: `990 + u * (2607 ±0)` + // Minimum execution time: 37_620 nanoseconds. + Weight::from_parts(38_079_000, 990) + // Standard Error: 43_476 + .saturating_add(Weight::from_parts(30_483_379, 0).saturating_mul(u.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) - .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + .saturating_add(Weight::from_parts(0, 2607).saturating_mul(u.into())) } } diff --git a/runtime/common/src/weights/pallet_bounties.rs b/runtime/common/src/weights/pallet_bounties.rs index 6e35f994f..2bed73d9b 100644 --- a/runtime/common/src/weights/pallet_bounties.rs +++ b/runtime/common/src/weights/pallet_bounties.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,162 +52,162 @@ use frame_support::{ /// Weight functions for pallet_bounties (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_bounties::weights::WeightInfo for WeightInfo { - /// Storage: Bounties BountyCount (r:1 w:1) - /// Proof: Bounties BountyCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Bounties BountyDescriptions (r:0 w:1) - /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(8206), added: 10681, mode: MaxEncodedLen) - /// Storage: Bounties Bounties (r:0 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) + /// Storage: `Bounties::BountyCount` (r:1 w:1) + /// Proof: `Bounties::BountyCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyDescriptions` (r:0 w:1) + /// Proof: `Bounties::BountyDescriptions` (`max_values`: None, `max_size`: Some(8206), added: 10681, mode: `MaxEncodedLen`) + /// Storage: `Bounties::Bounties` (r:0 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) /// The range of component `d` is `[0, 8192]`. fn propose_bounty(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `141` - // Estimated: `3106` - // Minimum execution time: 38_100 nanoseconds. - Weight::from_parts(46_943_073, 3106) - // Standard Error: 18 - .saturating_add(Weight::from_parts(1_743, 0).saturating_mul(d.into())) + // Measured: `109` + // Estimated: `3597` + // Minimum execution time: 48_599 nanoseconds. + Weight::from_parts(59_501_858, 3597) + // Standard Error: 84 + .saturating_add(Weight::from_parts(1_905, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: Bounties BountyApprovals (r:1 w:1) - /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyApprovals` (r:1 w:1) + /// Proof: `Bounties::BountyApprovals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) fn approve_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `229` - // Estimated: `3553` - // Minimum execution time: 21_700 nanoseconds. - Weight::from_parts(22_100_000, 3553) + // Measured: `197` + // Estimated: `3646` + // Minimum execution time: 22_950 nanoseconds. + Weight::from_parts(23_720_000, 3646) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) fn propose_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `249` - // Estimated: `2656` - // Minimum execution time: 19_270 nanoseconds. - Weight::from_parts(20_370_000, 2656) + // Measured: `217` + // Estimated: `3646` + // Minimum execution time: 19_669 nanoseconds. + Weight::from_parts(20_580_000, 3646) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn unassign_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `641` - // Estimated: `7870` - // Minimum execution time: 67_520 nanoseconds. - Weight::from_parts(69_530_000, 7870) + // Measured: `545` + // Estimated: `6204` + // Minimum execution time: 82_570 nanoseconds. + Weight::from_parts(96_369_000, 6204) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn accept_curator() -> Weight { // Proof Size summary in bytes: - // Measured: `457` - // Estimated: `5263` - // Minimum execution time: 37_670 nanoseconds. - Weight::from_parts(43_020_000, 5263) + // Measured: `393` + // Estimated: `3646` + // Minimum execution time: 50_850 nanoseconds. + Weight::from_parts(52_270_000, 3646) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) fn award_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `289` - // Estimated: `2656` - // Minimum execution time: 27_430 nanoseconds. - Weight::from_parts(30_770_000, 2656) + // Measured: `257` + // Estimated: `3646` + // Minimum execution time: 30_299 nanoseconds. + Weight::from_parts(31_340_000, 3646) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Bounties BountyDescriptions (r:0 w:1) - /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(8206), added: 10681, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyDescriptions` (r:0 w:1) + /// Proof: `Bounties::BountyDescriptions` (`max_values`: None, `max_size`: Some(8206), added: 10681, mode: `MaxEncodedLen`) fn claim_bounty() -> Weight { // Proof Size summary in bytes: - // Measured: `674` - // Estimated: `10477` - // Minimum execution time: 117_100 nanoseconds. - Weight::from_parts(121_650_000, 10477) + // Measured: `578` + // Estimated: `8811` + // Minimum execution time: 203_930 nanoseconds. + Weight::from_parts(209_029_000, 8811) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Bounties BountyDescriptions (r:0 w:1) - /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(8206), added: 10681, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyDescriptions` (r:0 w:1) + /// Proof: `Bounties::BountyDescriptions` (`max_values`: None, `max_size`: Some(8206), added: 10681, mode: `MaxEncodedLen`) fn close_bounty_proposed() -> Weight { // Proof Size summary in bytes: - // Measured: `541` - // Estimated: `7870` - // Minimum execution time: 64_760 nanoseconds. - Weight::from_parts(71_110_000, 7870) + // Measured: `445` + // Estimated: `6204` + // Minimum execution time: 85_390 nanoseconds. + Weight::from_parts(86_110_000, 6204) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Bounties BountyDescriptions (r:0 w:1) - /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(8206), added: 10681, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyDescriptions` (r:0 w:1) + /// Proof: `Bounties::BountyDescriptions` (`max_values`: None, `max_size`: Some(8206), added: 10681, mode: `MaxEncodedLen`) fn close_bounty_active() -> Weight { // Proof Size summary in bytes: - // Measured: `818` - // Estimated: `10477` - // Minimum execution time: 90_500 nanoseconds. - Weight::from_parts(92_640_000, 10477) + // Measured: `690` + // Estimated: `8811` + // Minimum execution time: 142_360 nanoseconds. + Weight::from_parts(169_050_000, 8811) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: Bounties Bounties (r:1 w:1) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) + /// Storage: `Bounties::Bounties` (r:1 w:1) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) fn extend_bounty_expiry() -> Weight { // Proof Size summary in bytes: - // Measured: `289` - // Estimated: `2656` - // Minimum execution time: 28_930 nanoseconds. - Weight::from_parts(30_041_000, 2656) + // Measured: `257` + // Estimated: `3646` + // Minimum execution time: 34_890 nanoseconds. + Weight::from_parts(37_200_000, 3646) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Bounties BountyApprovals (r:1 w:1) - /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) - /// Storage: Bounties Bounties (r:100 w:100) - /// Proof: Bounties Bounties (max_values: None, max_size: Some(181), added: 2656, mode: MaxEncodedLen) - /// Storage: System Account (r:200 w:200) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Bounties::BountyApprovals` (r:1 w:1) + /// Proof: `Bounties::BountyApprovals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `Bounties::Bounties` (r:100 w:100) + /// Proof: `Bounties::Bounties` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:200 w:200) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `98 + b * (357 ±0)` - // Estimated: `897 + b * (7870 ±0)` - // Minimum execution time: 8_040 nanoseconds. - Weight::from_parts(35_582_901, 897) - // Standard Error: 168_907 - .saturating_add(Weight::from_parts(54_930_083, 0).saturating_mul(b.into())) + // Measured: `70 + b * (294 ±0)` + // Estimated: `1887 + b * (5214 ±0)` + // Minimum execution time: 9_110 nanoseconds. + Weight::from_parts(9_920_000, 1887) + // Standard Error: 93_100 + .saturating_add(Weight::from_parts(80_045_614, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into()))) - .saturating_add(Weight::from_parts(0, 7870).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 5214).saturating_mul(b.into())) } } diff --git a/runtime/common/src/weights/pallet_collective.rs b/runtime/common/src/weights/pallet_collective.rs index 61b65f8e0..739622c92 100644 --- a/runtime/common/src/weights/pallet_collective.rs +++ b/runtime/common/src/weights/pallet_collective.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,244 +52,246 @@ use frame_support::{ /// Weight functions for pallet_collective (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_collective::weights::WeightInfo for WeightInfo { - /// Storage: AdvisoryCommittee Members (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Voting (r:255 w:255) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Voting` (r:255 w:255) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[0, 100]`. /// The range of component `n` is `[0, 100]`. /// The range of component `p` is `[0, 255]`. fn set_members(m: u32, _n: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + m * (8195 ±0) + p * (3227 ±0)` - // Estimated: `33167 + m * (19751 ±60) + p * (10255 ±23)` - // Minimum execution time: 32_240 nanoseconds. - Weight::from_parts(36_010_000, 33167) - // Standard Error: 331_381 - .saturating_add(Weight::from_parts(24_168_756, 0).saturating_mul(m.into())) - // Standard Error: 130_107 - .saturating_add(Weight::from_parts(16_390_802, 0).saturating_mul(p.into())) + // Measured: `0 + m * (8192 ±0) + p * (3194 ±0)` + // Estimated: `32746 + m * (4970 ±60) + p * (4343 ±23)` + // Minimum execution time: 37_640 nanoseconds. + Weight::from_parts(37_820_000, 32746) + // Standard Error: 342_845 + .saturating_add(Weight::from_parts(25_501_936, 0).saturating_mul(m.into())) + // Standard Error: 134_608 + .saturating_add(Weight::from_parts(18_454_663, 0).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()))) - .saturating_add(Weight::from_parts(0, 19751).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 10255).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 4970).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 4343).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `100 + m * (32 ±0)` - // Estimated: `596 + m * (32 ±0)` - // Minimum execution time: 29_290 nanoseconds. - Weight::from_parts(33_241_053, 596) - // Standard Error: 107 - .saturating_add(Weight::from_parts(2_623, 0).saturating_mul(b.into())) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(31_802, 0).saturating_mul(m.into())) + // Measured: `68 + m * (32 ±0)` + // Estimated: `1554 + m * (32 ±0)` + // Minimum execution time: 29_810 nanoseconds. + Weight::from_parts(38_342_071, 1554) + // Standard Error: 355 + .saturating_add(Weight::from_parts(2_144, 0).saturating_mul(b.into())) + // Standard Error: 3_667 + .saturating_add(Weight::from_parts(21_795, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:1 w:0) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `100 + m * (32 ±0)` - // Estimated: `3172 + m * (64 ±0)` - // Minimum execution time: 32_470 nanoseconds. - Weight::from_parts(36_593_323, 3172) - // Standard Error: 263 - .saturating_add(Weight::from_parts(3_751, 0).saturating_mul(b.into())) - // Standard Error: 2_716 - .saturating_add(Weight::from_parts(50_600, 0).saturating_mul(m.into())) + // Measured: `68 + m * (32 ±0)` + // Estimated: `3534 + m * (32 ±0)` + // Minimum execution time: 34_190 nanoseconds. + Weight::from_parts(41_468_423, 3534) + // Standard Error: 380 + .saturating_add(Weight::from_parts(2_531, 0).saturating_mul(b.into())) + // Standard Error: 3_920 + .saturating_add(Weight::from_parts(67_320, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalCount (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalCount (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Voting (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:1 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalCount` (r:1 w:1) + /// Proof: `AdvisoryCommittee::ProposalCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Voting` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 255]`. fn propose_proposed(b: u32, m: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `565 + m * (32 ±0) + p * (33 ±0)` - // Estimated: `6570 + m * (160 ±0) + p * (170 ±0)` - // Minimum execution time: 51_800 nanoseconds. - Weight::from_parts(49_667_053, 6570) - // Standard Error: 666 - .saturating_add(Weight::from_parts(11_053, 0).saturating_mul(b.into())) - // Standard Error: 6_959 - .saturating_add(Weight::from_parts(83_279, 0).saturating_mul(m.into())) - // Standard Error: 2_679 - .saturating_add(Weight::from_parts(254_614, 0).saturating_mul(p.into())) + // Measured: `501 + m * (32 ±0) + p * (33 ±0)` + // Estimated: `3926 + m * (32 ±0) + p * (34 ±0)` + // Minimum execution time: 48_060 nanoseconds. + Weight::from_parts(72_847_338, 3926) + // Standard Error: 1_256 + .saturating_add(Weight::from_parts(326, 0).saturating_mul(b.into())) + // Standard Error: 13_109 + .saturating_add(Weight::from_parts(36_498, 0).saturating_mul(m.into())) + // Standard Error: 5_046 + .saturating_add(Weight::from_parts(378_035, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 160).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 170).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 34).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Voting (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Voting` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `m` is `[5, 100]`. fn vote(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1240 + m * (64 ±0)` - // Estimated: `5448 + m * (128 ±0)` - // Minimum execution time: 51_250 nanoseconds. - Weight::from_parts(71_287_144, 5448) - // Standard Error: 5_011 - .saturating_add(Weight::from_parts(73_018, 0).saturating_mul(m.into())) + // Measured: `1175 + m * (64 ±0)` + // Estimated: `4639 + m * (64 ±0)` + // Minimum execution time: 53_080 nanoseconds. + Weight::from_parts(73_109_709, 4639) + // Standard Error: 5_086 + .saturating_add(Weight::from_parts(105_322, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(Weight::from_parts(0, 128).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommittee Voting (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Voting` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:0 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 255]`. fn close_early_disapproved(m: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `683 + m * (64 ±0) + p * (33 ±0)` - // Estimated: `6017 + m * (260 ±0) + p * (136 ±0)` - // Minimum execution time: 48_690 nanoseconds. - Weight::from_parts(55_109_178, 6017) - // Standard Error: 6_245 - .saturating_add(Weight::from_parts(107_851, 0).saturating_mul(m.into())) - // Standard Error: 2_373 - .saturating_add(Weight::from_parts(229_124, 0).saturating_mul(p.into())) + // Measured: `586 + m * (64 ±0) + p * (33 ±0)` + // Estimated: `4006 + m * (65 ±0) + p * (34 ±0)` + // Minimum execution time: 62_949 nanoseconds. + Weight::from_parts(74_028_560, 4006) + // Standard Error: 10_128 + .saturating_add(Weight::from_parts(65_347, 0).saturating_mul(m.into())) + // Standard Error: 3_849 + .saturating_add(Weight::from_parts(290_905, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 260).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 136).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 34).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Voting (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Voting` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:1 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 255]`. fn close_early_approved(b: u32, m: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `926 + b * (1 ±0) + m * (64 ±0) + p * (36 ±0)` - // Estimated: `9916 + b * (4 ±0) + m * (248 ±0) + p * (144 ±0)` - // Minimum execution time: 57_050 nanoseconds. - Weight::from_parts(75_520_068, 9916) - // Standard Error: 794 - .saturating_add(Weight::from_parts(7_735, 0).saturating_mul(b.into())) - // Standard Error: 8_398 - .saturating_add(Weight::from_parts(53_897, 0).saturating_mul(m.into())) - // Standard Error: 3_191 - .saturating_add(Weight::from_parts(306_904, 0).saturating_mul(p.into())) + // Measured: `798 + b * (1 ±0) + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4337 + b * (1 ±0) + m * (62 ±0) + p * (36 ±0)` + // Minimum execution time: 65_450 nanoseconds. + Weight::from_parts(94_281_108, 4337) + // Standard Error: 748 + .saturating_add(Weight::from_parts(10_158, 0).saturating_mul(b.into())) + // Standard Error: 7_910 + .saturating_add(Weight::from_parts(36_894, 0).saturating_mul(m.into())) + // Standard Error: 3_006 + .saturating_add(Weight::from_parts(344_530, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 4).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 248).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 62).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Voting (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Voting` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:0 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 255]`. fn close_disapproved(m: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `703 + m * (64 ±0) + p * (33 ±0)` - // Estimated: `7250 + m * (325 ±0) + p * (170 ±0)` - // Minimum execution time: 46_220 nanoseconds. - Weight::from_parts(62_405_239, 7250) - // Standard Error: 7_440 - .saturating_add(Weight::from_parts(108_767, 0).saturating_mul(m.into())) - // Standard Error: 2_827 - .saturating_add(Weight::from_parts(218_334, 0).saturating_mul(p.into())) + // Measured: `606 + m * (64 ±0) + p * (33 ±0)` + // Estimated: `4026 + m * (65 ±0) + p * (34 ±0)` + // Minimum execution time: 64_390 nanoseconds. + Weight::from_parts(70_683_234, 4026) + // Standard Error: 10_591 + .saturating_add(Weight::from_parts(135_054, 0).saturating_mul(m.into())) + // Standard Error: 4_025 + .saturating_add(Weight::from_parts(307_190, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 325).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 170).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 34).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Voting (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Members (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Voting` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Members` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:1 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 255]`. fn close_approved(b: u32, m: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `946 + b * (1 ±0) + m * (64 ±0) + p * (36 ±0)` - // Estimated: `11505 + b * (5 ±0) + m * (310 ±0) + p * (180 ±0)` - // Minimum execution time: 60_490 nanoseconds. - Weight::from_parts(87_540_688, 11505) - // Standard Error: 865 - .saturating_add(Weight::from_parts(3_430, 0).saturating_mul(b.into())) - // Standard Error: 3_474 - .saturating_add(Weight::from_parts(317_677, 0).saturating_mul(p.into())) + // Measured: `818 + b * (1 ±0) + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4357 + b * (1 ±0) + m * (62 ±0) + p * (36 ±0)` + // Minimum execution time: 85_380 nanoseconds. + Weight::from_parts(91_547_722, 4357) + // Standard Error: 1_298 + .saturating_add(Weight::from_parts(15_683, 0).saturating_mul(b.into())) + // Standard Error: 13_725 + .saturating_add(Weight::from_parts(46_296, 0).saturating_mul(m.into())) + // Standard Error: 5_216 + .saturating_add(Weight::from_parts(377_484, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 5).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 310).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 62).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } - /// Storage: AdvisoryCommittee Proposals (r:1 w:1) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Voting (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee ProposalOf (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:1) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Voting` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::ProposalOf` (r:0 w:1) + /// Proof: `AdvisoryCommittee::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `p` is `[1, 255]`. fn disapprove_proposal(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `258 + p * (32 ±0)` - // Estimated: `1266 + p * (96 ±0)` - // Minimum execution time: 23_361 nanoseconds. - Weight::from_parts(35_532_415, 1266) - // Standard Error: 3_908 - .saturating_add(Weight::from_parts(240_150, 0).saturating_mul(p.into())) + // Measured: `226 + p * (32 ±0)` + // Estimated: `1710 + p * (32 ±0)` + // Minimum execution time: 33_040 nanoseconds. + Weight::from_parts(43_701_252, 1710) + // Standard Error: 2_402 + .saturating_add(Weight::from_parts(300_555, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 96).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) } } diff --git a/runtime/common/src/weights/pallet_contracts.rs b/runtime/common/src/weights/pallet_contracts.rs index 2671199f1..46497daef 100644 --- a/runtime/common/src/weights/pallet_contracts.rs +++ b/runtime/common/src/weights/pallet_contracts.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -56,25 +56,25 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: - // Measured: `142` - // Estimated: `1627` - // Minimum execution time: 2_548_000 picoseconds. - Weight::from_parts(2_670_000, 1627).saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `42` + // Estimated: `1527` + // Minimum execution time: 7_430 nanoseconds. + Weight::from_parts(8_400_000, 1527).saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `451 + k * (69 ±0)` - // Estimated: `441 + k * (70 ±0)` - // Minimum execution time: 13_526_000 picoseconds. - Weight::from_parts(13_902_000, 441) - // Standard Error: 1_058 - .saturating_add(Weight::from_parts(1_274_724, 0).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `351 + k * (69 ±0)` + // Estimated: `341 + k * (70 ±0)` + // Minimum execution time: 23_910 nanoseconds. + Weight::from_parts(24_890_000, 341) + // Standard Error: 3_859 + .saturating_add(Weight::from_parts(2_015_712, 0).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } @@ -83,28 +83,28 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `c` is `[0, 125952]`. fn v9_migration_step(c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `211 + c * (1 ±0)` - // Estimated: `6149 + c * (1 ±0)` - // Minimum execution time: 8_426_000 picoseconds. - Weight::from_parts(8_591_621, 6149) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_203, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `111 + c * (1 ±0)` + // Estimated: `6049 + c * (1 ±0)` + // Minimum execution time: 20_290 nanoseconds. + Weight::from_parts(18_282_031, 6049) + // Standard Error: 10 + .saturating_add(Weight::from_parts(1_721, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) fn v10_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `510` - // Estimated: `6450` - // Minimum execution time: 17_008_000 picoseconds. - Weight::from_parts(17_742_000, 6450) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `415` + // Estimated: `6355` + // Minimum execution time: 33_490 nanoseconds. + Weight::from_parts(40_920_000, 6355) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Contracts::DeletionQueue` (r:1 w:1025) /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) @@ -113,14 +113,14 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `k` is `[0, 1024]`. fn v11_migration_step(k: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `171 + k * (1 ±0)` - // Estimated: `3635 + k * (1 ±0)` - // Minimum execution time: 3_949_000 picoseconds. - Weight::from_parts(4_062_000, 3635) - // Standard Error: 1_983 - .saturating_add(Weight::from_parts(1_173_197, 0).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `71 + k * (1 ±0)` + // Estimated: `3535 + k * (1 ±0)` + // Minimum execution time: 12_320 nanoseconds. + Weight::from_parts(12_830_000, 3535) + // Standard Error: 8_340 + .saturating_add(Weight::from_parts(2_265_906, 0).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 1).saturating_mul(k.into())) } @@ -129,71 +129,71 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:0 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn v12_migration_step(c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `325 + c * (1 ±0)` - // Estimated: `6263 + c * (1 ±0)` - // Minimum execution time: 17_094_000 picoseconds. - Weight::from_parts(17_338_591, 6263) - // Standard Error: 1 - .saturating_add(Weight::from_parts(436, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `225 + c * (1 ±0)` + // Estimated: `6163 + c * (1 ±0)` + // Minimum execution time: 33_350 nanoseconds. + Weight::from_parts(33_089_795, 6163) + // Standard Error: 12 + .saturating_add(Weight::from_parts(840, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) fn v13_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `440` - // Estimated: `6380` - // Minimum execution time: 12_704_000 picoseconds. - Weight::from_parts(13_147_000, 6380) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `340` + // Estimated: `6280` + // Minimum execution time: 25_500 nanoseconds. + Weight::from_parts(27_730_000, 6280) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:0) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) fn v14_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `360` - // Estimated: `6300` - // Minimum execution time: 48_387_000 picoseconds. - Weight::from_parts(50_024_000, 6300) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `212` + // Estimated: `6152` + // Minimum execution time: 90_871 nanoseconds. + Weight::from_parts(101_780_000, 6152) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `System::Account` (r:2 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) fn v15_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `594` - // Estimated: `6534` - // Minimum execution time: 59_300_000 picoseconds. - Weight::from_parts(61_805_000, 6534) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `499` + // Estimated: `6439` + // Minimum execution time: 154_710 nanoseconds. + Weight::from_parts(167_871_000, 6439) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn migration_noop() -> Weight { // Proof Size summary in bytes: - // Measured: `142` - // Estimated: `1627` - // Minimum execution time: 3_327_000 picoseconds. - Weight::from_parts(3_502_000, 1627) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `42` + // Estimated: `1527` + // Minimum execution time: 9_410 nanoseconds. + Weight::from_parts(10_060_000, 1527) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -201,21 +201,21 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) fn migrate() -> Weight { // Proof Size summary in bytes: - // Measured: `166` - // Estimated: `3631` - // Minimum execution time: 12_759_000 picoseconds. - Weight::from_parts(13_134_000, 3631) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `66` + // Estimated: `3531` + // Minimum execution time: 29_130 nanoseconds. + Weight::from_parts(33_410_000, 3531) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) fn on_runtime_upgrade_noop() -> Weight { // Proof Size summary in bytes: - // Measured: `142` - // Estimated: `3607` - // Minimum execution time: 4_775_000 picoseconds. - Weight::from_parts(5_084_000, 3607).saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `42` + // Estimated: `3507` + // Minimum execution time: 15_800 nanoseconds. + Weight::from_parts(17_760_000, 3507).saturating_add(T::DbWeight::get().reads(1)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -223,10 +223,10 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade_in_progress() -> Weight { // Proof Size summary in bytes: - // Measured: `167` - // Estimated: `3632` - // Minimum execution time: 6_663_000 picoseconds. - Weight::from_parts(6_855_000, 3632).saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `67` + // Estimated: `3532` + // Minimum execution time: 16_710 nanoseconds. + Weight::from_parts(17_820_000, 3532).saturating_add(T::DbWeight::get().reads(2)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -234,12 +234,12 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade() -> Weight { // Proof Size summary in bytes: - // Measured: `142` - // Estimated: `3607` - // Minimum execution time: 7_212_000 picoseconds. - Weight::from_parts(7_426_000, 3607) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `42` + // Estimated: `3507` + // Minimum execution time: 21_040 nanoseconds. + Weight::from_parts(21_610_000, 3507) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -252,20 +252,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `System::EventTopics` (r:2 w:2) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `792` - // Estimated: `6743 + c * (1 ±0)` - // Minimum execution time: 289_557_000 picoseconds. - Weight::from_parts(272_895_652, 6743) - // Standard Error: 80 - .saturating_add(Weight::from_parts(39_917, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `630` + // Estimated: `6582 + c * (1 ±0)` + // Minimum execution time: 609_010 nanoseconds. + Weight::from_parts(724_043_472, 6582) + // Standard Error: 134 + .saturating_add(Weight::from_parts(79_403, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) @@ -273,7 +273,7 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Balances::Holds` (r:2 w:2) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// Storage: `System::EventTopics` (r:3 w:3) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::Nonce` (r:1 w:1) @@ -283,7 +283,7 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. @@ -291,18 +291,18 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `323` - // Estimated: `8747` - // Minimum execution time: 4_671_359_000 picoseconds. - Weight::from_parts(586_523_882, 8747) - // Standard Error: 206 - .saturating_add(Weight::from_parts(115_402, 0).saturating_mul(c.into())) - // Standard Error: 24 - .saturating_add(Weight::from_parts(1_797, 0).saturating_mul(i.into())) - // Standard Error: 24 - .saturating_add(Weight::from_parts(2_046, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) + // Measured: `157` + // Estimated: `8578` + // Minimum execution time: 6_661_655 nanoseconds. + Weight::from_parts(1_301_904_860, 8578) + // Standard Error: 259 + .saturating_add(Weight::from_parts(235_011, 0).saturating_mul(c.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(2_771, 0).saturating_mul(i.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(2_677, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(10)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -317,25 +317,25 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `System::EventTopics` (r:2 w:2) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `560` - // Estimated: `6504` - // Minimum execution time: 2_170_657_000 picoseconds. - Weight::from_parts(369_331_405, 6504) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_940, 0).saturating_mul(i.into())) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_858, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Measured: `394` + // Estimated: `6339` + // Minimum execution time: 2_985_696 nanoseconds. + Weight::from_parts(778_974_170, 6339) + // Standard Error: 22 + .saturating_add(Weight::from_parts(2_385, 0).saturating_mul(i.into())) + // Standard Error: 22 + .saturating_add(Weight::from_parts(2_542, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(7)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -348,24 +348,24 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `Timestamp::Now` (r:1 w:0) /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `System::EventTopics` (r:2 w:2) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `826` - // Estimated: `6766` - // Minimum execution time: 204_287_000 picoseconds. - Weight::from_parts(213_239_000, 6766) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `665` + // Estimated: `6605` + // Minimum execution time: 390_731 nanoseconds. + Weight::from_parts(402_031_000, 6605) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(4)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) @@ -373,33 +373,33 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `c` is `[0, 125952]`. fn upload_code(c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `142` - // Estimated: `3607` - // Minimum execution time: 285_434_000 picoseconds. - Weight::from_parts(242_697_648, 3607) - // Standard Error: 128 - .saturating_add(Weight::from_parts(76_087, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `42` + // Estimated: `3507` + // Minimum execution time: 549_251 nanoseconds. + Weight::from_parts(727_042_849, 3507) + // Standard Error: 177 + .saturating_add(Weight::from_parts(155_165, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// Storage: `System::EventTopics` (r:1 w:1) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Contracts::PristineCode` (r:0 w:1) /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `315` - // Estimated: `3780` - // Minimum execution time: 46_486_000 picoseconds. - Weight::from_parts(48_422_000, 3780) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `212` + // Estimated: `3677` + // Minimum execution time: 83_830 nanoseconds. + Weight::from_parts(87_000_000, 3677) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) @@ -411,17 +411,17 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `552` - // Estimated: `8967` - // Minimum execution time: 37_568_000 picoseconds. - Weight::from_parts(38_589_000, 8967) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `452` + // Estimated: `8867` + // Minimum execution time: 53_370 nanoseconds. + Weight::from_parts(62_960_000, 8867) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -435,20 +435,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `866 + r * (6 ±0)` - // Estimated: `6806 + r * (6 ±0)` - // Minimum execution time: 274_513_000 picoseconds. - Weight::from_parts(288_793_403, 6806) - // Standard Error: 650 - .saturating_add(Weight::from_parts(339_309, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `652 + r * (6 ±0)` + // Estimated: `6592 + r * (6 ±0)` + // Minimum execution time: 516_961 nanoseconds. + Weight::from_parts(594_952_508, 6592) + // Standard Error: 4_197 + .saturating_add(Weight::from_parts(851_782, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -462,21 +462,21 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `922 + r * (209 ±0)` - // Estimated: `6826 + r * (2684 ±0)` - // Minimum execution time: 260_096_000 picoseconds. - Weight::from_parts(149_954_322, 6826) - // Standard Error: 5_713 - .saturating_add(Weight::from_parts(3_788_924, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `706 + r * (209 ±0)` + // Estimated: `6608 + r * (2684 ±0)` + // Minimum execution time: 531_401 nanoseconds. + Weight::from_parts(238_319_702, 6608) + // Standard Error: 30_236 + .saturating_add(Weight::from_parts(7_933_474, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -490,21 +490,21 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `921 + r * (213 ±0)` - // Estimated: `6830 + r * (2688 ±0)` - // Minimum execution time: 277_496_000 picoseconds. - Weight::from_parts(285_839_000, 6830) - // Standard Error: 10_076 - .saturating_add(Weight::from_parts(4_720_110, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `717 + r * (213 ±0)` + // Estimated: `6619 + r * (2688 ±0)` + // Minimum execution time: 551_671 nanoseconds. + Weight::from_parts(259_560_441, 6619) + // Standard Error: 30_149 + .saturating_add(Weight::from_parts(9_625_003, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 2688).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -518,20 +518,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `873 + r * (6 ±0)` - // Estimated: `6815 + r * (6 ±0)` - // Minimum execution time: 275_655_000 picoseconds. - Weight::from_parts(291_386_528, 6815) - // Standard Error: 898 - .saturating_add(Weight::from_parts(428_765, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `659 + r * (6 ±0)` + // Estimated: `6599 + r * (6 ±0)` + // Minimum execution time: 531_291 nanoseconds. + Weight::from_parts(588_260_613, 6599) + // Standard Error: 5_663 + .saturating_add(Weight::from_parts(1_037_843, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -545,14 +545,14 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (3 ±0)` - // Estimated: `6804 + r * (3 ±0)` - // Minimum execution time: 260_323_000 picoseconds. - Weight::from_parts(286_371_403, 6804) - // Standard Error: 451 - .saturating_add(Weight::from_parts(183_053, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `649 + r * (3 ±0)` + // Estimated: `6589 + r * (3 ±0)` + // Minimum execution time: 453_161 nanoseconds. + Weight::from_parts(598_392_249, 6589) + // Standard Error: 4_973 + .saturating_add(Weight::from_parts(429_684, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) @@ -570,20 +570,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_root(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `753 + r * (3 ±0)` - // Estimated: `6693 + r * (3 ±0)` - // Minimum execution time: 262_974_000 picoseconds. - Weight::from_parts(276_571_502, 6693) - // Standard Error: 527 - .saturating_add(Weight::from_parts(165_364, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `587 + r * (3 ±0)` + // Estimated: `6527 + r * (3 ±0)` + // Minimum execution time: 452_501 nanoseconds. + Weight::from_parts(568_566_069, 6527) + // Standard Error: 4_128 + .saturating_add(Weight::from_parts(397_700, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -597,20 +597,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `867 + r * (6 ±0)` - // Estimated: `6807 + r * (6 ±0)` - // Minimum execution time: 272_826_000 picoseconds. - Weight::from_parts(290_963_001, 6807) - // Standard Error: 810 - .saturating_add(Weight::from_parts(343_762, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `653 + r * (6 ±0)` + // Estimated: `6593 + r * (6 ±0)` + // Minimum execution time: 537_671 nanoseconds. + Weight::from_parts(606_054_284, 6593) + // Standard Error: 3_762 + .saturating_add(Weight::from_parts(856_259, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -624,20 +624,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (6 ±0)` - // Estimated: `6806 + r * (6 ±0)` - // Minimum execution time: 277_324_000 picoseconds. - Weight::from_parts(290_872_814, 6806) - // Standard Error: 766 - .saturating_add(Weight::from_parts(371_542, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `649 + r * (6 ±0)` + // Estimated: `6588 + r * (6 ±0)` + // Minimum execution time: 565_321 nanoseconds. + Weight::from_parts(640_947_181, 6588) + // Standard Error: 7_624 + .saturating_add(Weight::from_parts(907_145, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:2 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -651,20 +651,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1007 + r * (6 ±0)` - // Estimated: `6931 + r * (6 ±0)` - // Minimum execution time: 274_460_000 picoseconds. - Weight::from_parts(285_748_025, 6931) - // Standard Error: 1_570 - .saturating_add(Weight::from_parts(1_656_237, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `797 + r * (6 ±0)` + // Estimated: `6716 + r * (6 ±0)` + // Minimum execution time: 543_181 nanoseconds. + Weight::from_parts(597_314_979, 6716) + // Standard Error: 4_653 + .saturating_add(Weight::from_parts(3_173_375, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -678,20 +678,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (6 ±0)` - // Estimated: `6823 + r * (6 ±0)` - // Minimum execution time: 278_254_000 picoseconds. - Weight::from_parts(283_893_525, 6823) - // Standard Error: 726 - .saturating_add(Weight::from_parts(347_368, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `663 + r * (6 ±0)` + // Estimated: `6603 + r * (6 ±0)` + // Minimum execution time: 533_251 nanoseconds. + Weight::from_parts(644_790_077, 6603) + // Standard Error: 8_131 + .saturating_add(Weight::from_parts(790_937, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -705,20 +705,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `875 + r * (6 ±0)` - // Estimated: `6816 + r * (6 ±0)` - // Minimum execution time: 279_646_000 picoseconds. - Weight::from_parts(292_505_446, 6816) - // Standard Error: 867 - .saturating_add(Weight::from_parts(337_202, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `661 + r * (6 ±0)` + // Estimated: `6601 + r * (6 ±0)` + // Minimum execution time: 549_842 nanoseconds. + Weight::from_parts(631_501_952, 6601) + // Standard Error: 8_046 + .saturating_add(Weight::from_parts(838_569, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -732,20 +732,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `872 + r * (6 ±0)` - // Estimated: `6819 + r * (6 ±0)` - // Minimum execution time: 274_522_000 picoseconds. - Weight::from_parts(295_135_659, 6819) - // Standard Error: 1_052 - .saturating_add(Weight::from_parts(330_788, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `658 + r * (6 ±0)` + // Estimated: `6601 + r * (6 ±0)` + // Minimum execution time: 560_221 nanoseconds. + Weight::from_parts(606_561_904, 6601) + // Standard Error: 6_933 + .saturating_add(Weight::from_parts(847_298, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -759,20 +759,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (6 ±0)` - // Estimated: `6804 + r * (6 ±0)` - // Minimum execution time: 274_228_000 picoseconds. - Weight::from_parts(289_201_593, 6804) - // Standard Error: 752 - .saturating_add(Weight::from_parts(337_860, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `649 + r * (6 ±0)` + // Estimated: `6589 + r * (6 ±0)` + // Minimum execution time: 548_251 nanoseconds. + Weight::from_parts(633_732_523, 6589) + // Standard Error: 5_610 + .saturating_add(Weight::from_parts(792_725, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -788,20 +788,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `937 + r * (14 ±0)` - // Estimated: `6872 + r * (14 ±0)` - // Minimum execution time: 277_142_000 picoseconds. - Weight::from_parts(296_736_114, 6872) - // Standard Error: 1_502 - .saturating_add(Weight::from_parts(1_446_663, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `760 + r * (14 ±0)` + // Estimated: `6690 + r * (14 ±0)` + // Minimum execution time: 532_371 nanoseconds. + Weight::from_parts(581_227_315, 6690) + // Standard Error: 5_730 + .saturating_add(Weight::from_parts(2_414_332, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 14).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -815,20 +815,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `865 + r * (6 ±0)` - // Estimated: `6807 + r * (6 ±0)` - // Minimum execution time: 276_087_000 picoseconds. - Weight::from_parts(287_863_377, 6807) - // Standard Error: 495 - .saturating_add(Weight::from_parts(282_718, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `651 + r * (6 ±0)` + // Estimated: `6591 + r * (6 ±0)` + // Minimum execution time: 536_101 nanoseconds. + Weight::from_parts(623_941_107, 6591) + // Standard Error: 6_907 + .saturating_add(Weight::from_parts(714_895, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -842,19 +842,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `869` - // Estimated: `6809` - // Minimum execution time: 277_128_000 picoseconds. - Weight::from_parts(234_478_674, 6809) - // Standard Error: 23 - .saturating_add(Weight::from_parts(1_052, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `655` + // Estimated: `6595` + // Minimum execution time: 500_232 nanoseconds. + Weight::from_parts(677_055_581, 6595) + // Standard Error: 13 + .saturating_add(Weight::from_parts(973, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -868,18 +868,18 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `853 + r * (45 ±0)` - // Estimated: `6793 + r * (45 ±0)` - // Minimum execution time: 251_983_000 picoseconds. - Weight::from_parts(277_986_885, 6793) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 45).saturating_mul(r.into())) + // Measured: `639 + r * (8 ±0)` + // Estimated: `6579 + r * (8 ±0)` + // Minimum execution time: 429_561 nanoseconds. + Weight::from_parts(596_361_538, 6579) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -893,19 +893,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6810` - // Minimum execution time: 275_108_000 picoseconds. - Weight::from_parts(284_552_708, 6810) - // Standard Error: 0 - .saturating_add(Weight::from_parts(391, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `649` + // Estimated: `6589` + // Minimum execution time: 464_081 nanoseconds. + Weight::from_parts(607_528_707, 6589) + // Standard Error: 13 + .saturating_add(Weight::from_parts(572, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:3 w:3) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) @@ -919,28 +919,28 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// Storage: `Contracts::DeletionQueue` (r:0 w:1) /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2972 + r * (316 ±0)` - // Estimated: `8912 + r * (5266 ±0)` - // Minimum execution time: 281_278_000 picoseconds. - Weight::from_parts(306_800_667, 8912) - // Standard Error: 855_257 - .saturating_add(Weight::from_parts(126_508_132, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `2758 + r * (319 ±0)` + // Estimated: `8698 + r * (5269 ±0)` + // Minimum execution time: 461_342 nanoseconds. + Weight::from_parts(644_397_548, 8698) + // Standard Error: 5_359_824 + .saturating_add(Weight::from_parts(214_364_951, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((10_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 5266).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 5269).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -956,20 +956,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `944 + r * (10 ±0)` - // Estimated: `6885 + r * (10 ±0)` - // Minimum execution time: 260_609_000 picoseconds. - Weight::from_parts(287_385_076, 6885) - // Standard Error: 2_754 - .saturating_add(Weight::from_parts(2_057_388, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `730 + r * (10 ±0)` + // Estimated: `6664 + r * (10 ±0)` + // Minimum execution time: 557_592 nanoseconds. + Weight::from_parts(643_614_143, 6664) + // Standard Error: 7_627 + .saturating_add(Weight::from_parts(3_861_613, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -983,20 +983,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `863 + r * (10 ±0)` - // Estimated: `6805 + r * (10 ±0)` - // Minimum execution time: 254_770_000 picoseconds. - Weight::from_parts(255_105_647, 6805) - // Standard Error: 5_707 - .saturating_add(Weight::from_parts(3_808_788, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `649 + r * (10 ±0)` + // Estimated: `6589 + r * (10 ±0)` + // Minimum execution time: 521_742 nanoseconds. + Weight::from_parts(588_882_521, 6589) + // Standard Error: 28_311 + .saturating_add(Weight::from_parts(6_923_036, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1011,24 +1011,24 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `880 + t * (32 ±0)` - // Estimated: `6825 + t * (2508 ±0)` - // Minimum execution time: 278_200_000 picoseconds. - Weight::from_parts(288_081_493, 6825) - // Standard Error: 97_535 - .saturating_add(Weight::from_parts(3_683_455, 0).saturating_mul(t.into())) - // Standard Error: 27 - .saturating_add(Weight::from_parts(731, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `666 + t * (32 ±0)` + // Estimated: `6607 + t * (2508 ±0)` + // Minimum execution time: 463_732 nanoseconds. + Weight::from_parts(578_639_080, 6607) + // Standard Error: 1_354_623 + .saturating_add(Weight::from_parts(5_024_616, 0).saturating_mul(t.into())) + // Standard Error: 378 + .saturating_add(Weight::from_parts(3_344, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2508).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1042,20 +1042,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `862 + r * (7 ±0)` - // Estimated: `6807 + r * (7 ±0)` - // Minimum execution time: 167_181_000 picoseconds. - Weight::from_parts(178_433_475, 6807) - // Standard Error: 374 - .saturating_add(Weight::from_parts(241_240, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `648 + r * (7 ±0)` + // Estimated: `6588 + r * (7 ±0)` + // Minimum execution time: 304_881 nanoseconds. + Weight::from_parts(342_600_782, 6588) + // Standard Error: 2_764 + .saturating_add(Weight::from_parts(608_660, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 7).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1069,29 +1069,29 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `125813` - // Estimated: `131755` - // Minimum execution time: 434_456_000 picoseconds. - Weight::from_parts(400_940_450, 131755) - // Standard Error: 13 - .saturating_add(Weight::from_parts(1_102, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `125599` + // Estimated: `131539` + // Minimum execution time: 780_312 nanoseconds. + Weight::from_parts(896_977_178, 131539) + // Standard Error: 16 + .saturating_add(Weight::from_parts(1_659, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `924 + r * (292 ±0)` - // Estimated: `925 + r * (293 ±0)` - // Minimum execution time: 277_825_000 picoseconds. - Weight::from_parts(159_688_263, 925) - // Standard Error: 13_610 - .saturating_add(Weight::from_parts(7_145_641, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `702 + r * (292 ±0)` + // Estimated: `706 + r * (293 ±0)` + // Minimum execution time: 586_592 nanoseconds. + Weight::from_parts(253_036_536, 706) + // Standard Error: 71_420 + .saturating_add(Weight::from_parts(14_775_235, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 293).saturating_mul(r.into())) } @@ -1100,28 +1100,26 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1446` - // Estimated: `1429` - // Minimum execution time: 284_745_000 picoseconds. - Weight::from_parts(345_928_316, 1429) - // Standard Error: 70 - .saturating_add(Weight::from_parts(547, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Measured: `1235` + // Estimated: `1219` + // Minimum execution time: 531_741 nanoseconds. + Weight::from_parts(739_159_889, 1219) + // Standard Error: 753 + .saturating_add(Weight::from_parts(3_069, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(8)) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_old_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1252 + n * (1 ±0)` - // Estimated: `1252 + n * (1 ±0)` - // Minimum execution time: 275_328_000 picoseconds. - Weight::from_parts(300_037_010, 1252) - // Standard Error: 32 - .saturating_add(Weight::from_parts(558, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `1038 + n * (1 ±0)` + // Estimated: `1038 + n * (1 ±0)` + // Minimum execution time: 461_381 nanoseconds. + Weight::from_parts(668_619_955, 1038) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1129,15 +1127,15 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `920 + r * (288 ±0)` - // Estimated: `926 + r * (289 ±0)` - // Minimum execution time: 273_742_000 picoseconds. - Weight::from_parts(169_430_806, 926) - // Standard Error: 11_821 - .saturating_add(Weight::from_parts(6_927_074, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `702 + r * (288 ±0)` + // Estimated: `706 + r * (289 ±0)` + // Minimum execution time: 530_462 nanoseconds. + Weight::from_parts(246_522_459, 706) + // Standard Error: 60_816 + .saturating_add(Weight::from_parts(14_261_381, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } @@ -1146,14 +1144,12 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1248 + n * (1 ±0)` - // Estimated: `1248 + n * (1 ±0)` - // Minimum execution time: 275_167_000 picoseconds. - Weight::from_parts(301_883_655, 1248) - // Standard Error: 35 - .saturating_add(Weight::from_parts(4, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `1034 + n * (1 ±0)` + // Estimated: `1034 + n * (1 ±0)` + // Minimum execution time: 497_492 nanoseconds. + Weight::from_parts(718_153_644, 1034) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1161,15 +1157,15 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `920 + r * (296 ±0)` - // Estimated: `922 + r * (297 ±0)` - // Minimum execution time: 274_628_000 picoseconds. - Weight::from_parts(195_255_092, 922) - // Standard Error: 9_109 - .saturating_add(Weight::from_parts(5_707_060, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `698 + r * (296 ±0)` + // Estimated: `707 + r * (297 ±0)` + // Minimum execution time: 573_902 nanoseconds. + Weight::from_parts(567_343_326, 707) + // Standard Error: 38_899 + .saturating_add(Weight::from_parts(11_221_016, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1177,14 +1173,12 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1264 + n * (1 ±0)` - // Estimated: `1264 + n * (1 ±0)` - // Minimum execution time: 274_202_000 picoseconds. - Weight::from_parts(296_440_752, 1264) - // Standard Error: 38 - .saturating_add(Weight::from_parts(1_010, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `1050 + n * (1 ±0)` + // Estimated: `1050 + n * (1 ±0)` + // Minimum execution time: 484_782 nanoseconds. + Weight::from_parts(686_750_011, 1050) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1192,15 +1186,15 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `931 + r * (288 ±0)` - // Estimated: `928 + r * (289 ±0)` - // Minimum execution time: 274_123_000 picoseconds. - Weight::from_parts(193_280_535, 928) - // Standard Error: 9_264 - .saturating_add(Weight::from_parts(5_548_039, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `705 + r * (288 ±0)` + // Estimated: `709 + r * (289 ±0)` + // Minimum execution time: 505_512 nanoseconds. + Weight::from_parts(509_064_085, 709) + // Standard Error: 34_162 + .saturating_add(Weight::from_parts(10_705_915, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1208,14 +1202,12 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1251 + n * (1 ±0)` - // Estimated: `1251 + n * (1 ±0)` - // Minimum execution time: 276_425_000 picoseconds. - Weight::from_parts(300_521_806, 1251) - // Standard Error: 36 - .saturating_add(Weight::from_parts(83, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `1037 + n * (1 ±0)` + // Estimated: `1037 + n * (1 ±0)` + // Minimum execution time: 459_192 nanoseconds. + Weight::from_parts(669_131_393, 1037) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1223,15 +1215,15 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `913 + r * (296 ±0)` - // Estimated: `918 + r * (297 ±0)` - // Minimum execution time: 264_860_000 picoseconds. - Weight::from_parts(191_561_777, 918) - // Standard Error: 10_678 - .saturating_add(Weight::from_parts(6_895_457, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `699 + r * (296 ±0)` + // Estimated: `706 + r * (297 ±0)` + // Minimum execution time: 509_522 nanoseconds. + Weight::from_parts(352_464_662, 706) + // Standard Error: 55_958 + .saturating_add(Weight::from_parts(14_145_333, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } @@ -1240,20 +1232,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1265 + n * (1 ±0)` - // Estimated: `1265 + n * (1 ±0)` - // Minimum execution time: 282_501_000 picoseconds. - Weight::from_parts(303_351_919, 1265) - // Standard Error: 37 - .saturating_add(Weight::from_parts(643, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `1051 + n * (1 ±0)` + // Estimated: `1051 + n * (1 ±0)` + // Minimum execution time: 484_042 nanoseconds. + Weight::from_parts(682_363_864, 1051) + // Standard Error: 597 + .saturating_add(Weight::from_parts(1_036, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1602 w:1601) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1267,22 +1259,22 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1415 + r * (45 ±0)` - // Estimated: `7307 + r * (2520 ±0)` - // Minimum execution time: 273_198_000 picoseconds. - Weight::from_parts(179_673_238, 7307) - // Standard Error: 34_990 - .saturating_add(Weight::from_parts(38_468_091, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) + // Measured: `1233 + r * (45 ±0)` + // Estimated: `7124 + r * (2520 ±0)` + // Minimum execution time: 561_581 nanoseconds. + Weight::from_parts(441_046_359, 7124) + // Standard Error: 99_108 + .saturating_add(Weight::from_parts(71_874_739, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) @@ -1296,22 +1288,22 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1260 + r * (245 ±0)` - // Estimated: `9440 + r * (2721 ±0)` - // Minimum execution time: 283_869_000 picoseconds. - Weight::from_parts(288_374_000, 9440) - // Standard Error: 137_512 - .saturating_add(Weight::from_parts(248_206_665, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) + // Measured: `684 + r * (245 ±0)` + // Estimated: `8943 + r * (2721 ±0)` + // Minimum execution time: 485_332 nanoseconds. + Weight::from_parts(535_912_000, 8943) + // Standard Error: 786_881 + .saturating_add(Weight::from_parts(537_702_187, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2721).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:736 w:0) @@ -1326,21 +1318,21 @@ impl pallet_contracts::weights::WeightInfo for WeightIn fn seal_delegate_call(r: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (576 ±0)` - // Estimated: `6812 + r * (2637 ±3)` - // Minimum execution time: 257_577_000 picoseconds. - Weight::from_parts(277_310_000, 6812) - // Standard Error: 150_204 - .saturating_add(Weight::from_parts(249_943_483, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Estimated: `6598 + r * (2637 ±3)` + // Minimum execution time: 536_731 nanoseconds. + Weight::from_parts(550_162_000, 6598) + // Standard Error: 688_612 + .saturating_add(Weight::from_parts(537_876_786, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2637).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:3 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) @@ -1355,24 +1347,24 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1307 + t * (277 ±0)` - // Estimated: `12197 + t * (5227 ±0)` - // Minimum execution time: 471_081_000 picoseconds. - Weight::from_parts(79_081_122, 12197) - // Standard Error: 11_777_790 - .saturating_add(Weight::from_parts(357_425_411, 0).saturating_mul(t.into())) + // Measured: `1093 + t * (285 ±0)` + // Estimated: `11983 + t * (5235 ±0)` + // Minimum execution time: 945_443 nanoseconds. + Weight::from_parts(938_213_161, 11983) + // Standard Error: 12_269_613 + .saturating_add(Weight::from_parts(54_663_055, 0).saturating_mul(t.into())) // Standard Error: 17 - .saturating_add(Weight::from_parts(1_111, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(Weight::from_parts(1_114, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes(6)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 5227).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 5235).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:802 w:802) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:801 w:800) @@ -1386,26 +1378,26 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `System::EventTopics` (r:803 w:803) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Balances::Holds` (r:800 w:800) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// The range of component `r` is `[1, 800]`. fn seal_instantiate(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1278 + r * (255 ±0)` - // Estimated: `9620 + r * (2731 ±0)` - // Minimum execution time: 672_742_000 picoseconds. - Weight::from_parts(680_025_000, 9620) - // Standard Error: 313_642 - .saturating_add(Weight::from_parts(388_311_259, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) + // Measured: `1118 + r * (255 ±0)` + // Estimated: `9443 + r * (2731 ±0)` + // Minimum execution time: 1_267_695 nanoseconds. + Weight::from_parts(1_289_974_000, 9443) + // Standard Error: 991_189 + .saturating_add(Weight::from_parts(801_216_526, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2731).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:3 w:3) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:2 w:1) @@ -1419,30 +1411,32 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// Storage: `System::EventTopics` (r:4 w:4) /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 983040]`. /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1303 + t * (104 ±0)` - // Estimated: `12211 + t * (2549 ±1)` - // Minimum execution time: 2_733_870_000 picoseconds. - Weight::from_parts(1_001_793_458, 12211) - // Standard Error: 12 - .saturating_add(Weight::from_parts(1_963, 0).saturating_mul(i.into())) - // Standard Error: 12 - .saturating_add(Weight::from_parts(2_060, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(16_u64)) + // Measured: `1051 + t * (145 ±0)` + // Estimated: `11964 + t * (2591 ±2)` + // Minimum execution time: 3_219_401 nanoseconds. + Weight::from_parts(976_837_163, 11964) + // Standard Error: 15_942_531 + .saturating_add(Weight::from_parts(200_805_198, 0).saturating_mul(t.into())) + // Standard Error: 25 + .saturating_add(Weight::from_parts(2_489, 0).saturating_mul(i.into())) + // Standard Error: 25 + .saturating_add(Weight::from_parts(2_552, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(11_u64)) + .saturating_add(T::DbWeight::get().writes(11)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) - .saturating_add(Weight::from_parts(0, 2549).saturating_mul(t.into())) + .saturating_add(Weight::from_parts(0, 2591).saturating_mul(t.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1456,20 +1450,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `862 + r * (8 ±0)` - // Estimated: `6801 + r * (8 ±0)` - // Minimum execution time: 272_658_000 picoseconds. - Weight::from_parts(282_717_645, 6801) - // Standard Error: 517 - .saturating_add(Weight::from_parts(400_604, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `648 + r * (8 ±0)` + // Estimated: `6588 + r * (8 ±0)` + // Minimum execution time: 535_012 nanoseconds. + Weight::from_parts(570_533_334, 6588) + // Standard Error: 3_285 + .saturating_add(Weight::from_parts(896_964, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1483,19 +1477,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `870` - // Estimated: `6808` - // Minimum execution time: 260_969_000 picoseconds. - Weight::from_parts(265_206_847, 6808) - // Standard Error: 2 - .saturating_add(Weight::from_parts(1_134, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `656` + // Estimated: `6596` + // Minimum execution time: 544_862 nanoseconds. + Weight::from_parts(587_166_184, 6596) + // Standard Error: 12 + .saturating_add(Weight::from_parts(1_449, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1509,20 +1503,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (8 ±0)` - // Estimated: `6806 + r * (8 ±0)` - // Minimum execution time: 262_351_000 picoseconds. - Weight::from_parts(286_974_296, 6806) - // Standard Error: 514 - .saturating_add(Weight::from_parts(802_363, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `650 + r * (8 ±0)` + // Estimated: `6590 + r * (8 ±0)` + // Minimum execution time: 474_112 nanoseconds. + Weight::from_parts(627_816_943, 6590) + // Standard Error: 5_383 + .saturating_add(Weight::from_parts(1_409_976, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1536,19 +1530,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `872` - // Estimated: `6814` - // Minimum execution time: 276_907_000 picoseconds. - Weight::from_parts(277_928_418, 6814) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_410, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `658` + // Estimated: `6598` + // Minimum execution time: 479_872 nanoseconds. + Weight::from_parts(635_482_819, 6598) + // Standard Error: 13 + .saturating_add(Weight::from_parts(4_874, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1562,20 +1556,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (8 ±0)` - // Estimated: `6808 + r * (8 ±0)` - // Minimum execution time: 263_660_000 picoseconds. - Weight::from_parts(285_665_916, 6808) - // Standard Error: 527 - .saturating_add(Weight::from_parts(480_457, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `650 + r * (8 ±0)` + // Estimated: `6593 + r * (8 ±0)` + // Minimum execution time: 488_072 nanoseconds. + Weight::from_parts(616_223_306, 6593) + // Standard Error: 5_696 + .saturating_add(Weight::from_parts(970_036, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1589,19 +1583,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `872` - // Estimated: `6813` - // Minimum execution time: 262_071_000 picoseconds. - Weight::from_parts(270_115_341, 6813) - // Standard Error: 1 - .saturating_add(Weight::from_parts(1_254, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `658` + // Estimated: `6598` + // Minimum execution time: 542_302 nanoseconds. + Weight::from_parts(613_680_368, 6598) + // Standard Error: 14 + .saturating_add(Weight::from_parts(1_964, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1615,20 +1609,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `864 + r * (8 ±0)` - // Estimated: `6805 + r * (8 ±0)` - // Minimum execution time: 265_568_000 picoseconds. - Weight::from_parts(285_791_811, 6805) - // Standard Error: 559 - .saturating_add(Weight::from_parts(505_330, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `650 + r * (8 ±0)` + // Estimated: `6590 + r * (8 ±0)` + // Minimum execution time: 461_662 nanoseconds. + Weight::from_parts(648_493_086, 6590) + // Standard Error: 4_593 + .saturating_add(Weight::from_parts(920_179, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1642,19 +1636,19 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `872` - // Estimated: `6811` - // Minimum execution time: 271_336_000 picoseconds. - Weight::from_parts(272_829_313, 6811) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_252, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `658` + // Estimated: `6598` + // Minimum execution time: 551_902 nanoseconds. + Weight::from_parts(622_414_265, 6598) + // Standard Error: 15 + .saturating_add(Weight::from_parts(1_982, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1668,20 +1662,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify_per_byte(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `997 + n * (1 ±0)` - // Estimated: `6934 + n * (1 ±0)` - // Minimum execution time: 351_146_000 picoseconds. - Weight::from_parts(355_368_323, 6934) - // Standard Error: 14 - .saturating_add(Weight::from_parts(6_155, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `783 + n * (1 ±0)` + // Estimated: `6720 + n * (1 ±0)` + // Minimum execution time: 679_592 nanoseconds. + Weight::from_parts(693_747_758, 6720) + // Standard Error: 44 + .saturating_add(Weight::from_parts(10_020, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1695,20 +1689,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 160]`. fn seal_sr25519_verify(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `807 + r * (112 ±0)` - // Estimated: `6748 + r * (112 ±0)` - // Minimum execution time: 277_250_000 picoseconds. - Weight::from_parts(346_490_114, 6748) - // Standard Error: 14_654 - .saturating_add(Weight::from_parts(56_127_492, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `589 + r * (112 ±0)` + // Estimated: `6534 + r * (112 ±0)` + // Minimum execution time: 561_292 nanoseconds. + Weight::from_parts(640_027_829, 6534) + // Standard Error: 86_043 + .saturating_add(Weight::from_parts(103_095_748, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 112).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1722,20 +1716,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `907 + r * (76 ±0)` - // Estimated: `6801 + r * (77 ±0)` - // Minimum execution time: 272_697_000 picoseconds. - Weight::from_parts(345_385_667, 6801) - // Standard Error: 14_226 - .saturating_add(Weight::from_parts(46_037_637, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `693 + r * (76 ±0)` + // Estimated: `6587 + r * (77 ±0)` + // Minimum execution time: 547_652 nanoseconds. + Weight::from_parts(660_814_171, 6587) + // Standard Error: 61_313 + .saturating_add(Weight::from_parts(77_704_263, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 77).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1749,20 +1743,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `877 + r * (42 ±0)` - // Estimated: `6816 + r * (42 ±0)` - // Minimum execution time: 271_800_000 picoseconds. - Weight::from_parts(314_891_136, 6816) - // Standard Error: 9_762 - .saturating_add(Weight::from_parts(11_949_979, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `663 + r * (42 ±0)` + // Estimated: `6602 + r * (42 ±0)` + // Minimum execution time: 441_102 nanoseconds. + Weight::from_parts(581_365_341, 6602) + // Standard Error: 30_378 + .saturating_add(Weight::from_parts(16_916_864, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 42).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1536 w:1536) @@ -1777,21 +1771,21 @@ impl pallet_contracts::weights::WeightInfo for WeightIn fn seal_set_code_hash(r: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (965 ±0)` - // Estimated: `6807 + r * (3090 ±10)` - // Minimum execution time: 274_238_000 picoseconds. - Weight::from_parts(278_034_000, 6807) - // Standard Error: 77_011 - .saturating_add(Weight::from_parts(27_627_005, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Estimated: `6593 + r * (3090 ±10)` + // Minimum execution time: 478_301 nanoseconds. + Weight::from_parts(532_962_000, 6593) + // Standard Error: 169_896 + .saturating_add(Weight::from_parts(57_252_995, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 3090).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) @@ -1805,22 +1799,22 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 32]`. fn add_delegate_dependency(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `928 + r * (131 ±0)` - // Estimated: `6878 + r * (2606 ±0)` - // Minimum execution time: 271_519_000 picoseconds. - Weight::from_parts(292_726_476, 6878) - // Standard Error: 23_870 - .saturating_add(Weight::from_parts(6_695_172, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `715 + r * (131 ±0)` + // Estimated: `6664 + r * (2606 ±0)` + // Minimum execution time: 520_780 nanoseconds. + Weight::from_parts(656_546_733, 6664) + // Standard Error: 303_992 + .saturating_add(Weight::from_parts(14_603_365, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2606).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `MaxEncodedLen`) /// Storage: `Contracts::CodeInfoOf` (r:33 w:32) @@ -1834,22 +1828,22 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 32]`. fn remove_delegate_dependency(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `969 + r * (183 ±0)` + // Measured: `754 + r * (183 ±0)` // Estimated: `129453 + r * (2568 ±0)` - // Minimum execution time: 274_675_000 picoseconds. - Weight::from_parts(293_727_489, 129453) - // Standard Error: 23_160 - .saturating_add(Weight::from_parts(5_895_043, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Minimum execution time: 530_861 nanoseconds. + Weight::from_parts(726_049_331, 129453) + // Standard Error: 338_829 + .saturating_add(Weight::from_parts(8_606_108, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2568).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1863,20 +1857,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (3 ±0)` - // Estimated: `6804 + r * (3 ±0)` - // Minimum execution time: 253_330_000 picoseconds. - Weight::from_parts(281_079_564, 6804) - // Standard Error: 378 - .saturating_add(Weight::from_parts(180_655, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `644 + r * (3 ±0)` + // Estimated: `6584 + r * (3 ±0)` + // Minimum execution time: 468_541 nanoseconds. + Weight::from_parts(626_524_887, 6584) + // Standard Error: 4_710 + .saturating_add(Weight::from_parts(393_620, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1890,20 +1884,20 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2109 + r * (39 ±0)` - // Estimated: `7899 + r * (40 ±0)` - // Minimum execution time: 276_552_000 picoseconds. - Weight::from_parts(368_521_088, 7899) - // Standard Error: 2_310 - .saturating_add(Weight::from_parts(318_129, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) + // Measured: `1382 + r * (39 ±0)` + // Estimated: `7282 + r * (39 ±0)` + // Minimum execution time: 542_420 nanoseconds. + Weight::from_parts(717_598_356, 7282) + // Standard Error: 4_053 + .saturating_add(Weight::from_parts(553_534, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_parts(0, 39).saturating_mul(r.into())) } /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `Measured`) /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) @@ -1919,14 +1913,14 @@ impl pallet_contracts::weights::WeightInfo for WeightIn /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `861 + r * (3 ±0)` - // Estimated: `6801 + r * (3 ±0)` - // Minimum execution time: 258_953_000 picoseconds. - Weight::from_parts(288_222_836, 6801) - // Standard Error: 367 - .saturating_add(Weight::from_parts(152_842, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `647 + r * (3 ±0)` + // Estimated: `6587 + r * (3 ±0)` + // Minimum execution time: 534_052 nanoseconds. + Weight::from_parts(647_781_638, 6587) + // Standard Error: 6_129 + .saturating_add(Weight::from_parts(327_893, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. @@ -1934,9 +1928,9 @@ impl pallet_contracts::weights::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_476_000 picoseconds. - Weight::from_parts(2_119_717, 0) - // Standard Error: 28 - .saturating_add(Weight::from_parts(9_805, 0).saturating_mul(r.into())) + // Minimum execution time: 3_760 nanoseconds. + Weight::from_parts(6_262_561, 0) + // Standard Error: 74 + .saturating_add(Weight::from_parts(22_284, 0).saturating_mul(r.into())) } } diff --git a/runtime/common/src/weights/pallet_democracy.rs b/runtime/common/src/weights/pallet_democracy.rs index 78f1f7ee1..100de6939 100644 --- a/runtime/common/src/weights/pallet_democracy.rs +++ b/runtime/common/src/weights/pallet_democracy.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,448 +52,448 @@ use frame_support::{ /// Weight functions for pallet_democracy (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_democracy::weights::WeightInfo for WeightInfo { - /// Storage: Democracy PublicPropCount (r:1 w:1) - /// Proof: Democracy PublicPropCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy PublicProps (r:1 w:1) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Democracy Blacklist (r:1 w:0) - /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) - /// Storage: Democracy DepositOf (r:0 w:1) - /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicPropCount` (r:1 w:1) + /// Proof: `Democracy::PublicPropCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::PublicProps` (r:1 w:1) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Democracy::Blacklist` (r:1 w:0) + /// Proof: `Democracy::Blacklist` (`max_values`: None, `max_size`: Some(3242), added: 5717, mode: `MaxEncodedLen`) + /// Storage: `Democracy::DepositOf` (r:0 w:1) + /// Proof: `Democracy::DepositOf` (`max_values`: None, `max_size`: Some(3230), added: 5705, mode: `MaxEncodedLen`) fn propose() -> Weight { // Proof Size summary in bytes: - // Measured: `4801` + // Measured: `4772` // Estimated: `18187` - // Minimum execution time: 49_339_000 picoseconds. - Weight::from_parts(50_942_000, 18187) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Minimum execution time: 94_250 nanoseconds. + Weight::from_parts(106_040_000, 18187) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy DepositOf (r:1 w:1) - /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: `Democracy::DepositOf` (r:1 w:1) + /// Proof: `Democracy::DepositOf` (`max_values`: None, `max_size`: Some(3230), added: 5705, mode: `MaxEncodedLen`) fn second() -> Weight { // Proof Size summary in bytes: - // Measured: `3556` + // Measured: `3527` // Estimated: `6695` - // Minimum execution time: 43_291_000 picoseconds. - Weight::from_parts(44_856_000, 6695) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 79_460 nanoseconds. + Weight::from_parts(83_551_000, 6695) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `3470` - // Estimated: `7260` - // Minimum execution time: 61_890_000 picoseconds. - Weight::from_parts(63_626_000, 7260) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `3415` + // Estimated: `7264` + // Minimum execution time: 119_831 nanoseconds. + Weight::from_parts(125_030_000, 7264) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `3492` - // Estimated: `7260` - // Minimum execution time: 67_802_000 picoseconds. - Weight::from_parts(69_132_000, 7260) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `3437` + // Estimated: `7264` + // Minimum execution time: 98_820 nanoseconds. + Weight::from_parts(131_651_000, 7264) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy Cancellations (r:1 w:1) - /// Proof: Democracy Cancellations (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::Cancellations` (r:1 w:1) + /// Proof: `Democracy::Cancellations` (`max_values`: None, `max_size`: Some(33), added: 2508, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn emergency_cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `366` - // Estimated: `3666` - // Minimum execution time: 25_757_000 picoseconds. - Weight::from_parts(27_226_000, 3666) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `341` + // Estimated: `3674` + // Minimum execution time: 52_690 nanoseconds. + Weight::from_parts(54_040_000, 3674) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy PublicProps (r:1 w:1) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Democracy DepositOf (r:1 w:1) - /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:3 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) - /// Storage: Democracy NextExternal (r:1 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy Blacklist (r:0 w:1) - /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicProps` (r:1 w:1) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Democracy::DepositOf` (r:1 w:1) + /// Proof: `Democracy::DepositOf` (`max_values`: None, `max_size`: Some(3230), added: 5705, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:3 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) + /// Storage: `Democracy::NextExternal` (r:1 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::Blacklist` (r:0 w:1) + /// Proof: `Democracy::Blacklist` (`max_values`: None, `max_size`: Some(3242), added: 5717, mode: `MaxEncodedLen`) fn blacklist() -> Weight { // Proof Size summary in bytes: - // Measured: `5910` + // Measured: `6171` // Estimated: `18187` - // Minimum execution time: 113_060_000 picoseconds. - Weight::from_parts(114_813_000, 18187) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 214_781 nanoseconds. + Weight::from_parts(226_251_000, 18187) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) } - /// Storage: Democracy NextExternal (r:1 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy Blacklist (r:1 w:0) - /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:1 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::Blacklist` (r:1 w:0) + /// Proof: `Democracy::Blacklist` (`max_values`: None, `max_size`: Some(3242), added: 5717, mode: `MaxEncodedLen`) fn external_propose() -> Weight { // Proof Size summary in bytes: - // Measured: `3416` - // Estimated: `6703` - // Minimum execution time: 13_413_000 picoseconds. - Weight::from_parts(13_794_000, 6703) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `3387` + // Estimated: `6707` + // Minimum execution time: 28_680 nanoseconds. + Weight::from_parts(29_660_000, 6707) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy NextExternal (r:0 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:0 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) fn external_propose_majority() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_213_000 picoseconds. - Weight::from_parts(3_429_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 6_580 nanoseconds. + Weight::from_parts(7_150_000, 0).saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy NextExternal (r:0 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:0 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) fn external_propose_default() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_280_000 picoseconds. - Weight::from_parts(3_389_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 6_760 nanoseconds. + Weight::from_parts(7_100_000, 0).saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy NextExternal (r:1 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumCount (r:1 w:1) - /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:2) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:0 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:1 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumCount` (r:1 w:1) + /// Proof: `Democracy::ReferendumCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:2) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:0 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) fn fast_track() -> Weight { // Proof Size summary in bytes: - // Measured: `286` + // Measured: `253` // Estimated: `3518` - // Minimum execution time: 28_142_000 picoseconds. - Weight::from_parts(28_862_000, 3518) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Minimum execution time: 54_810 nanoseconds. + Weight::from_parts(55_750_000, 3518) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: Democracy NextExternal (r:1 w:1) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy Blacklist (r:1 w:1) - /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:1 w:1) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::Blacklist` (r:1 w:1) + /// Proof: `Democracy::Blacklist` (`max_values`: None, `max_size`: Some(3242), added: 5717, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn veto_external() -> Weight { // Proof Size summary in bytes: - // Measured: `3519` - // Estimated: `6703` - // Minimum execution time: 32_395_000 picoseconds. - Weight::from_parts(33_617_000, 6703) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `3490` + // Estimated: `6707` + // Minimum execution time: 59_521 nanoseconds. + Weight::from_parts(60_930_000, 6707) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy PublicProps (r:1 w:1) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Democracy DepositOf (r:1 w:1) - /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicProps` (r:1 w:1) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Democracy::DepositOf` (r:1 w:1) + /// Proof: `Democracy::DepositOf` (`max_values`: None, `max_size`: Some(3230), added: 5705, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn cancel_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `5821` + // Measured: `6074` // Estimated: `18187` - // Minimum execution time: 92_255_000 picoseconds. - Weight::from_parts(93_704_000, 18187) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Minimum execution time: 186_500 nanoseconds. + Weight::from_parts(203_851_000, 18187) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:0 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:0 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) fn cancel_referendum() -> Weight { // Proof Size summary in bytes: - // Measured: `271` + // Measured: `238` // Estimated: `3518` - // Minimum execution time: 19_623_000 picoseconds. - Weight::from_parts(20_545_000, 3518) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 40_041 nanoseconds. + Weight::from_parts(41_300_000, 3518) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Democracy LowestUnbaked (r:1 w:1) - /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumCount (r:1 w:0) - /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:99 w:0) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: `Democracy::LowestUnbaked` (r:1 w:1) + /// Proof: `Democracy::LowestUnbaked` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumCount` (r:1 w:0) + /// Proof: `Democracy::ReferendumCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:99 w:0) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (86 ±0)` - // Estimated: `1489 + r * (2676 ±0)` - // Minimum execution time: 7_032_000 picoseconds. - Weight::from_parts(7_931_421, 1489) - // Standard Error: 7_395 - .saturating_add(Weight::from_parts(3_236_964, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `211 + r * (94 ±0)` + // Estimated: `1489 + r * (2684 ±0)` + // Minimum execution time: 15_640 nanoseconds. + Weight::from_parts(16_300_000, 1489) + // Standard Error: 24_194 + .saturating_add(Weight::from_parts(6_717_090, 0).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_u64)) - .saturating_add(Weight::from_parts(0, 2676).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } - /// Storage: Democracy LowestUnbaked (r:1 w:1) - /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumCount (r:1 w:0) - /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Democracy LastTabledWasExternal (r:1 w:0) - /// Proof: Democracy LastTabledWasExternal (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Democracy NextExternal (r:1 w:0) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy PublicProps (r:1 w:0) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:99 w:0) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: `Democracy::LowestUnbaked` (r:1 w:1) + /// Proof: `Democracy::LowestUnbaked` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumCount` (r:1 w:0) + /// Proof: `Democracy::ReferendumCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Democracy::LastTabledWasExternal` (r:1 w:0) + /// Proof: `Democracy::LastTabledWasExternal` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + /// Storage: `Democracy::NextExternal` (r:1 w:0) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::PublicProps` (r:1 w:0) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:99 w:0) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `244 + r * (86 ±0)` - // Estimated: `18187 + r * (2676 ±0)` - // Minimum execution time: 10_524_000 picoseconds. - Weight::from_parts(10_369_064, 18187) - // Standard Error: 8_385 - .saturating_add(Weight::from_parts(3_242_334, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `211 + r * (94 ±0)` + // Estimated: `18187 + r * (2684 ±0)` + // Minimum execution time: 21_570 nanoseconds. + Weight::from_parts(21_702_657, 18187) + // Standard Error: 27_834 + .saturating_add(Weight::from_parts(6_702_723, 0).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_u64)) - .saturating_add(Weight::from_parts(0, 2676).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } - /// Storage: Democracy VotingOf (r:3 w:3) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:99 w:99) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Democracy::VotingOf` (r:3 w:3) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:99 w:99) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `830 + r * (108 ±0)` - // Estimated: `19800 + r * (2676 ±0)` - // Minimum execution time: 46_106_000 picoseconds. - Weight::from_parts(48_936_654, 19800) - // Standard Error: 8_879 - .saturating_add(Weight::from_parts(4_708_141, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `779 + r * (116 ±0)` + // Estimated: `19812 + r * (2684 ±0)` + // Minimum execution time: 77_540 nanoseconds. + Weight::from_parts(78_180_523, 19812) + // Standard Error: 62_728 + .saturating_add(Weight::from_parts(8_933_951, 0).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(4_u64)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2676).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } - /// Storage: Democracy VotingOf (r:2 w:2) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Democracy ReferendumInfoOf (r:99 w:99) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: `Democracy::VotingOf` (r:2 w:2) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Democracy::ReferendumInfoOf` (r:99 w:99) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `493 + r * (108 ±0)` - // Estimated: `13530 + r * (2676 ±0)` - // Minimum execution time: 21_078_000 picoseconds. - Weight::from_parts(22_732_737, 13530) - // Standard Error: 7_969 - .saturating_add(Weight::from_parts(4_626_458, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `468 + r * (116 ±0)` + // Estimated: `13538 + r * (2684 ±0)` + // Minimum execution time: 42_001 nanoseconds. + Weight::from_parts(44_467_605, 13538) + // Standard Error: 42_007 + .saturating_add(Weight::from_parts(8_358_722, 0).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_u64)) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2676).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(0, 2684).saturating_mul(r.into())) } - /// Storage: Democracy PublicProps (r:0 w:1) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicProps` (r:0 w:1) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) fn clear_public_proposals() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_229_000 picoseconds. - Weight::from_parts(3_415_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 6_970 nanoseconds. + Weight::from_parts(7_250_000, 0).saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `563` - // Estimated: `7260` - // Minimum execution time: 25_735_000 picoseconds. - Weight::from_parts(41_341_468, 7260) - // Standard Error: 3_727 - .saturating_add(Weight::from_parts(94_755, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `500` + // Estimated: `7264` + // Minimum execution time: 46_810 nanoseconds. + Weight::from_parts(73_459_464, 7264) + // Standard Error: 9_303 + .saturating_add(Weight::from_parts(355_260, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `564 + r * (22 ±0)` - // Estimated: `7260` - // Minimum execution time: 36_233_000 picoseconds. - Weight::from_parts(39_836_017, 7260) - // Standard Error: 1_791 - .saturating_add(Weight::from_parts(132_158, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `501 + r * (22 ±0)` + // Estimated: `7264` + // Minimum execution time: 57_700 nanoseconds. + Weight::from_parts(73_683_809, 7264) + // Standard Error: 10_335 + .saturating_add(Weight::from_parts(391_304, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `728 + r * (26 ±0)` - // Estimated: `7260` - // Minimum execution time: 16_081_000 picoseconds. - Weight::from_parts(19_624_101, 7260) - // Standard Error: 1_639 - .saturating_add(Weight::from_parts(133_630, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `707 + r * (26 ±0)` + // Estimated: `7264` + // Minimum execution time: 32_310 nanoseconds. + Weight::from_parts(42_608_741, 7264) + // Standard Error: 8_632 + .saturating_add(Weight::from_parts(320_539, 0).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) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy VotingOf (r:1 w:1) - /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:1) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::VotingOf` (r:1 w:1) + /// Proof: `Democracy::VotingOf` (`max_values`: None, `max_size`: Some(3799), added: 6274, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `728 + r * (26 ±0)` - // Estimated: `7260` - // Minimum execution time: 15_634_000 picoseconds. - Weight::from_parts(19_573_407, 7260) - // Standard Error: 1_790 - .saturating_add(Weight::from_parts(139_707, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `707 + r * (26 ±0)` + // Estimated: `7264` + // Minimum execution time: 27_850 nanoseconds. + Weight::from_parts(38_259_109, 7264) + // Standard Error: 6_531 + .saturating_add(Weight::from_parts(367_033, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Democracy NextExternal (r:1 w:0) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Preimage StatusFor (r:1 w:0) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:0 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:1 w:0) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:0 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn set_external_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `356` + // Measured: `323` // Estimated: `3556` - // Minimum execution time: 18_344_000 picoseconds. - Weight::from_parts(18_727_000, 3556) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 37_840 nanoseconds. + Weight::from_parts(38_590_000, 3556) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy NextExternal (r:1 w:0) - /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::NextExternal` (r:1 w:0) + /// Proof: `Democracy::NextExternal` (`max_values`: Some(1), `max_size`: Some(132), added: 627, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn clear_external_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `286` + // Measured: `253` // Estimated: `3518` - // Minimum execution time: 16_497_000 picoseconds. - Weight::from_parts(16_892_000, 3518) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 34_190 nanoseconds. + Weight::from_parts(35_360_000, 3518) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy PublicProps (r:1 w:0) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Preimage StatusFor (r:1 w:0) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:0 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicProps` (r:1 w:0) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:0 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn set_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4888` + // Measured: `4855` // Estimated: `18187` - // Minimum execution time: 39_517_000 picoseconds. - Weight::from_parts(40_632_000, 18187) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 79_700 nanoseconds. + Weight::from_parts(93_760_000, 18187) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy PublicProps (r:1 w:0) - /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::PublicProps` (r:1 w:0) + /// Proof: `Democracy::PublicProps` (`max_values`: Some(1), `max_size`: Some(16702), added: 17197, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn clear_proposal_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `4822` + // Measured: `4789` // Estimated: `18187` - // Minimum execution time: 37_108_000 picoseconds. - Weight::from_parts(37_599_000, 18187) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 77_470 nanoseconds. + Weight::from_parts(88_080_000, 18187) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:0) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:0 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:0) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:0 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn set_referendum_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `144` // Estimated: `3556` - // Minimum execution time: 13_997_000 picoseconds. - Weight::from_parts(14_298_000, 3556) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 29_750 nanoseconds. + Weight::from_parts(30_401_000, 3556) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Democracy ReferendumInfoOf (r:1 w:0) - /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) - /// Storage: Democracy MetadataOf (r:1 w:1) - /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) + /// Storage: `Democracy::ReferendumInfoOf` (r:1 w:0) + /// Proof: `Democracy::ReferendumInfoOf` (`max_values`: None, `max_size`: Some(209), added: 2684, mode: `MaxEncodedLen`) + /// Storage: `Democracy::MetadataOf` (r:1 w:1) + /// Proof: `Democracy::MetadataOf` (`max_values`: None, `max_size`: Some(53), added: 2528, mode: `MaxEncodedLen`) fn clear_referendum_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `302` - // Estimated: `3666` - // Minimum execution time: 18_122_000 picoseconds. - Weight::from_parts(18_655_000, 3666) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `273` + // Estimated: `3674` + // Minimum execution time: 38_380 nanoseconds. + Weight::from_parts(39_540_000, 3674) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/common/src/weights/pallet_identity.rs b/runtime/common/src/weights/pallet_identity.rs index 2aa7b79ab..b375f700e 100644 --- a/runtime/common/src/weights/pallet_identity.rs +++ b/runtime/common/src/weights/pallet_identity.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_identity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,284 +52,288 @@ use frame_support::{ /// Weight functions for pallet_identity (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_identity::weights::WeightInfo for WeightInfo { - /// Storage: Identity Registrars (r:1 w:1) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:1) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 7]`. - fn add_registrar(_r: u32) -> Weight { + fn add_registrar(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `64 + r * (57 ±0)` - // Estimated: `952` - // Minimum execution time: 20_160 nanoseconds. - Weight::from_parts(25_433_606, 952) + // Measured: `32 + r * (57 ±0)` + // Estimated: `1942` + // Minimum execution time: 21_660 nanoseconds. + Weight::from_parts(25_850_328, 1942) + // Standard Error: 29_962 + .saturating_add(Weight::from_parts(896_959, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 8]`. /// The range of component `x` is `[0, 64]`. - fn set_identity(_r: u32, x: u32) -> Weight { + fn set_identity(r: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `474 + r * (5 ±0)` - // Estimated: `7313` - // Minimum execution time: 25_740 nanoseconds. - Weight::from_parts(54_428_048, 7313) - // Standard Error: 11_438 - .saturating_add(Weight::from_parts(664_046, 0).saturating_mul(x.into())) + // Measured: `442 + r * (5 ±0)` + // Estimated: `8303` + // Minimum execution time: 39_640 nanoseconds. + Weight::from_parts(60_315_640, 8303) + // Standard Error: 144_124 + .saturating_add(Weight::from_parts(609_509, 0).saturating_mul(r.into())) + // Standard Error: 16_740 + .saturating_add(Weight::from_parts(1_085_375, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SubsOf (r:1 w:1) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:64 w:64) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:0) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:64 w:64) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 64]`. fn set_subs_new(s: u32) -> Weight { // Proof Size summary in bytes: // Measured: `101` - // Estimated: `11894 + s * (2589 ±0)` - // Minimum execution time: 14_240 nanoseconds. - Weight::from_parts(38_930_175, 11894) - // Standard Error: 40_523 - .saturating_add(Weight::from_parts(4_824_524, 0).saturating_mul(s.into())) + // Estimated: `8303 + s * (2589 ±0)` + // Minimum execution time: 19_750 nanoseconds. + Weight::from_parts(46_888_139, 8303) + // Standard Error: 63_869 + .saturating_add(Weight::from_parts(6_537_301, 0).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()))) .saturating_add(Weight::from_parts(0, 2589).saturating_mul(s.into())) } - /// Storage: Identity IdentityOf (r:1 w:0) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SubsOf (r:1 w:1) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:0 w:64) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:0) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:0 w:64) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) /// The range of component `p` is `[0, 64]`. fn set_subs_old(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `226 + p * (32 ±0)` - // Estimated: `11894` - // Minimum execution time: 16_560 nanoseconds. - Weight::from_parts(33_071_959, 11894) - // Standard Error: 19_437 - .saturating_add(Weight::from_parts(2_080_950, 0).saturating_mul(p.into())) + // Measured: `194 + p * (32 ±0)` + // Estimated: `8303` + // Minimum execution time: 19_190 nanoseconds. + Weight::from_parts(51_774_753, 8303) + // Standard Error: 31_886 + .saturating_add(Weight::from_parts(2_750_438, 0).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) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) - /// Storage: Identity IdentityOf (r:1 w:1) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:0 w:64) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:0 w:64) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 8]`. /// The range of component `s` is `[0, 64]`. /// The range of component `x` is `[0, 64]`. - fn clear_identity(r: u32, s: u32, x: u32) -> Weight { + fn clear_identity(_r: u32, s: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `535 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `11894` - // Minimum execution time: 58_640 nanoseconds. - Weight::from_parts(48_246_140, 11894) - // Standard Error: 182_255 - .saturating_add(Weight::from_parts(387_308, 0).saturating_mul(r.into())) - // Standard Error: 21_222 - .saturating_add(Weight::from_parts(1_997_948, 0).saturating_mul(s.into())) - // Standard Error: 21_222 - .saturating_add(Weight::from_parts(265_450, 0).saturating_mul(x.into())) + // Measured: `471 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `8303` + // Minimum execution time: 94_821 nanoseconds. + Weight::from_parts(81_296_022, 8303) + // Standard Error: 17_279 + .saturating_add(Weight::from_parts(2_529_084, 0).saturating_mul(s.into())) + // Standard Error: 17_279 + .saturating_add(Weight::from_parts(530_119, 0).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) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) - /// Storage: Identity IdentityOf (r:1 w:1) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:0) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 8]`. /// The range of component `x` is `[0, 64]`. fn request_judgement(_r: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `431 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `8265` - // Minimum execution time: 41_030 nanoseconds. - Weight::from_parts(60_905_120, 8265) - // Standard Error: 11_458 - .saturating_add(Weight::from_parts(668_303, 0).saturating_mul(x.into())) + // Measured: `367 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `8303` + // Minimum execution time: 51_290 nanoseconds. + Weight::from_parts(71_825_285, 8303) + // Standard Error: 20_454 + .saturating_add(Weight::from_parts(1_158_768, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 8]`. /// The range of component `x` is `[0, 64]`. fn cancel_request(r: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `430 + x * (66 ±0)` - // Estimated: `7313` - // Minimum execution time: 37_480 nanoseconds. - Weight::from_parts(43_853_453, 7313) - // Standard Error: 105_132 - .saturating_add(Weight::from_parts(224_903, 0).saturating_mul(r.into())) - // Standard Error: 12_211 - .saturating_add(Weight::from_parts(728_184, 0).saturating_mul(x.into())) + // Measured: `398 + x * (66 ±0)` + // Estimated: `8303` + // Minimum execution time: 49_660 nanoseconds. + Weight::from_parts(56_328_193, 8303) + // Standard Error: 104_321 + .saturating_add(Weight::from_parts(615_177, 0).saturating_mul(r.into())) + // Standard Error: 12_117 + .saturating_add(Weight::from_parts(1_058_625, 0).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) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:1) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 7]`. fn set_fee(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `952` - // Minimum execution time: 13_030 nanoseconds. - Weight::from_parts(14_794_208, 952) - // Standard Error: 28_452 - .saturating_add(Weight::from_parts(499_504, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `1942` + // Minimum execution time: 14_930 nanoseconds. + Weight::from_parts(19_021_487, 1942) + // Standard Error: 27_494 + .saturating_add(Weight::from_parts(355_592, 0).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) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:1) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 7]`. fn set_account_id(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `952` - // Minimum execution time: 10_610 nanoseconds. - Weight::from_parts(14_237_318, 952) - // Standard Error: 19_699 - .saturating_add(Weight::from_parts(124_020, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `1942` + // Minimum execution time: 14_111 nanoseconds. + Weight::from_parts(16_435_082, 1942) + // Standard Error: 17_735 + .saturating_add(Weight::from_parts(343_164, 0).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) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:1) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 7]`. fn set_fields(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `121 + r * (57 ±0)` - // Estimated: `952` - // Minimum execution time: 10_390 nanoseconds. - Weight::from_parts(14_604_605, 952) - // Standard Error: 17_396 - .saturating_add(Weight::from_parts(10_750, 0).saturating_mul(r.into())) + // Measured: `89 + r * (57 ±0)` + // Estimated: `1942` + // Minimum execution time: 13_630 nanoseconds. + Weight::from_parts(17_450_843, 1942) + // Standard Error: 19_433 + .saturating_add(Weight::from_parts(358_031, 0).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) - /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(457), added: 952, mode: MaxEncodedLen) - /// Storage: Identity IdentityOf (r:1 w:1) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) + /// Storage: `Identity::Registrars` (r:1 w:0) + /// Proof: `Identity::Registrars` (`max_values`: Some(1), `max_size`: Some(457), added: 952, mode: `MaxEncodedLen`) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 7]`. /// The range of component `x` is `[0, 64]`. fn provide_judgement(_r: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `509 + r * (57 ±0) + x * (66 ±0)` - // Estimated: `8265` - // Minimum execution time: 32_650 nanoseconds. - Weight::from_parts(48_622_386, 8265) - // Standard Error: 15_117 - .saturating_add(Weight::from_parts(1_066_351, 0).saturating_mul(x.into())) + // Measured: `445 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `8303` + // Minimum execution time: 43_850 nanoseconds. + Weight::from_parts(74_007_290, 8303) + // Standard Error: 14_509 + .saturating_add(Weight::from_parts(1_470_246, 0).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) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) - /// Storage: Identity IdentityOf (r:1 w:1) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:0 w:64) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) + /// Storage: `Identity::IdentityOf` (r:1 w:1) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:0 w:64) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 8]`. /// The range of component `s` is `[0, 64]`. /// The range of component `x` is `[0, 64]`. fn kill_identity(r: u32, s: u32, x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `954 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` - // Estimated: `17108` - // Minimum execution time: 76_120 nanoseconds. - Weight::from_parts(58_672_057, 17108) - // Standard Error: 176_813 - .saturating_add(Weight::from_parts(404_857, 0).saturating_mul(r.into())) - // Standard Error: 20_588 - .saturating_add(Weight::from_parts(2_097_548, 0).saturating_mul(s.into())) - // Standard Error: 20_588 - .saturating_add(Weight::from_parts(421_199, 0).saturating_mul(x.into())) + // Measured: `826 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `8303` + // Minimum execution time: 126_141 nanoseconds. + Weight::from_parts(85_217_639, 8303) + // Standard Error: 167_129 + .saturating_add(Weight::from_parts(2_032_971, 0).saturating_mul(r.into())) + // Standard Error: 19_461 + .saturating_add(Weight::from_parts(2_770_065, 0).saturating_mul(s.into())) + // Standard Error: 19_461 + .saturating_add(Weight::from_parts(654_970, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:1 w:1) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) - /// Storage: Identity SubsOf (r:1 w:1) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:0) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:1 w:1) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 63]`. fn add_sub(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `355 + s * (41 ±0)` - // Estimated: `14483` - // Minimum execution time: 38_690 nanoseconds. - Weight::from_parts(51_610_989, 14483) - // Standard Error: 10_821 - .saturating_add(Weight::from_parts(141_693, 0).saturating_mul(s.into())) + // Measured: `323 + s * (41 ±0)` + // Estimated: `8303` + // Minimum execution time: 53_400 nanoseconds. + Weight::from_parts(67_814_141, 8303) + // Standard Error: 14_324 + .saturating_add(Weight::from_parts(312_244, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:1 w:1) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:0) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:1 w:1) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) /// The range of component `s` is `[1, 64]`. fn rename_sub(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `464 + s * (7 ±0)` - // Estimated: `9902` - // Minimum execution time: 19_930 nanoseconds. - Weight::from_parts(27_289_143, 9902) - // Standard Error: 4_266 - .saturating_add(Weight::from_parts(23_773, 0).saturating_mul(s.into())) + // Measured: `432 + s * (7 ±0)` + // Estimated: `8303` + // Minimum execution time: 22_360 nanoseconds. + Weight::from_parts(32_328_919, 8303) + // Standard Error: 5_763 + .saturating_add(Weight::from_parts(96_628, 0).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) - /// Proof: Identity IdentityOf (max_values: None, max_size: Some(4838), added: 7313, mode: MaxEncodedLen) - /// Storage: Identity SuperOf (r:1 w:1) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) - /// Storage: Identity SubsOf (r:1 w:1) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) + /// Storage: `Identity::IdentityOf` (r:1 w:0) + /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(4838), added: 7313, mode: `MaxEncodedLen`) + /// Storage: `Identity::SuperOf` (r:1 w:1) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) /// The range of component `s` is `[1, 64]`. fn remove_sub(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `544 + s * (39 ±0)` - // Estimated: `14483` - // Minimum execution time: 44_120 nanoseconds. - Weight::from_parts(55_480_947, 14483) - // Standard Error: 10_276 - .saturating_add(Weight::from_parts(74_281, 0).saturating_mul(s.into())) + // Measured: `480 + s * (39 ±0)` + // Estimated: `8303` + // Minimum execution time: 53_400 nanoseconds. + Weight::from_parts(72_889_969, 8303) + // Standard Error: 13_786 + .saturating_add(Weight::from_parts(142_340, 0).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) - /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) - /// Storage: Identity SubsOf (r:1 w:1) - /// Proof: Identity SubsOf (max_values: None, max_size: Some(2106), added: 4581, mode: MaxEncodedLen) + /// Storage: `Identity::SuperOf` (r:1 w:1) + /// Proof: `Identity::SuperOf` (`max_values`: None, `max_size`: Some(114), added: 2589, mode: `MaxEncodedLen`) + /// Storage: `Identity::SubsOf` (r:1 w:1) + /// Proof: `Identity::SubsOf` (`max_values`: None, `max_size`: Some(2106), added: 4581, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 63]`. fn quit_sub(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `469 + s * (42 ±0)` - // Estimated: `7170` - // Minimum execution time: 30_280 nanoseconds. - Weight::from_parts(37_281_308, 7170) - // Standard Error: 7_323 - .saturating_add(Weight::from_parts(156_189, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `583 + s * (42 ±0)` + // Estimated: `5571` + // Minimum execution time: 43_830 nanoseconds. + Weight::from_parts(58_683_464, 5571) + // Standard Error: 11_129 + .saturating_add(Weight::from_parts(198_809, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) .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 a5e298a66..27fe60aad 100644 --- a/runtime/common/src/weights/pallet_membership.rs +++ b/runtime/common/src/weights/pallet_membership.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_membership //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,151 +52,151 @@ use frame_support::{ /// Weight functions for pallet_membership (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_membership::weights::WeightInfo for WeightInfo { - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Members (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Members` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `237 + m * (64 ±0)` - // Estimated: `4900 + m * (192 ±0)` - // Minimum execution time: 25_400 nanoseconds. - Weight::from_parts(32_228_880, 4900) - // Standard Error: 4_601 - .saturating_add(Weight::from_parts(86_582, 0).saturating_mul(m.into())) + // Measured: `173 + m * (64 ±0)` + // Estimated: `4687 + m * (64 ±0)` + // Minimum execution time: 28_891 nanoseconds. + Weight::from_parts(38_624_052, 4687) + // Standard Error: 4_114 + .saturating_add(Weight::from_parts(92_160, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommitteeMembership Prime (r:1 w:0) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Members (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:1 w:0) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Members` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `341 + m * (64 ±0)` - // Estimated: `5739 + m * (192 ±0)` - // Minimum execution time: 33_480 nanoseconds. - Weight::from_parts(40_243_522, 5739) - // Standard Error: 5_034 - .saturating_add(Weight::from_parts(47_094, 0).saturating_mul(m.into())) + // Measured: `277 + m * (64 ±0)` + // Estimated: `4687 + m * (64 ±0)` + // Minimum execution time: 34_980 nanoseconds. + Weight::from_parts(45_466_871, 4687) + // Standard Error: 5_162 + .saturating_add(Weight::from_parts(49_436, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommitteeMembership Prime (r:1 w:0) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Members (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:1 w:0) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Members` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `341 + m * (64 ±0)` - // Estimated: `5739 + m * (192 ±0)` - // Minimum execution time: 30_070 nanoseconds. - Weight::from_parts(39_888_985, 5739) - // Standard Error: 5_667 - .saturating_add(Weight::from_parts(60_568, 0).saturating_mul(m.into())) + // Measured: `277 + m * (64 ±0)` + // Estimated: `4687 + m * (64 ±0)` + // Minimum execution time: 34_110 nanoseconds. + Weight::from_parts(44_605_700, 4687) + // Standard Error: 5_689 + .saturating_add(Weight::from_parts(80_800, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommitteeMembership Prime (r:1 w:0) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Members (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:1 w:0) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Members` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `341 + m * (64 ±0)` - // Estimated: `5739 + m * (192 ±0)` - // Minimum execution time: 32_460 nanoseconds. - Weight::from_parts(38_375_533, 5739) - // Standard Error: 6_339 - .saturating_add(Weight::from_parts(275_877, 0).saturating_mul(m.into())) + // Measured: `277 + m * (64 ±0)` + // Estimated: `4687 + m * (64 ±0)` + // Minimum execution time: 38_531 nanoseconds. + Weight::from_parts(44_370_362, 4687) + // Standard Error: 6_660 + .saturating_add(Weight::from_parts(307_146, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Proposals (r:1 w:0) - /// Proof Skipped: AdvisoryCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommitteeMembership Prime (r:1 w:1) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Members (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Proposals` (r:1 w:0) + /// Proof: `AdvisoryCommittee::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:1 w:1) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Members` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `341 + m * (64 ±0)` - // Estimated: `5739 + m * (192 ±0)` - // Minimum execution time: 34_170 nanoseconds. - Weight::from_parts(41_592_825, 5739) - // Standard Error: 5_454 - .saturating_add(Weight::from_parts(46_054, 0).saturating_mul(m.into())) + // Measured: `277 + m * (64 ±0)` + // Estimated: `4687 + m * (64 ±0)` + // Minimum execution time: 33_720 nanoseconds. + Weight::from_parts(46_240_091, 4687) + // Standard Error: 6_117 + .saturating_add(Weight::from_parts(77_038, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 192).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Members (r:1 w:0) - /// Proof: AdvisoryCommitteeMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: AdvisoryCommitteeMembership Prime (r:0 w:1) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Members` (r:1 w:0) + /// Proof: `AdvisoryCommitteeMembership::Members` (`max_values`: Some(1), `max_size`: Some(3202), added: 3697, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `136 + m * (32 ±0)` - // Estimated: `3833 + m * (32 ±0)` - // Minimum execution time: 14_610 nanoseconds. - Weight::from_parts(17_594_663, 3833) - // Standard Error: 2_314 - .saturating_add(Weight::from_parts(27_614, 0).saturating_mul(m.into())) + // Measured: `104 + m * (32 ±0)` + // Estimated: `4687 + m * (32 ±0)` + // Minimum execution time: 15_210 nanoseconds. + Weight::from_parts(20_320_551, 4687) + // Standard Error: 2_763 + .saturating_add(Weight::from_parts(38_801, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } - /// Storage: AdvisoryCommitteeMembership Prime (r:0 w:1) - /// Proof: AdvisoryCommitteeMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: AdvisoryCommittee Prime (r:0 w:1) - /// Proof Skipped: AdvisoryCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `AdvisoryCommitteeMembership::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommitteeMembership::Prime` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `AdvisoryCommittee::Prime` (r:0 w:1) + /// Proof: `AdvisoryCommittee::Prime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_300 nanoseconds. - Weight::from_parts(6_149_799, 0) - // Standard Error: 750 - .saturating_add(Weight::from_parts(8_021, 0).saturating_mul(m.into())) + // Minimum execution time: 5_590 nanoseconds. + Weight::from_parts(7_678_557, 0) + // Standard Error: 899 + .saturating_add(Weight::from_parts(1_667, 0).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 ed3df3103..208529d4c 100644 --- a/runtime/common/src/weights/pallet_multisig.rs +++ b/runtime/common/src/weights/pallet_multisig.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_multisig //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -57,103 +57,103 @@ impl pallet_multisig::weights::WeightInfo for WeightInf // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 17_140 nanoseconds. - Weight::from_parts(20_613_290, 0) - // Standard Error: 23 - .saturating_add(Weight::from_parts(989, 0).saturating_mul(z.into())) + // Minimum execution time: 23_740 nanoseconds. + Weight::from_parts(33_203_659, 0) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_068, 0).saturating_mul(z.into())) } - /// Storage: Multisig Multisigs (r:1 w:1) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `373 + s * (1 ±0)` - // Estimated: `5825` - // Minimum execution time: 48_190 nanoseconds. - Weight::from_parts(55_141_032, 5825) - // Standard Error: 6_415 - .saturating_add(Weight::from_parts(20_531, 0).saturating_mul(s.into())) - // Standard Error: 62 - .saturating_add(Weight::from_parts(2_645, 0).saturating_mul(z.into())) + // Measured: `275 + s * (1 ±0)` + // Estimated: `6815` + // Minimum execution time: 70_790 nanoseconds. + Weight::from_parts(75_902_643, 6815) + // Standard Error: 8_192 + .saturating_add(Weight::from_parts(219_592, 0).saturating_mul(s.into())) + // Standard Error: 80 + .saturating_add(Weight::from_parts(2_091, 0).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) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `317` - // Estimated: `5825` - // Minimum execution time: 35_200 nanoseconds. - Weight::from_parts(34_539_686, 5825) - // Standard Error: 5_214 - .saturating_add(Weight::from_parts(83_803, 0).saturating_mul(s.into())) - // Standard Error: 51 - .saturating_add(Weight::from_parts(2_652, 0).saturating_mul(z.into())) + // Measured: `252` + // Estimated: `6815` + // Minimum execution time: 49_710 nanoseconds. + Weight::from_parts(41_381_547, 6815) + // Standard Error: 6_063 + .saturating_add(Weight::from_parts(306_390, 0).saturating_mul(s.into())) + // Standard Error: 59 + .saturating_add(Weight::from_parts(2_114, 0).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) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `459 + s * (33 ±0)` - // Estimated: `8432` - // Minimum execution time: 55_860 nanoseconds. - Weight::from_parts(56_804_266, 8432) - // Standard Error: 7_150 - .saturating_add(Weight::from_parts(95_888, 0).saturating_mul(s.into())) - // Standard Error: 70 - .saturating_add(Weight::from_parts(2_628, 0).saturating_mul(z.into())) + // Measured: `362 + s * (33 ±0)` + // Estimated: `6815` + // Minimum execution time: 84_521 nanoseconds. + Weight::from_parts(86_035_413, 6815) + // Standard Error: 6_863 + .saturating_add(Weight::from_parts(285_220, 0).saturating_mul(s.into())) + // Standard Error: 67 + .saturating_add(Weight::from_parts(2_030, 0).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) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `377 + s * (1 ±0)` - // Estimated: `5825` - // Minimum execution time: 38_691 nanoseconds. - Weight::from_parts(50_725_622, 5825) - // Standard Error: 6_195 - .saturating_add(Weight::from_parts(48_095, 0).saturating_mul(s.into())) + // Measured: `279 + s * (1 ±0)` + // Estimated: `6815` + // Minimum execution time: 53_560 nanoseconds. + Weight::from_parts(68_219_543, 6815) + // Standard Error: 8_990 + .saturating_add(Weight::from_parts(280_934, 0).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) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `317` - // Estimated: `5825` - // Minimum execution time: 26_740 nanoseconds. - Weight::from_parts(32_958_938, 5825) - // Standard Error: 4_854 - .saturating_add(Weight::from_parts(77_200, 0).saturating_mul(s.into())) + // Measured: `252` + // Estimated: `6815` + // Minimum execution time: 37_020 nanoseconds. + Weight::from_parts(43_487_688, 6815) + // Standard Error: 6_367 + .saturating_add(Weight::from_parts(160_508, 0).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) - /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3350), added: 5825, mode: MaxEncodedLen) + /// Storage: `Multisig::Multisigs` (r:1 w:1) + /// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3350), added: 5825, mode: `MaxEncodedLen`) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `525 + s * (1 ±0)` - // Estimated: `5825` - // Minimum execution time: 41_640 nanoseconds. - Weight::from_parts(51_559_888, 5825) - // Standard Error: 7_083 - .saturating_add(Weight::from_parts(65_557, 0).saturating_mul(s.into())) + // Measured: `428 + s * (1 ±0)` + // Estimated: `6815` + // Minimum execution time: 62_651 nanoseconds. + Weight::from_parts(68_545_202, 6815) + // Standard Error: 8_112 + .saturating_add(Weight::from_parts(200_729, 0).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 788b12083..705889f4a 100644 --- a/runtime/common/src/weights/pallet_parachain_staking.rs +++ b/runtime/common/src/weights/pallet_parachain_staking.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_parachain_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,820 +52,830 @@ use frame_support::{ /// Weight functions for pallet_parachain_staking (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_parachain_staking::weights::WeightInfo for WeightInfo { - /// Storage: ParachainStaking InflationConfig (r:1 w:1) - /// Proof Skipped: ParachainStaking InflationConfig (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::InflationConfig` (r:1 w:1) + /// Proof: `ParachainStaking::InflationConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_staking_expectations() -> Weight { // Proof Size summary in bytes: // Measured: `88` // Estimated: `1573` - // Minimum execution time: 15_889_000 picoseconds. - Weight::from_parts(16_404_000, 1573) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 20_920 nanoseconds. + Weight::from_parts(22_131_000, 1573) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ParachainStaking InflationConfig (r:1 w:1) - /// Proof Skipped: ParachainStaking InflationConfig (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::InflationConfig` (r:1 w:1) + /// Proof: `ParachainStaking::InflationConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_inflation() -> Weight { // Proof Size summary in bytes: // Measured: `88` // Estimated: `1573` - // Minimum execution time: 44_509_000 picoseconds. - Weight::from_parts(45_011_000, 1573) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 66_631 nanoseconds. + Weight::from_parts(70_110_000, 1573) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ParachainStaking ParachainBondInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking ParachainBondInfo (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::ParachainBondInfo` (r:1 w:1) + /// Proof: `ParachainStaking::ParachainBondInfo` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_parachain_bond_account() -> Weight { // Proof Size summary in bytes: - // Measured: `6` - // Estimated: `1491` - // Minimum execution time: 14_675_000 picoseconds. - Weight::from_parts(15_094_000, 1491) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `21` + // Estimated: `1506` + // Minimum execution time: 17_950 nanoseconds. + Weight::from_parts(22_380_000, 1506) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ParachainStaking ParachainBondInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking ParachainBondInfo (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::ParachainBondInfo` (r:1 w:1) + /// Proof: `ParachainStaking::ParachainBondInfo` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_parachain_bond_reserve_percent() -> Weight { // Proof Size summary in bytes: - // Measured: `6` - // Estimated: `1491` - // Minimum execution time: 13_898_000 picoseconds. - Weight::from_parts(14_492_000, 1491) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `21` + // Estimated: `1506` + // Minimum execution time: 21_690 nanoseconds. + Weight::from_parts(22_390_000, 1506) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ParachainStaking TotalSelected (r:1 w:1) - /// Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::TotalSelected` (r:1 w:1) + /// Proof: `ParachainStaking::TotalSelected` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_total_selected() -> Weight { // Proof Size summary in bytes: // Measured: `28` // Estimated: `1513` - // Minimum execution time: 15_666_000 picoseconds. - Weight::from_parts(15_939_000, 1513) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 21_490 nanoseconds. + Weight::from_parts(24_350_000, 1513) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: ParachainStaking CollatorCommission (r:1 w:1) - /// Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::CollatorCommission` (r:1 w:1) + /// Proof: `ParachainStaking::CollatorCommission` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_collator_commission() -> Weight { // Proof Size summary in bytes: // Measured: `27` // Estimated: `1512` - // Minimum execution time: 13_997_000 picoseconds. - Weight::from_parts(14_320_000, 1512) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: ParachainStaking TotalSelected (r:1 w:0) - /// Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking InflationConfig (r:1 w:1) - /// Proof Skipped: ParachainStaking InflationConfig (max_values: Some(1), max_size: None, mode: Measured) + // Minimum execution time: 19_440 nanoseconds. + Weight::from_parts(21_970_000, 1512) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ParachainStaking::TotalSelected` (r:1 w:0) + /// Proof: `ParachainStaking::TotalSelected` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::InflationConfig` (r:1 w:1) + /// Proof: `ParachainStaking::InflationConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_blocks_per_round() -> Weight { // Proof Size summary in bytes: // Measured: `116` // Estimated: `1601` - // Minimum execution time: 48_389_000 picoseconds. - Weight::from_parts(49_554_000, 1601) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegatorState (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:0 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:0 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) + // Minimum execution time: 86_860 nanoseconds. + Weight::from_parts(87_851_000, 1601) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:0) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:0 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:0 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[3, 200]`. fn join_candidates(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1421 + x * (38 ±0)` - // Estimated: `4752 + x * (41 ±0)` - // Minimum execution time: 76_742_000 picoseconds. - Weight::from_parts(88_864_511, 4752) - // Standard Error: 2_004 - .saturating_add(Weight::from_parts(88_538, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - .saturating_add(Weight::from_parts(0, 41).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `1212 + x * (52 ±0)` + // Estimated: `4764 + x * (53 ±0)` + // Minimum execution time: 94_680 nanoseconds. + Weight::from_parts(129_865_953, 4764) + // Standard Error: 7_461 + .saturating_add(Weight::from_parts(293_951, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(Weight::from_parts(0, 53).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[3, 200]`. fn schedule_leave_candidates(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `702 + x * (37 ±0)` - // Estimated: `4060 + x * (38 ±0)` - // Minimum execution time: 27_238_000 picoseconds. - Weight::from_parts(34_109_750, 4060) - // Standard Error: 1_116 - .saturating_add(Weight::from_parts(62_292, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 38).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegatorState (r:349 w:349) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:350 w:350) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:350 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:350 w:350) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `769 + x * (49 ±0)` + // Estimated: `4109 + x * (50 ±0)` + // Minimum execution time: 32_620 nanoseconds. + Weight::from_parts(54_251_947, 4109) + // Standard Error: 5_751 + .saturating_add(Weight::from_parts(273_039, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegatorState` (r:349 w:349) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:350 w:350) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:350 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:350 w:350) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[2, 350]`. fn execute_leave_candidates_worst_case(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1157 + x * (431 ±0)` - // Estimated: `4696 + x * (3762 ±0)` - // Minimum execution time: 141_946_000 picoseconds. - Weight::from_parts(144_961_000, 4696) - // Standard Error: 79_832 - .saturating_add(Weight::from_parts(49_060_154, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `283 + x * (530 ±0)` + // Estimated: `4888 + x * (3774 ±0)` + // Minimum execution time: 147_651 nanoseconds. + Weight::from_parts(181_751_000, 4888) + // Standard Error: 291_873 + .saturating_add(Weight::from_parts(76_847_404, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 3762).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegatorState (r:349 w:349) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:350 w:350) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:350 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:350 w:350) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 3774).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegatorState` (r:349 w:349) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:350 w:350) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:350 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:350 w:350) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[2, 350]`. /// The range of component `y` is `[2, 350]`. fn execute_leave_candidates_ideal(x: u32, _y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1149 + x * (431 ±0)` - // Estimated: `4696 + x * (3762 ±0)` - // Minimum execution time: 133_121_000 picoseconds. - Weight::from_parts(134_388_000, 4696) - // Standard Error: 34_256 - .saturating_add(Weight::from_parts(50_828_386, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Measured: `277 + x * (531 ±0)` + // Estimated: `4888 + x * (3774 ±0)` + // Minimum execution time: 187_621 nanoseconds. + Weight::from_parts(202_610_000, 4888) + // Standard Error: 155_800 + .saturating_add(Weight::from_parts(80_277_630, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 3762).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 3774).saturating_mul(x.into())) } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[3, 200]`. fn cancel_leave_candidates(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `670 + x * (37 ±0)` - // Estimated: `4028 + x * (38 ±0)` - // Minimum execution time: 25_910_000 picoseconds. - Weight::from_parts(32_465_127, 4028) - // Standard Error: 1_064 - .saturating_add(Weight::from_parts(60_655, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 38).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `725 + x * (49 ±0)` + // Estimated: `4065 + x * (50 ±0)` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(58_253_070, 4065) + // Standard Error: 6_431 + .saturating_add(Weight::from_parts(249_533, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 200]`. fn go_offline(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `567 + x * (38 ±0)` - // Estimated: `3968 + x * (39 ±0)` - // Minimum execution time: 24_471_000 picoseconds. - Weight::from_parts(30_875_133, 3968) - // Standard Error: 1_124 - .saturating_add(Weight::from_parts(66_032, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 39).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `638 + x * (49 ±0)` + // Estimated: `4024 + x * (50 ±0)` + // Minimum execution time: 28_620 nanoseconds. + Weight::from_parts(47_266_699, 4024) + // Standard Error: 5_762 + .saturating_add(Weight::from_parts(268_069, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 200]`. fn go_online(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `531 + x * (38 ±0)` - // Estimated: `3932 + x * (39 ±0)` - // Minimum execution time: 24_249_000 picoseconds. - Weight::from_parts(30_765_292, 3932) - // Standard Error: 1_181 - .saturating_add(Weight::from_parts(65_935, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 39).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Measured: `590 + x * (49 ±0)` + // Estimated: `3976 + x * (50 ±0)` + // Minimum execution time: 32_720 nanoseconds. + Weight::from_parts(48_255_063, 3976) + // Standard Error: 6_033 + .saturating_add(Weight::from_parts(271_498, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 50).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 200]`. fn candidate_bond_more(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1270 + x * (42 ±0)` - // Estimated: `4752 + x * (44 ±0)` - // Minimum execution time: 68_720_000 picoseconds. - Weight::from_parts(79_722_709, 4752) - // Standard Error: 2_059 - .saturating_add(Weight::from_parts(113_832, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) + // Measured: `1522 + x * (52 ±0)` + // Estimated: `4764 + x * (54 ±0)` + // Minimum execution time: 72_710 nanoseconds. + Weight::from_parts(113_926_751, 4764) + // Standard Error: 8_405 + .saturating_add(Weight::from_parts(297_196, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(Weight::from_parts(0, 54).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) fn schedule_candidate_bond_less() -> Weight { // Proof Size summary in bytes: - // Measured: `171` - // Estimated: `3636` - // Minimum execution time: 21_049_000 picoseconds. - Weight::from_parts(21_735_000, 3636) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) + // Measured: `184` + // Estimated: `3649` + // Minimum execution time: 29_320 nanoseconds. + Weight::from_parts(30_880_000, 3649) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[1, 200]`. fn execute_candidate_bond_less(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1322 + x * (42 ±0)` - // Estimated: `4752 + x * (43 ±0)` - // Minimum execution time: 71_996_000 picoseconds. - Weight::from_parts(80_620_929, 4752) - // Standard Error: 1_363 - .saturating_add(Weight::from_parts(94_580, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) - } - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - fn cancel_candidate_bond_less() -> Weight { - // Proof Size summary in bytes: - // Measured: `191` - // Estimated: `3656` - // Minimum execution time: 18_991_000 picoseconds. - Weight::from_parts(19_491_000, 3656) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } + // Measured: `1538 + x * (52 ±0)` + // Estimated: `4764 + x * (54 ±0)` + // Minimum execution time: 87_930 nanoseconds. + Weight::from_parts(120_669_992, 4764) + // Standard Error: 7_625 + .saturating_add(Weight::from_parts(230_828, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(Weight::from_parts(0, 54).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// The range of component `x` is `[1, 200]`. fn set_candidate_bond_to_zero(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1322 + x * (42 ±0)` - // Estimated: `4752 + x * (43 ±0)` - // Minimum execution time: 71_996_000 picoseconds. - Weight::from_parts(80_620_929, 4752) - // Standard Error: 1_363 - .saturating_add(Weight::from_parts(94_580, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) - } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `1518 + x * (52 ±0)` + // Estimated: `4764 + x * (54 ±0)` + // Minimum execution time: 69_960 nanoseconds. + Weight::from_parts(106_259_917, 4764) + // Standard Error: 8_305 + .saturating_add(Weight::from_parts(269_671, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(Weight::from_parts(0, 54).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn cancel_candidate_bond_less() -> Weight { + // Proof Size summary in bytes: + // Measured: `204` + // Estimated: `3669` + // Minimum execution time: 26_380 nanoseconds. + Weight::from_parts(31_890_000, 3669) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[3, 100]`. /// The range of component `y` is `[2, 300]`. fn delegate(x: u32, y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2479 + x * (79 ±0) + y * (38 ±0)` - // Estimated: `5723 + x * (81 ±0) + y * (39 ±0)` - // Minimum execution time: 120_061_000 picoseconds. - Weight::from_parts(111_894_468, 5723) - // Standard Error: 1_320 - .saturating_add(Weight::from_parts(135_446, 0).saturating_mul(x.into())) - // Standard Error: 433 - .saturating_add(Weight::from_parts(41_110, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - .saturating_add(Weight::from_parts(0, 81).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 39).saturating_mul(y.into())) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) + // Measured: `2215 + x * (103 ±0) + y * (52 ±0)` + // Estimated: `5422 + x * (106 ±0) + y * (53 ±0)` + // Minimum execution time: 162_160 nanoseconds. + Weight::from_parts(184_112_627, 5422) + // Standard Error: 15_255 + .saturating_add(Weight::from_parts(329_277, 0).saturating_mul(x.into())) + // Standard Error: 5_004 + .saturating_add(Weight::from_parts(132_709, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(Weight::from_parts(0, 106).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 53).saturating_mul(y.into())) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 349]`. fn schedule_revoke_delegation(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `566 + x * (42 ±0)` - // Estimated: `4012 + x * (43 ±0)` - // Minimum execution time: 25_479_000 picoseconds. - Weight::from_parts(35_344_986, 4012) - // Standard Error: 803 - .saturating_add(Weight::from_parts(60_212, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `688 + x * (54 ±0)` + // Estimated: `4097 + x * (54 ±0)` + // Minimum execution time: 37_670 nanoseconds. + Weight::from_parts(62_885_317, 4097) + // Standard Error: 3_441 + .saturating_add(Weight::from_parts(168_223, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 54).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:0) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 349]`. fn delegator_bond_more(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1996 + x * (79 ±0)` - // Estimated: `5428 + x * (79 ±0)` - // Minimum execution time: 90_985_000 picoseconds. - Weight::from_parts(111_258_553, 5428) - // Standard Error: 1_580 - .saturating_add(Weight::from_parts(109_354, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - .saturating_add(Weight::from_parts(0, 79).saturating_mul(x.into())) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) + // Measured: `2052 + x * (103 ±0)` + // Estimated: `5592 + x * (102 ±0)` + // Minimum execution time: 97_960 nanoseconds. + Weight::from_parts(163_346_210, 5592) + // Standard Error: 8_012 + .saturating_add(Weight::from_parts(371_428, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(Weight::from_parts(0, 102).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 349]`. fn schedule_delegator_bond_less(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `566 + x * (42 ±0)` - // Estimated: `4012 + x * (43 ±0)` - // Minimum execution time: 25_784_000 picoseconds. - Weight::from_parts(35_792_924, 4012) - // Standard Error: 793 - .saturating_add(Weight::from_parts(60_874, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:0) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `688 + x * (54 ±0)` + // Estimated: `4097 + x * (54 ±0)` + // Minimum execution time: 33_520 nanoseconds. + Weight::from_parts(66_292_397, 4097) + // Standard Error: 3_862 + .saturating_add(Weight::from_parts(178_224, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 54).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:0) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn execute_revoke_delegation() -> Weight { // Proof Size summary in bytes: - // Measured: `964` - // Estimated: `4752` - // Minimum execution time: 113_086_000 picoseconds. - Weight::from_parts(115_421_000, 4752) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `1053` + // Estimated: `4764` + // Minimum execution time: 153_161 nanoseconds. + Weight::from_parts(188_110_000, 4764) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn execute_delegator_revoke_delegation_worst() -> Weight { // Proof Size summary in bytes: - // Measured: `37308` - // Estimated: `40773` - // Minimum execution time: 179_325_000 picoseconds. - Weight::from_parts(182_100_000, 40773) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `50108` + // Estimated: `53573` + // Minimum execution time: 326_631 nanoseconds. + Weight::from_parts(360_401_000, 53573) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(10)) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn execute_delegator_bond_less_worst() -> Weight { // Proof Size summary in bytes: - // Measured: `29930` - // Estimated: `33395` - // Minimum execution time: 150_818_000 picoseconds. - Weight::from_parts(152_294_000, 33395) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(9_u64)) - } - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) + // Measured: `38517` + // Estimated: `41982` + // Minimum execution time: 276_161 nanoseconds. + Weight::from_parts(318_081_000, 41982) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(9)) + } + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 349]`. fn cancel_delegation_request(x: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `663 + x * (42 ±0)` - // Estimated: `4092 + x * (43 ±0)` - // Minimum execution time: 30_062_000 picoseconds. - Weight::from_parts(37_242_991, 4092) - // Standard Error: 767 - .saturating_add(Weight::from_parts(62_995, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 43).saturating_mul(x.into())) - } - /// Storage: ParachainStaking Points (r:1 w:0) - /// Proof Skipped: ParachainStaking Points (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking Staked (r:1 w:1) - /// Proof Skipped: ParachainStaking Staked (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking InflationConfig (r:1 w:0) - /// Proof Skipped: ParachainStaking InflationConfig (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking ParachainBondInfo (r:1 w:0) - /// Proof Skipped: ParachainStaking ParachainBondInfo (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking CollatorCommission (r:1 w:0) - /// Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking DelayedPayouts (r:0 w:1) - /// Proof Skipped: ParachainStaking DelayedPayouts (max_values: None, max_size: None, mode: Measured) + // Measured: `728 + x * (54 ±0)` + // Estimated: `4143 + x * (55 ±0)` + // Minimum execution time: 41_060 nanoseconds. + Weight::from_parts(73_879_404, 4143) + // Standard Error: 3_549 + .saturating_add(Weight::from_parts(157_397, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 55).saturating_mul(x.into())) + } + /// Storage: `ParachainStaking::Points` (r:1 w:0) + /// Proof: `ParachainStaking::Points` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Staked` (r:1 w:1) + /// Proof: `ParachainStaking::Staked` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::InflationConfig` (r:1 w:0) + /// Proof: `ParachainStaking::InflationConfig` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::ParachainBondInfo` (r:1 w:0) + /// Proof: `ParachainStaking::ParachainBondInfo` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CollatorCommission` (r:1 w:0) + /// Proof: `ParachainStaking::CollatorCommission` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelayedPayouts` (r:0 w:1) + /// Proof: `ParachainStaking::DelayedPayouts` (`max_values`: None, `max_size`: None, mode: `Measured`) fn prepare_staking_payouts() -> Weight { // Proof Size summary in bytes: - // Measured: `380` - // Estimated: `3845` - // Minimum execution time: 48_260_000 picoseconds. - Weight::from_parts(49_856_000, 3845) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:0) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) + // Measured: `344` + // Estimated: `3809` + // Minimum execution time: 65_741 nanoseconds. + Weight::from_parts(80_170_000, 3809) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:0) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:0) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `y` is `[0, 100]`. fn get_rewardable_delegators(y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `73 + y * (36 ±0)` - // Estimated: `3537 + y * (36 ±0)` - // Minimum execution time: 8_183_000 picoseconds. - Weight::from_parts(10_416_160, 3537) - // Standard Error: 780 - .saturating_add(Weight::from_parts(44_865, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(y.into())) - } - /// Storage: ParachainStaking TotalSelected (r:1 w:0) - /// Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:0) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:51 w:0) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:51 w:0) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:51 w:0) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:51 w:0) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking SelectedCandidates (r:0 w:1) - /// Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking AtStake (r:0 w:51) - /// Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) + // Measured: `86 + y * (48 ±0)` + // Estimated: `3550 + y * (48 ±0)` + // Minimum execution time: 9_040 nanoseconds. + Weight::from_parts(14_932_628, 3550) + // Standard Error: 2_867 + .saturating_add(Weight::from_parts(188_808, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(Weight::from_parts(0, 48).saturating_mul(y.into())) + } + /// Storage: `ParachainStaking::TotalSelected` (r:1 w:0) + /// Proof: `ParachainStaking::TotalSelected` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:0) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:51 w:0) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:51 w:0) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:51 w:0) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:51 w:0) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::SelectedCandidates` (r:0 w:1) + /// Proof: `ParachainStaking::SelectedCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AtStake` (r:0 w:51) + /// Proof: `ParachainStaking::AtStake` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 50]`. /// The range of component `y` is `[0, 100]`. fn select_top_candidates(x: u32, y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (3816 ±0) + y * (1800 ±0)` - // Estimated: `3730 + x * (3975 ±39) + y * (639 ±19)` - // Minimum execution time: 31_870_000 picoseconds. - Weight::from_parts(32_158_000, 3730) - // Standard Error: 51_554 - .saturating_add(Weight::from_parts(22_540_635, 0).saturating_mul(x.into())) - // Standard Error: 25_709 - .saturating_add(Weight::from_parts(957_745, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) + // Measured: `0 + x * (5058 ±0) + y * (2400 ±0)` + // Estimated: `3778 + x * (4440 ±53) + y * (851 ±26)` + // Minimum execution time: 42_360 nanoseconds. + Weight::from_parts(43_100_000, 3778) + // Standard Error: 213_932 + .saturating_add(Weight::from_parts(37_938_792, 0).saturating_mul(x.into())) + // Standard Error: 106_682 + .saturating_add(Weight::from_parts(3_271_060, 0).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_u64)) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 3975).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 639).saturating_mul(y.into())) - } - /// Storage: System Account (r:349 w:349) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegatorState (r:349 w:349) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:349 w:349) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:349 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 4440).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 851).saturating_mul(y.into())) + } + /// Storage: `System::Account` (r:349 w:349) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegatorState` (r:349 w:349) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:0) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:349 w:349) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:349 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 349]`. /// The range of component `y` is `[0, 349]`. /// The range of component `z` is `[0, 349]`. fn pay_one_collator_reward_best(x: u32, y: u32, z: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (395 ±0) + y * (156 ±0) + z * (41 ±0)` - // Estimated: `125757 + x * (2591 ±19) + y * (2234 ±19) + z * (28 ±0)` - // Minimum execution time: 459_000 picoseconds. - Weight::from_parts(472_000, 125757) - // Standard Error: 685_607 - .saturating_add(Weight::from_parts(74_007_162, 0).saturating_mul(x.into())) - // Standard Error: 685_607 - .saturating_add(Weight::from_parts(43_825_857, 0).saturating_mul(y.into())) + // Measured: `0 + x * (483 ±0) + y * (206 ±0) + z * (53 ±0)` + // Estimated: `151958 + x * (2607 ±2) + y * (2241 ±2) + z * (37 ±1)` + // Minimum execution time: 650 nanoseconds. + Weight::from_parts(710_000, 151958) + // Standard Error: 1_305_281 + .saturating_add(Weight::from_parts(117_137_166, 0).saturating_mul(x.into())) + // Standard Error: 1_305_281 + .saturating_add(Weight::from_parts(68_635_248, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2591).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2234).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 28).saturating_mul(z.into())) - } - /// Storage: ParachainStaking DelayedPayouts (r:1 w:0) - /// Proof Skipped: ParachainStaking DelayedPayouts (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking Points (r:1 w:0) - /// Proof Skipped: ParachainStaking Points (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AtStake (r:2 w:1) - /// Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AwardedPts (r:1 w:1) - /// Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: MoonbeamOrbiters OrbiterPerRound (r:1 w:0) - /// Proof Skipped: MoonbeamOrbiters OrbiterPerRound (max_values: None, max_size: None, mode: Measured) - /// Storage: System Account (r:301 w:301) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 2607).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2241).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(z.into())) + } + /// Storage: `ParachainStaking::DelayedPayouts` (r:1 w:0) + /// Proof: `ParachainStaking::DelayedPayouts` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Points` (r:1 w:0) + /// Proof: `ParachainStaking::Points` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AtStake` (r:2 w:1) + /// Proof: `ParachainStaking::AtStake` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AwardedPts` (r:1 w:1) + /// Proof: `ParachainStaking::AwardedPts` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:0) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:301 w:301) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `y` is `[0, 300]`. fn pay_one_collator_reward(y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1208 + y * (160 ±0)` - // Estimated: `6978 + y * (2591 ±0)` - // Minimum execution time: 65_428_000 picoseconds. - Weight::from_parts(68_535_135, 6978) - // Standard Error: 6_093 - .saturating_add(Weight::from_parts(25_186_464, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `389 + y * (187 ±0)` + // Estimated: `6323 + y * (2607 ±0)` + // Minimum execution time: 95_210 nanoseconds. + Weight::from_parts(46_188_313, 6323) + // Standard Error: 130_487 + .saturating_add(Weight::from_parts(32_991_381, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2591).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 2607).saturating_mul(y.into())) } fn base_on_initialize() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_024_000 picoseconds. - Weight::from_parts(2_168_000, 0) + // Minimum execution time: 2_400 nanoseconds. + Weight::from_parts(2_630_000, 0) } - /// Storage: ParachainStaking DelegatorState (r:1 w:0) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:0) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 300]`. /// The range of component `y` is `[0, 100]`. fn set_auto_compound(x: u32, y: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `671 + x * (22 ±0) + y * (36 ±0)` - // Estimated: `4027 + x * (23 ±0) + y * (36 ±0)` - // Minimum execution time: 34_494_000 picoseconds. - Weight::from_parts(33_677_881, 4027) - // Standard Error: 278 - .saturating_add(Weight::from_parts(45_734, 0).saturating_mul(x.into())) - // Standard Error: 833 - .saturating_add(Weight::from_parts(39_753, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 23).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(y.into())) - } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegatorState (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:1 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `655 + x * (34 ±0) + y * (48 ±0)` + // Estimated: `3997 + x * (35 ±0) + y * (49 ±0)` + // Minimum execution time: 64_941 nanoseconds. + Weight::from_parts(68_368_754, 3997) + // Standard Error: 2_390 + .saturating_add(Weight::from_parts(117_516, 0).saturating_mul(x.into())) + // Standard Error: 7_155 + .saturating_add(Weight::from_parts(96_794, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 35).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 49).saturating_mul(y.into())) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegatorState` (r:1 w:1) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `x` is `[0, 350]`. /// The range of component `y` is `[0, 349]`. /// The range of component `z` is `[0, 99]`. fn delegate_with_auto_compound(x: u32, y: u32, z: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (60 ±0) + y * (21 ±0) + z * (78 ±0)` - // Estimated: `26253 + x * (44 ±0) + y * (19 ±0) + z * (76 ±1)` - // Minimum execution time: 130_103_000 picoseconds. - Weight::from_parts(116_616_415, 26253) - // Standard Error: 1_141 - .saturating_add(Weight::from_parts(117_041, 0).saturating_mul(x.into())) - // Standard Error: 4_030 - .saturating_add(Weight::from_parts(178_483, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 44).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 19).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 76).saturating_mul(z.into())) - } - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegatorState (r:2 w:2) - /// Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AutoCompoundingDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking AutoCompoundingDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking TopDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking TopDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking BottomDelegations (r:1 w:1) - /// Proof Skipped: ParachainStaking BottomDelegations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Locks (r:2 w:2) - /// Proof: Balances Locks (max_values: None, max_size: Some(1287), added: 3762, mode: MaxEncodedLen) - /// Storage: Balances Freezes (r:2 w:0) - /// Proof: Balances Freezes (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - /// Storage: ParachainStaking DelegationScheduledRequests (r:1 w:1) - /// Proof Skipped: ParachainStaking DelegationScheduledRequests (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking Total (r:1 w:1) - /// Proof Skipped: ParachainStaking Total (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `0 + x * (84 ±0) + y * (33 ±0) + z * (114 ±0)` + // Estimated: `34219 + x * (61 ±0) + y * (31 ±0) + z * (105 ±1)` + // Minimum execution time: 188_241 nanoseconds. + Weight::from_parts(167_789_565, 34219) + // Standard Error: 5_366 + .saturating_add(Weight::from_parts(290_539, 0).saturating_mul(x.into())) + // Standard Error: 5_380 + .saturating_add(Weight::from_parts(46_897, 0).saturating_mul(y.into())) + // Standard Error: 18_948 + .saturating_add(Weight::from_parts(324_903, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(Weight::from_parts(0, 61).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 31).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 105).saturating_mul(z.into())) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegatorState` (r:2 w:2) + /// Proof: `ParachainStaking::DelegatorState` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AutoCompoundingDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::AutoCompoundingDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TopDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::TopDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::BottomDelegations` (r:1 w:1) + /// Proof: `ParachainStaking::BottomDelegations` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Locks` (r:2 w:2) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:2 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `ParachainStaking::DelegationScheduledRequests` (r:1 w:1) + /// Proof: `ParachainStaking::DelegationScheduledRequests` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::Total` (r:1 w:1) + /// Proof: `ParachainStaking::Total` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn delegate_with_auto_compound_worst() -> Weight { // Proof Size summary in bytes: - // Measured: `48167` - // Estimated: `54107` - // Minimum execution time: 276_584_000 picoseconds. - Weight::from_parts(279_594_000, 54107) - .saturating_add(T::DbWeight::get().reads(15_u64)) - .saturating_add(T::DbWeight::get().writes(13_u64)) + // Measured: `63204` + // Estimated: `69144` + // Minimum execution time: 467_031 nanoseconds. + Weight::from_parts(515_911_000, 69144) + .saturating_add(T::DbWeight::get().reads(15)) + .saturating_add(T::DbWeight::get().writes(13)) } - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn mint_collator_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `128` - // Estimated: `3581` - // Minimum execution time: 28_741_000 picoseconds. - Weight::from_parts(29_344_000, 3581) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: ParachainStaking EnableMarkingOffline (r:1 w:0) - /// Proof Skipped: ParachainStaking EnableMarkingOffline (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking TotalSelected (r:1 w:0) - /// Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking SelectedCandidates (r:1 w:0) - /// Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: ParachainStaking AtStake (r:2 w:0) - /// Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking AwardedPts (r:2 w:0) - /// Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - /// Storage: MoonbeamOrbiters OrbiterPerRound (r:1 w:0) - /// Proof Skipped: MoonbeamOrbiters OrbiterPerRound (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidateInfo (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidateInfo (max_values: None, max_size: None, mode: Measured) - /// Storage: ParachainStaking CandidatePool (r:1 w:1) - /// Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) + // Measured: `107` + // Estimated: `3597` + // Minimum execution time: 33_540 nanoseconds. + Weight::from_parts(34_680_000, 3597) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ParachainStaking::EnableMarkingOffline` (r:1 w:0) + /// Proof: `ParachainStaking::EnableMarkingOffline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::TotalSelected` (r:1 w:0) + /// Proof: `ParachainStaking::TotalSelected` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::SelectedCandidates` (r:1 w:0) + /// Proof: `ParachainStaking::SelectedCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AtStake` (r:1 w:0) + /// Proof: `ParachainStaking::AtStake` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::AwardedPts` (r:1 w:0) + /// Proof: `ParachainStaking::AwardedPts` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidateInfo` (r:1 w:1) + /// Proof: `ParachainStaking::CandidateInfo` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainStaking::CandidatePool` (r:1 w:1) + /// Proof: `ParachainStaking::CandidatePool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn notify_inactive_collator() -> Weight { // Proof Size summary in bytes: - // Measured: `11494` - // Estimated: `17434` - // Minimum execution time: 41_130_000 picoseconds. - Weight::from_parts(41_130_000, 0) - .saturating_add(Weight::from_parts(0, 17434)) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `14976` + // Estimated: `18441` + // Minimum execution time: 123_950 nanoseconds. + Weight::from_parts(154_121_000, 18441) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) } } diff --git a/runtime/common/src/weights/pallet_preimage.rs b/runtime/common/src/weights/pallet_preimage.rs index 8fedc5045..873dd954a 100644 --- a/runtime/common/src/weights/pallet_preimage.rs +++ b/runtime/common/src/weights/pallet_preimage.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_preimage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,156 +52,156 @@ use frame_support::{ /// Weight functions for pallet_preimage (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_preimage::weights::WeightInfo for WeightInfo { - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `179` - // Estimated: `2566` - // Minimum execution time: 46_570 nanoseconds. - Weight::from_parts(47_640_000, 2566) - // Standard Error: 4 - .saturating_add(Weight::from_parts(2_961, 0).saturating_mul(s.into())) + // Measured: `147` + // Estimated: `3556` + // Minimum execution time: 57_781 nanoseconds. + Weight::from_parts(58_050_000, 3556) + // Standard Error: 3 + .saturating_add(Weight::from_parts(2_854, 0).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) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 25_630 nanoseconds. - Weight::from_parts(27_760_000, 2566) + // Estimated: `3556` + // Minimum execution time: 32_980 nanoseconds. + Weight::from_parts(33_530_000, 3556) // Standard Error: 4 - .saturating_add(Weight::from_parts(2_967, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(2_819, 0).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) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32) -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 24_550 nanoseconds. - Weight::from_parts(27_741_000, 2566) + // Estimated: `3556` + // Minimum execution time: 36_560 nanoseconds. + Weight::from_parts(37_361_000, 3556) // Standard Error: 4 - .saturating_add(Weight::from_parts(2_990, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(2_844, 0).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) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) fn unnote_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `357` - // Estimated: `2566` - // Minimum execution time: 59_490 nanoseconds. - Weight::from_parts(69_030_000, 2566) + // Measured: `293` + // Estimated: `3556` + // Minimum execution time: 88_750 nanoseconds. + Weight::from_parts(91_651_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) fn unnote_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 45_150 nanoseconds. - Weight::from_parts(52_960_000, 2566) + // Estimated: `3556` + // Minimum execution time: 54_850 nanoseconds. + Weight::from_parts(56_380_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn request_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `220` - // Estimated: `2566` - // Minimum execution time: 40_950 nanoseconds. - Weight::from_parts(43_730_000, 2566) + // Measured: `188` + // Estimated: `3556` + // Minimum execution time: 48_240 nanoseconds. + Weight::from_parts(54_141_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn request_no_deposit_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 26_900 nanoseconds. - Weight::from_parts(31_590_000, 2566) + // Estimated: `3556` + // Minimum execution time: 33_901 nanoseconds. + Weight::from_parts(38_760_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn request_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `2566` - // Minimum execution time: 29_690 nanoseconds. - Weight::from_parts(34_591_000, 2566) + // Estimated: `3556` + // Minimum execution time: 42_190 nanoseconds. + Weight::from_parts(43_881_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn request_requested_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_440 nanoseconds. - Weight::from_parts(18_710_000, 2566) + // Estimated: `3556` + // Minimum execution time: 21_480 nanoseconds. + Weight::from_parts(23_090_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - /// Storage: Preimage PreimageFor (r:0 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) + /// Storage: `Preimage::PreimageFor` (r:0 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`) fn unrequest_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `144` - // Estimated: `2566` - // Minimum execution time: 43_490 nanoseconds. - Weight::from_parts(48_550_000, 2566) + // Estimated: `3556` + // Minimum execution time: 53_370 nanoseconds. + Weight::from_parts(62_590_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn unrequest_unnoted_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_000 nanoseconds. - Weight::from_parts(17_720_000, 2566) + // Estimated: `3556` + // Minimum execution time: 22_580 nanoseconds. + Weight::from_parts(23_320_000, 3556) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) fn unrequest_multi_referenced_preimage() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `2566` - // Minimum execution time: 14_260 nanoseconds. - Weight::from_parts(17_310_000, 2566) + // Estimated: `3556` + // Minimum execution time: 22_870 nanoseconds. + Weight::from_parts(24_080_000, 3556) .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 28942d025..0128c6373 100644 --- a/runtime/common/src/weights/pallet_proxy.rs +++ b/runtime/common/src/weights/pallet_proxy.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_proxy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,156 +52,162 @@ use frame_support::{ /// Weight functions for pallet_proxy (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_proxy::weights::WeightInfo for WeightInfo { - /// Storage: Proxy Proxies (r:1 w:0) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:0) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `122 + p * (41 ±0)` - // Estimated: `3844` - // Minimum execution time: 21_120 nanoseconds. - Weight::from_parts(25_838_411, 3844) - // Standard Error: 10_663 - .saturating_add(Weight::from_parts(154_975, 0).saturating_mul(p.into())) + // Measured: `90 + p * (41 ±0)` + // Estimated: `4834` + // Minimum execution time: 24_460 nanoseconds. + Weight::from_parts(31_916_739, 4834) + // Standard Error: 10_449 + .saturating_add(Weight::from_parts(119_468, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } - /// Storage: Proxy Proxies (r:1 w:0) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) - /// Storage: Proxy Announcements (r:1 w:1) - /// Proof: Proxy Announcements (max_values: None, max_size: Some(2361), added: 4836, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:0) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) + /// Storage: `Proxy::Announcements` (r:1 w:1) + /// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2361), added: 4836, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn proxy_announced(a: u32, _p: u32) -> Weight { + fn proxy_announced(a: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `521 + a * (72 ±0) + p * (41 ±0)` - // Estimated: `11287` - // Minimum execution time: 47_870 nanoseconds. - Weight::from_parts(64_203_809, 11287) - // Standard Error: 16_966 - .saturating_add(Weight::from_parts(103_726, 0).saturating_mul(a.into())) + // Measured: `425 + a * (72 ±0) + p * (41 ±0)` + // Estimated: `5826` + // Minimum execution time: 59_630 nanoseconds. + Weight::from_parts(68_853_256, 5826) + // Standard Error: 14_552 + .saturating_add(Weight::from_parts(556_375, 0).saturating_mul(a.into())) + // Standard Error: 15_035 + .saturating_add(Weight::from_parts(200_681, 0).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) - /// Proof: Proxy Announcements (max_values: None, max_size: Some(2361), added: 4836, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Proxy::Announcements` (r:1 w:1) + /// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2361), added: 4836, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn remove_announcement(a: u32, _p: u32) -> Weight { + fn remove_announcement(a: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `404 + a * (72 ±0)` - // Estimated: `7443` - // Minimum execution time: 28_880 nanoseconds. - Weight::from_parts(39_031_523, 7443) - // Standard Error: 11_187 - .saturating_add(Weight::from_parts(148_230, 0).saturating_mul(a.into())) + // Measured: `340 + a * (72 ±0)` + // Estimated: `5826` + // Minimum execution time: 39_230 nanoseconds. + Weight::from_parts(47_915_752, 5826) + // Standard Error: 11_282 + .saturating_add(Weight::from_parts(370_639, 0).saturating_mul(a.into())) + // Standard Error: 11_656 + .saturating_add(Weight::from_parts(89_877, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Proxy Announcements (r:1 w:1) - /// Proof: Proxy Announcements (max_values: None, max_size: Some(2361), added: 4836, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Proxy::Announcements` (r:1 w:1) + /// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2361), added: 4836, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn reject_announcement(a: u32, _p: u32) -> Weight { + fn reject_announcement(a: u32, p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `404 + a * (72 ±0)` - // Estimated: `7443` - // Minimum execution time: 27_891 nanoseconds. - Weight::from_parts(39_270_464, 7443) - // Standard Error: 12_225 - .saturating_add(Weight::from_parts(160_797, 0).saturating_mul(a.into())) + // Measured: `340 + a * (72 ±0)` + // Estimated: `5826` + // Minimum execution time: 39_380 nanoseconds. + Weight::from_parts(50_472_779, 5826) + // Standard Error: 10_655 + .saturating_add(Weight::from_parts(341_751, 0).saturating_mul(a.into())) + // Standard Error: 11_009 + .saturating_add(Weight::from_parts(1_588, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Proxy Proxies (r:1 w:0) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) - /// Storage: Proxy Announcements (r:1 w:1) - /// Proof: Proxy Announcements (max_values: None, max_size: Some(2361), added: 4836, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:0) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) + /// Storage: `Proxy::Announcements` (r:1 w:1) + /// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2361), added: 4836, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn announce(a: u32, p: u32) -> Weight { + fn announce(a: u32, _p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `449 + a * (72 ±0) + p * (41 ±0)` - // Estimated: `11287` - // Minimum execution time: 40_190 nanoseconds. - Weight::from_parts(49_900_553, 11287) - // Standard Error: 16_800 - .saturating_add(Weight::from_parts(219_080, 0).saturating_mul(a.into())) - // Standard Error: 17_358 - .saturating_add(Weight::from_parts(146_779, 0).saturating_mul(p.into())) + // Measured: `353 + a * (72 ±0) + p * (41 ±0)` + // Estimated: `5826` + // Minimum execution time: 54_760 nanoseconds. + Weight::from_parts(76_162_735, 5826) + // Standard Error: 17_467 + .saturating_add(Weight::from_parts(198_517, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Proxy Proxies (r:1 w:1) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:1) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `122 + p * (41 ±0)` - // Estimated: `3844` - // Minimum execution time: 29_420 nanoseconds. - Weight::from_parts(39_127_927, 3844) - // Standard Error: 12_097 - .saturating_add(Weight::from_parts(129_823, 0).saturating_mul(p.into())) + // Measured: `90 + p * (41 ±0)` + // Estimated: `4834` + // Minimum execution time: 38_410 nanoseconds. + Weight::from_parts(51_454_716, 4834) + // Standard Error: 18_577 + .saturating_add(Weight::from_parts(108_813, 0).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) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:1) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `122 + p * (41 ±0)` - // Estimated: `3844` - // Minimum execution time: 29_990 nanoseconds. - Weight::from_parts(40_424_160, 3844) - // Standard Error: 11_438 - .saturating_add(Weight::from_parts(50_007, 0).saturating_mul(p.into())) + // Measured: `90 + p * (41 ±0)` + // Estimated: `4834` + // Minimum execution time: 39_900 nanoseconds. + Weight::from_parts(49_203_091, 4834) + // Standard Error: 14_073 + .saturating_add(Weight::from_parts(142_433, 0).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) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:1) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `122 + p * (41 ±0)` - // Estimated: `3844` - // Minimum execution time: 23_350 nanoseconds. - Weight::from_parts(31_893_850, 3844) - // Standard Error: 10_014 - .saturating_add(Weight::from_parts(18_034, 0).saturating_mul(p.into())) + // Measured: `90 + p * (41 ±0)` + // Estimated: `4834` + // Minimum execution time: 35_010 nanoseconds. + Weight::from_parts(44_812_883, 4834) + // Standard Error: 16_380 + .saturating_add(Weight::from_parts(230_872, 0).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) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:1) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[1, 31]`. fn create_pure(_p: u32) -> Weight { // Proof Size summary in bytes: // Measured: `102` - // Estimated: `3844` - // Minimum execution time: 31_170 nanoseconds. - Weight::from_parts(41_446_203, 3844) + // Estimated: `4834` + // Minimum execution time: 40_930 nanoseconds. + Weight::from_parts(55_446_660, 4834) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Proxy Proxies (r:1 w:1) - /// Proof: Proxy Proxies (max_values: None, max_size: Some(1369), added: 3844, mode: MaxEncodedLen) + /// Storage: `Proxy::Proxies` (r:1 w:1) + /// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1369), added: 3844, mode: `MaxEncodedLen`) /// The range of component `p` is `[0, 30]`. - fn kill_pure(_p: u32) -> Weight { + fn kill_pure(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `163 + p * (41 ±0)` - // Estimated: `3844` - // Minimum execution time: 25_500 nanoseconds. - Weight::from_parts(34_599_406, 3844) + // Measured: `131 + p * (41 ±0)` + // Estimated: `4834` + // Minimum execution time: 35_620 nanoseconds. + Weight::from_parts(47_395_705, 4834) + // Standard Error: 20_099 + .saturating_add(Weight::from_parts(283_385, 0).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 1f38b550c..8e2c4c2db 100644 --- a/runtime/common/src/weights/pallet_scheduler.rs +++ b/runtime/common/src/weights/pallet_scheduler.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_scheduler //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,28 +52,28 @@ use frame_support::{ /// Weight functions for pallet_scheduler (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_scheduler::weights::WeightInfo for WeightInfo { - /// Storage: Scheduler IncompleteSince (r:1 w:1) - /// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: `Scheduler::IncompleteSince` (r:1 w:1) + /// Proof: `Scheduler::IncompleteSince` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) fn service_agendas_base() -> Weight { // Proof Size summary in bytes: // Measured: `35` - // Estimated: `503` - // Minimum execution time: 6_220 nanoseconds. - Weight::from_parts(6_910_000, 503) + // Estimated: `1493` + // Minimum execution time: 8_110 nanoseconds. + Weight::from_parts(9_030_000, 1493) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Scheduler Agenda (r:1 w:1) - /// Proof: Scheduler Agenda (max_values: None, max_size: Some(10667), added: 13142, mode: MaxEncodedLen) - /// The range of component `s` is `[0, 50]`. + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(109074), added: 111549, mode: `MaxEncodedLen`) + /// The range of component `s` is `[0, 512]`. fn service_agenda_base(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `114 + s * (181 ±0)` - // Estimated: `13142` - // Minimum execution time: 5_390 nanoseconds. - Weight::from_parts(15_743_204, 13142) - // Standard Error: 9_341 - .saturating_add(Weight::from_parts(563_979, 0).saturating_mul(s.into())) + // Measured: `85 + s * (181 ±0)` + // Estimated: `112539` + // Minimum execution time: 7_470 nanoseconds. + Weight::from_parts(11_212_129, 112539) + // Standard Error: 3_304 + .saturating_add(Weight::from_parts(800_049, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -81,115 +81,115 @@ impl pallet_scheduler::weights::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_580 nanoseconds. - Weight::from_parts(7_830_000, 0) + // Minimum execution time: 10_490 nanoseconds. + Weight::from_parts(11_100_000, 0) } - /// Storage: Preimage PreimageFor (r:1 w:1) - /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) - /// Storage: Preimage StatusFor (r:1 w:1) - /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: `Preimage::PreimageFor` (r:1 w:1) + /// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `Measured`) + /// Storage: `Preimage::StatusFor` (r:1 w:1) + /// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`) /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `211 + s * (1 ±0)` - // Estimated: `5252 + s * (1 ±0)` - // Minimum execution time: 31_820 nanoseconds. - Weight::from_parts(32_290_000, 5252) - // Standard Error: 4 - .saturating_add(Weight::from_parts(2_145, 0).saturating_mul(s.into())) + // Measured: `179 + s * (1 ±0)` + // Estimated: `3644 + s * (1 ±0)` + // Minimum execution time: 40_180 nanoseconds. + Weight::from_parts(40_931_000, 3644) + // Standard Error: 6 + .saturating_add(Weight::from_parts(2_085, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into())) } - /// Storage: Scheduler Lookup (r:0 w:1) - /// Proof: Scheduler Lookup (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: `Scheduler::Lookup` (r:0 w:1) + /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn service_task_named() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_570 nanoseconds. - Weight::from_parts(11_580_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 13_691 nanoseconds. + Weight::from_parts(14_670_000, 0).saturating_add(T::DbWeight::get().writes(1)) } fn service_task_periodic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_180 nanoseconds. - Weight::from_parts(8_610_000, 0) + // Minimum execution time: 12_010 nanoseconds. + Weight::from_parts(13_100_000, 0) } fn execute_dispatch_signed() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_730 nanoseconds. - Weight::from_parts(3_870_000, 0) + // Minimum execution time: 5_730 nanoseconds. + Weight::from_parts(6_090_000, 0) } fn execute_dispatch_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_610 nanoseconds. - Weight::from_parts(3_730_000, 0) + // Minimum execution time: 5_640 nanoseconds. + Weight::from_parts(6_031_000, 0) } - /// Storage: Scheduler Agenda (r:1 w:1) - /// Proof: Scheduler Agenda (max_values: None, max_size: Some(10667), added: 13142, mode: MaxEncodedLen) - /// The range of component `s` is `[0, 49]`. + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(109074), added: 111549, mode: `MaxEncodedLen`) + /// The range of component `s` is `[0, 511]`. fn schedule(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `114 + s * (181 ±0)` - // Estimated: `13142` - // Minimum execution time: 23_370 nanoseconds. - Weight::from_parts(33_098_986, 13142) - // Standard Error: 12_003 - .saturating_add(Weight::from_parts(605_404, 0).saturating_mul(s.into())) + // Measured: `85 + s * (181 ±0)` + // Estimated: `112539` + // Minimum execution time: 25_240 nanoseconds. + Weight::from_parts(42_440_477, 112539) + // Standard Error: 4_722 + .saturating_add(Weight::from_parts(841_906, 0).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) - /// Proof: Scheduler Agenda (max_values: None, max_size: Some(10667), added: 13142, mode: MaxEncodedLen) - /// Storage: Scheduler Lookup (r:0 w:1) - /// Proof: Scheduler Lookup (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) - /// The range of component `s` is `[1, 50]`. + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(109074), added: 111549, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Lookup` (r:0 w:1) + /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// The range of component `s` is `[1, 512]`. fn cancel(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `114 + s * (181 ±0)` - // Estimated: `13142` - // Minimum execution time: 25_350 nanoseconds. - Weight::from_parts(26_437_367, 13142) - // Standard Error: 14_878 - .saturating_add(Weight::from_parts(1_022_676, 0).saturating_mul(s.into())) + // Measured: `85 + s * (181 ±0)` + // Estimated: `112539` + // Minimum execution time: 34_300 nanoseconds. + Weight::from_parts(35_524_030, 112539) + // Standard Error: 4_784 + .saturating_add(Weight::from_parts(1_270_424, 0).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) - /// Proof: Scheduler Lookup (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) - /// Storage: Scheduler Agenda (r:1 w:1) - /// Proof: Scheduler Agenda (max_values: None, max_size: Some(10667), added: 13142, mode: MaxEncodedLen) - /// The range of component `s` is `[0, 49]`. + /// Storage: `Scheduler::Lookup` (r:1 w:1) + /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(109074), added: 111549, mode: `MaxEncodedLen`) + /// The range of component `s` is `[0, 511]`. fn schedule_named(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `297 + s * (189 ±0)` - // Estimated: `15669` - // Minimum execution time: 24_030 nanoseconds. - Weight::from_parts(40_010_187, 15669) - // Standard Error: 15_936 - .saturating_add(Weight::from_parts(699_125, 0).saturating_mul(s.into())) + // Measured: `601 + s * (182 ±0)` + // Estimated: `112539` + // Minimum execution time: 36_031 nanoseconds. + Weight::from_parts(58_246_502, 112539) + // Standard Error: 4_269 + .saturating_add(Weight::from_parts(833_968, 0).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) - /// Proof: Scheduler Lookup (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) - /// Storage: Scheduler Agenda (r:1 w:1) - /// Proof: Scheduler Agenda (max_values: None, max_size: Some(10667), added: 13142, mode: MaxEncodedLen) - /// The range of component `s` is `[1, 50]`. + /// Storage: `Scheduler::Lookup` (r:1 w:1) + /// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Scheduler::Agenda` (r:1 w:1) + /// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(109074), added: 111549, mode: `MaxEncodedLen`) + /// The range of component `s` is `[1, 512]`. fn cancel_named(s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `321 + s * (189 ±0)` - // Estimated: `15669` - // Minimum execution time: 30_030 nanoseconds. - Weight::from_parts(36_715_188, 15669) - // Standard Error: 17_393 - .saturating_add(Weight::from_parts(1_024_734, 0).saturating_mul(s.into())) + // Measured: `717 + s * (181 ±0)` + // Estimated: `112539` + // Minimum execution time: 43_840 nanoseconds. + Weight::from_parts(42_474_452, 112539) + // Standard Error: 5_508 + .saturating_add(Weight::from_parts(1_280_085, 0).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 0e3264b94..fb781d3ef 100644 --- a/runtime/common/src/weights/pallet_timestamp.rs +++ b/runtime/common/src/weights/pallet_timestamp.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,16 +52,16 @@ use frame_support::{ /// Weight functions for pallet_timestamp (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_timestamp::weights::WeightInfo for WeightInfo { - /// Storage: Timestamp Now (r:1 w:1) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Aura CurrentSlot (r:1 w:0) - /// Proof: Aura CurrentSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: `Timestamp::Now` (r:1 w:1) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Aura::CurrentSlot` (r:1 w:0) + /// Proof: `Aura::CurrentSlot` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) fn set() -> Weight { // Proof Size summary in bytes: - // Measured: `289` - // Estimated: `1006` - // Minimum execution time: 23_750 nanoseconds. - Weight::from_parts(28_020_000, 1006) + // Measured: `256` + // Estimated: `1493` + // Minimum execution time: 27_830 nanoseconds. + Weight::from_parts(28_710_000, 1493) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -69,7 +69,7 @@ impl pallet_timestamp::weights::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `128` // Estimated: `0` - // Minimum execution time: 9_100 nanoseconds. - Weight::from_parts(9_390_000, 0) + // Minimum execution time: 10_771 nanoseconds. + Weight::from_parts(11_610_000, 0) } } diff --git a/runtime/common/src/weights/pallet_treasury.rs b/runtime/common/src/weights/pallet_treasury.rs index 31af5a972..348dad587 100644 --- a/runtime/common/src/weights/pallet_treasury.rs +++ b/runtime/common/src/weights/pallet_treasury.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,99 +52,97 @@ use frame_support::{ /// Weight functions for pallet_treasury (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_treasury::weights::WeightInfo for WeightInfo { - /// Storage: Treasury ProposalCount (r:1 w:1) - /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Treasury Approvals (r:1 w:1) - /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) - /// Storage: Treasury Proposals (r:0 w:1) - /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: `Treasury::ProposalCount` (r:1 w:1) + /// Proof: `Treasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Approvals` (r:1 w:1) + /// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Proposals` (r:0 w:1) + /// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn spend() -> Weight { // Proof Size summary in bytes: - // Measured: `80` - // Estimated: `1396` - // Minimum execution time: 24_670 nanoseconds. - Weight::from_parts(30_100_000, 1396) + // Measured: `42` + // Estimated: `1887` + // Minimum execution time: 30_290 nanoseconds. + Weight::from_parts(31_230_000, 1887) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Treasury ProposalCount (r:1 w:1) - /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Treasury Proposals (r:0 w:1) - /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: `Treasury::ProposalCount` (r:1 w:1) + /// Proof: `Treasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Proposals` (r:0 w:1) + /// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn propose_spend() -> Weight { // Proof Size summary in bytes: - // Measured: `217` - // Estimated: `499` - // Minimum execution time: 38_110 nanoseconds. - Weight::from_parts(38_800_000, 499) + // Measured: `147` + // Estimated: `1489` + // Minimum execution time: 54_400 nanoseconds. + Weight::from_parts(55_751_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Treasury Proposals (r:1 w:1) - /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Treasury::Proposals` (r:1 w:1) + /// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn reject_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `583` - // Estimated: `7797` - // Minimum execution time: 50_470 nanoseconds. - Weight::from_parts(59_770_000, 7797) + // Measured: `449` + // Estimated: `6204` + // Minimum execution time: 83_171 nanoseconds. + Weight::from_parts(84_411_000, 6204) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Treasury Proposals (r:1 w:0) - /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: Treasury Approvals (r:1 w:1) - /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: `Treasury::Proposals` (r:1 w:0) + /// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Approvals` (r:1 w:1) + /// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `538 + p * (8 ±0)` - // Estimated: `3480` - // Minimum execution time: 17_940 nanoseconds. - Weight::from_parts(25_751_614, 3480) - // Standard Error: 3_529 - .saturating_add(Weight::from_parts(33_921, 0).saturating_mul(p.into())) + // Measured: `469 + p * (8 ±0)` + // Estimated: `3573` + // Minimum execution time: 19_540 nanoseconds. + Weight::from_parts(28_185_198, 3573) + // Standard Error: 4_990 + .saturating_add(Weight::from_parts(218_022, 0).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) - /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: `Treasury::Approvals` (r:1 w:1) + /// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) fn remove_approval() -> Weight { // Proof Size summary in bytes: - // Measured: `165` - // Estimated: `897` - // Minimum execution time: 12_680 nanoseconds. - Weight::from_parts(12_950_000, 897) + // Measured: `127` + // Estimated: `1887` + // Minimum execution time: 19_670 nanoseconds. + Weight::from_parts(21_080_000, 1887) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: System Account (r:201 w:201) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Treasury Deactivated (r:1 w:1) - /// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Balances InactiveIssuance (r:1 w:1) - /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Treasury Approvals (r:1 w:1) - /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) - /// Storage: Treasury Proposals (r:100 w:100) - /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - /// Storage: Bounties BountyApprovals (r:1 w:1) - /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: `System::Account` (r:201 w:201) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Deactivated` (r:1 w:1) + /// Proof: `Treasury::Deactivated` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Approvals` (r:1 w:1) + /// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `Treasury::Proposals` (r:100 w:100) + /// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) + /// Storage: `Bounties::BountyApprovals` (r:1 w:1) + /// Proof: `Bounties::BountyApprovals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `421 + p * (318 ±0)` - // Estimated: `5423 + p * (7797 ±0)` - // Minimum execution time: 56_770 nanoseconds. - Weight::from_parts(85_622_030, 5423) - // Standard Error: 190_622 - .saturating_add(Weight::from_parts(48_399_356, 0).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `320 + p * (255 ±0)` + // Estimated: `3597 + p * (5214 ±0)` + // Minimum execution time: 100_551 nanoseconds. + Weight::from_parts(51_119_356, 3597) + // Standard Error: 140_974 + .saturating_add(Weight::from_parts(78_423_136, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into()))) - .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 7797).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 5214).saturating_mul(p.into())) } } diff --git a/runtime/common/src/weights/pallet_utility.rs b/runtime/common/src/weights/pallet_utility.rs index 4623af16b..1260a1d5f 100644 --- a/runtime/common/src/weights/pallet_utility.rs +++ b/runtime/common/src/weights/pallet_utility.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_utility //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -57,43 +57,43 @@ impl pallet_utility::weights::WeightInfo for WeightInfo // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_850 nanoseconds. - Weight::from_parts(64_007_522, 0) - // Standard Error: 19_728 - .saturating_add(Weight::from_parts(6_558_888, 0).saturating_mul(c.into())) + // Minimum execution time: 13_410 nanoseconds. + Weight::from_parts(6_269_119, 0) + // Standard Error: 10_761 + .saturating_add(Weight::from_parts(8_693_574, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_810 nanoseconds. - Weight::from_parts(9_330_000, 0) + // Minimum execution time: 9_320 nanoseconds. + Weight::from_parts(9_770_000, 0) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_390 nanoseconds. - Weight::from_parts(16_446_792, 0) - // Standard Error: 19_995 - .saturating_add(Weight::from_parts(6_975_821, 0).saturating_mul(c.into())) + // Minimum execution time: 13_930 nanoseconds. + Weight::from_parts(14_440_000, 0) + // Standard Error: 5_656 + .saturating_add(Weight::from_parts(9_027_117, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_260 nanoseconds. - Weight::from_parts(12_760_000, 0) + // Minimum execution time: 17_380 nanoseconds. + Weight::from_parts(18_100_000, 0) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_790 nanoseconds. - Weight::from_parts(86_897_110, 0) - // Standard Error: 19_414 - .saturating_add(Weight::from_parts(6_578_542, 0).saturating_mul(c.into())) + // Minimum execution time: 13_720 nanoseconds. + Weight::from_parts(15_689_569, 0) + // Standard Error: 11_844 + .saturating_add(Weight::from_parts(8_654_402, 0).saturating_mul(c.into())) } } diff --git a/runtime/common/src/weights/pallet_vesting.rs b/runtime/common/src/weights/pallet_vesting.rs index 1cf788469..d6516c58b 100644 --- a/runtime/common/src/weights/pallet_vesting.rs +++ b/runtime/common/src/weights/pallet_vesting.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for pallet_vesting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,162 +52,184 @@ use frame_support::{ /// Weight functions for pallet_vesting (automatically generated) pub struct WeightInfo(PhantomData); impl pallet_vesting::weights::WeightInfo for WeightInfo { - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `438 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `7418` - // Minimum execution time: 38_560 nanoseconds. - Weight::from_parts(45_516_515, 7418) - // Standard Error: 8_687 - .saturating_add(Weight::from_parts(94_777, 0).saturating_mul(l.into())) - // Standard Error: 15_456 - .saturating_add(Weight::from_parts(72_036, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `343 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 52_331 nanoseconds. + Weight::from_parts(63_401_606, 4764) + // Standard Error: 7_177 + .saturating_add(Weight::from_parts(89_197, 0).saturating_mul(l.into())) + // Standard Error: 12_769 + .saturating_add(Weight::from_parts(417_041, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `438 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `7418` - // Minimum execution time: 37_590 nanoseconds. - Weight::from_parts(47_544_266, 7418) - // Standard Error: 9_000 - .saturating_add(Weight::from_parts(42_206, 0).saturating_mul(l.into())) - // Standard Error: 16_013 - .saturating_add(Weight::from_parts(26_886, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `343 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 57_360 nanoseconds. + Weight::from_parts(73_584_234, 4764) + // Standard Error: 8_211 + .saturating_add(Weight::from_parts(143_468, 0).saturating_mul(l.into())) + // Standard Error: 14_609 + .saturating_add(Weight::from_parts(179_456, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `10025` - // Minimum execution time: 43_891 nanoseconds. - Weight::from_parts(46_799_315, 10025) - // Standard Error: 9_698 - .saturating_add(Weight::from_parts(146_827, 0).saturating_mul(l.into())) - // Standard Error: 17_255 - .saturating_add(Weight::from_parts(168_808, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `450 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 56_870 nanoseconds. + Weight::from_parts(72_384_891, 4764) + // Standard Error: 9_374 + .saturating_add(Weight::from_parts(122_312, 0).saturating_mul(l.into())) + // Standard Error: 16_679 + .saturating_add(Weight::from_parts(242_036, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. - fn vest_other_unlocked(l: u32, _s: u32) -> Weight { + fn vest_other_unlocked(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `577 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `10025` - // Minimum execution time: 43_400 nanoseconds. - Weight::from_parts(53_527_221, 10025) - // Standard Error: 11_915 - .saturating_add(Weight::from_parts(74_224, 0).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `450 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 62_670 nanoseconds. + Weight::from_parts(76_824_460, 4764) + // Standard Error: 10_041 + .saturating_add(Weight::from_parts(113_179, 0).saturating_mul(l.into())) + // Standard Error: 17_865 + .saturating_add(Weight::from_parts(310_811, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. - fn vested_transfer(l: u32, _s: u32) -> Weight { + fn vested_transfer(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `648 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `10025` - // Minimum execution time: 62_280 nanoseconds. - Weight::from_parts(78_476_850, 10025) - // Standard Error: 14_571 - .saturating_add(Weight::from_parts(40_756, 0).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `521 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 112_320 nanoseconds. + Weight::from_parts(141_803_727, 4764) + // Standard Error: 14_957 + .saturating_add(Weight::from_parts(98_436, 0).saturating_mul(l.into())) + // Standard Error: 26_611 + .saturating_add(Weight::from_parts(306_207, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. - fn force_vested_transfer(l: u32, _s: u32) -> Weight { + fn force_vested_transfer(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `787 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `12632` - // Minimum execution time: 66_730 nanoseconds. - Weight::from_parts(80_474_489, 12632) - // Standard Error: 14_395 - .saturating_add(Weight::from_parts(142_000, 0).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `628 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `6204` + // Minimum execution time: 116_570 nanoseconds. + Weight::from_parts(145_862_858, 6204) + // Standard Error: 12_694 + .saturating_add(Weight::from_parts(134_468, 0).saturating_mul(l.into())) + // Standard Error: 22_586 + .saturating_add(Weight::from_parts(306_294, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `575 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `10025` - // Minimum execution time: 44_740 nanoseconds. - Weight::from_parts(52_534_350, 10025) - // Standard Error: 10_550 - .saturating_add(Weight::from_parts(25_678, 0).saturating_mul(l.into())) - // Standard Error: 19_484 - .saturating_add(Weight::from_parts(180_277, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `448 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 61_260 nanoseconds. + Weight::from_parts(78_432_635, 4764) + // Standard Error: 9_780 + .saturating_add(Weight::from_parts(95_506, 0).saturating_mul(l.into())) + // Standard Error: 18_061 + .saturating_add(Weight::from_parts(186_973, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof: Vesting Vesting (max_values: None, max_size: Some(1169), added: 3644, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Vesting::Vesting` (r:1 w:1) + /// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1169), added: 3644, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `575 + l * (25 ±0) + s * (40 ±0)` - // Estimated: `10025` - // Minimum execution time: 45_250 nanoseconds. - Weight::from_parts(54_174_621, 10025) - // Standard Error: 11_352 - .saturating_add(Weight::from_parts(118_094, 0).saturating_mul(l.into())) - // Standard Error: 20_964 - .saturating_add(Weight::from_parts(25_682, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `448 + l * (25 ±0) + s * (40 ±0)` + // Estimated: `4764` + // Minimum execution time: 64_750 nanoseconds. + Weight::from_parts(82_374_991, 4764) + // Standard Error: 9_563 + .saturating_add(Weight::from_parts(94_770, 0).saturating_mul(l.into())) + // Standard Error: 17_661 + .saturating_add(Weight::from_parts(283_509, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/runtime/zeitgeist/Cargo.toml b/runtime/zeitgeist/Cargo.toml index bc48adbc3..f02b27715 100644 --- a/runtime/zeitgeist/Cargo.toml +++ b/runtime/zeitgeist/Cargo.toml @@ -11,7 +11,6 @@ orml-currencies = { workspace = true } orml-tokens = { workspace = true } orml-traits = { workspace = true } pallet-asset-tx-payment = { workspace = true } -pallet-assets = { workspace = true } pallet-balances = { workspace = true } pallet-bounties = { workspace = true } pallet-collective = { workspace = true } @@ -109,7 +108,6 @@ xcm-executor = { workspace = true, optional = true } common-runtime = { workspace = true } zeitgeist-primitives = { workspace = true } -zrml-asset-router = { workspace = true } zrml-authorized = { workspace = true } zrml-court = { workspace = true } zrml-global-disputes = { workspace = true, optional = true } @@ -192,7 +190,6 @@ runtime-benchmarks = [ "orml-benchmarking", "orml-tokens/runtime-benchmarks", "orml-xtokens?/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", "pallet-author-inherent?/runtime-benchmarks", "pallet-author-mapping?/runtime-benchmarks", "pallet-author-slot-filter?/runtime-benchmarks", @@ -242,7 +239,6 @@ std = [ "orml-currencies/std", "orml-tokens/std", "orml-traits/std", - "pallet-assets/std", "pallet-asset-tx-payment/std", "pallet-balances/std", "pallet-bounties/std", @@ -326,7 +322,6 @@ std = [ # Zeitgeist "zeitgeist-primitives/std", - "zrml-asset-router/std", "zrml-authorized/std", "zrml-court/std", "zrml-hybrid-router/std", @@ -357,7 +352,6 @@ try-runtime = [ "pallet-preimage/try-runtime", # Money runtime pallets - "pallet-assets/try-runtime", "pallet-asset-tx-payment/try-runtime", "pallet-balances/try-runtime", "pallet-bounties/try-runtime", @@ -384,7 +378,6 @@ try-runtime = [ "orml-xtokens?/try-runtime", # Zeitgeist runtime pallets - "zrml-asset-router/try-runtime", "zrml-authorized/try-runtime", "zrml-court/try-runtime", "zrml-hybrid-router/try-runtime", diff --git a/runtime/zeitgeist/src/integration_tests/xcm/genesis/zeitgeist.rs b/runtime/zeitgeist/src/integration_tests/xcm/genesis/zeitgeist.rs index 39cf5a6f9..45d9e00d6 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/genesis/zeitgeist.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/genesis/zeitgeist.rs @@ -21,7 +21,6 @@ use crate::{ }, parachain_params::MinCandidateStk, parameters::ZeitgeistTreasuryAccount, - Asset, }; use nimbus_primitives::NimbusId; use sp_core::storage::Storage; @@ -66,11 +65,11 @@ pub(crate) fn genesis(parachain_id: u32) -> Storage { .chain([(ZeitgeistTreasuryAccount::get())].iter()) .flat_map(|k| { vec![ - (k.clone(), Asset::from(FOREIGN_PARENT_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(FOREIGN_SIBLING_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(FOREIGN_ZTG_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(BTC_ID).try_into().unwrap(), ENDOWMENT), - (k.clone(), Asset::from(ETH_ID).try_into().unwrap(), ENDOWMENT), + (k.clone(), FOREIGN_PARENT_ID, ENDOWMENT), + (k.clone(), FOREIGN_SIBLING_ID, ENDOWMENT), + (k.clone(), FOREIGN_ZTG_ID, ENDOWMENT), + (k.clone(), BTC_ID, ENDOWMENT), + (k.clone(), ETH_ID, ENDOWMENT), ] }) .collect::>(), diff --git a/runtime/zeitgeist/src/integration_tests/xcm/setup.rs b/runtime/zeitgeist/src/integration_tests/xcm/setup.rs index 3a35b1042..3dd142182 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/setup.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/setup.rs @@ -17,7 +17,8 @@ use crate::{ xcm_config::config::{general_key, zeitgeist}, - AccountId, AssetRegistry, AssetRegistryStringLimit, Balance, ExistentialDeposit, RuntimeOrigin, + AccountId, AssetRegistry, AssetRegistryStringLimit, Balance, CurrencyId, ExistentialDeposit, + RuntimeOrigin, }; use frame_support::assert_ok; use orml_traits::asset_registry::AssetMetadata; @@ -27,7 +28,7 @@ use xcm::{ VersionedMultiLocation, }; use xcm_emulator::helpers::get_account_id_from_seed; -use zeitgeist_primitives::types::{CustomMetadata, XcmAsset}; +use zeitgeist_primitives::types::{Asset, CustomMetadata}; pub(super) mod accounts { use super::*; @@ -83,11 +84,11 @@ pub const PARA_ID_SIBLING: u32 = 3000; pub const PARA_ID_ZEITGEIST: u32 = zeitgeist::ID; /// IDs that are used to represent tokens from other chains -pub const FOREIGN_ZTG_ID: XcmAsset = XcmAsset::ForeignAsset(0); -pub const FOREIGN_PARENT_ID: XcmAsset = XcmAsset::ForeignAsset(1); -pub const FOREIGN_SIBLING_ID: XcmAsset = XcmAsset::ForeignAsset(2); -pub const BTC_ID: XcmAsset = XcmAsset::ForeignAsset(3); -pub const ETH_ID: XcmAsset = XcmAsset::ForeignAsset(4); +pub const FOREIGN_ZTG_ID: Asset = CurrencyId::ForeignAsset(0); +pub const FOREIGN_PARENT_ID: Asset = CurrencyId::ForeignAsset(1); +pub const FOREIGN_SIBLING_ID: Asset = CurrencyId::ForeignAsset(2); +pub const BTC_ID: Asset = CurrencyId::ForeignAsset(3); +pub const ETH_ID: Asset = CurrencyId::ForeignAsset(4); #[inline] pub(super) const fn ztg(amount: Balance) -> Balance { diff --git a/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs b/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs index a70900558..b44d3d246 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/test_net.rs @@ -43,7 +43,6 @@ decl_test_relay_chains! { } }, } - decl_test_parachains! { pub struct Zeitgeist { genesis = zeitgeist::genesis(PARA_ID_ZEITGEIST), 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 38d443dee..076775890 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 @@ -26,13 +26,14 @@ use crate::{ test_net::Zeitgeist, }, xcm_config::config::{general_key, zeitgeist, AssetConvert}, - Assets, CustomMetadata, ScalarPosition, XcmAsset, + CurrencyId, CustomMetadata, ScalarPosition, }; use core::fmt::Debug; use sp_runtime::traits::{Convert, MaybeEquivalence}; use test_case::test_case; use xcm::latest::{Junction::*, Junctions::*, MultiLocation}; use xcm_emulator::TestExt; +use zeitgeist_primitives::types::Asset; fn convert_common_native(expected: T) where @@ -81,18 +82,13 @@ fn convert_common_non_native( #[test] fn convert_native_assets() { - convert_common_native(Assets::Ztg); -} - -#[test] -fn convert_native_xcm_assets() { - convert_common_native(XcmAsset::Ztg); + convert_common_native(Asset::Ztg); } #[test] fn convert_any_registered_parent_multilocation_assets() { convert_common_non_native( - Assets::from(FOREIGN_PARENT_ID), + FOREIGN_PARENT_ID, foreign_parent_multilocation(), register_foreign_parent, ); @@ -101,7 +97,7 @@ fn convert_any_registered_parent_multilocation_assets() { #[test] fn convert_any_registered_parent_multilocation_xcm_assets() { convert_common_non_native( - XcmAsset::try_from(Assets::from(FOREIGN_PARENT_ID)).unwrap(), + FOREIGN_PARENT_ID, foreign_parent_multilocation(), register_foreign_parent, ); @@ -110,7 +106,7 @@ fn convert_any_registered_parent_multilocation_xcm_assets() { #[test] fn convert_any_registered_sibling_multilocation_assets() { convert_common_non_native( - Assets::from(FOREIGN_SIBLING_ID), + FOREIGN_SIBLING_ID, foreign_sibling_multilocation(), register_foreign_sibling, ); @@ -119,7 +115,7 @@ fn convert_any_registered_sibling_multilocation_assets() { #[test] fn convert_any_registered_sibling_multilocation_xcm_assets() { convert_common_non_native( - XcmAsset::try_from(Assets::from(FOREIGN_SIBLING_ID)).unwrap(), + FOREIGN_SIBLING_ID, foreign_sibling_multilocation(), register_foreign_sibling, ); @@ -132,43 +128,16 @@ fn convert_unkown_multilocation() { Zeitgeist::execute_with(|| { assert!( - >::convert(&unknown_location).is_none() + >::convert(&unknown_location).is_none() ); }); } -#[test_case( - Assets::CategoricalOutcome(7, 8); - "assets_categorical" -)] -#[test_case( - Assets::ScalarOutcome(7, ScalarPosition::Long); - "assets_scalar" -)] -#[test_case( - Assets::PoolShare(7); - "assets_pool_share" -)] -#[test_case( - Assets::ForeignAsset(7); - "assets_foreign" -)] -#[test_case( - Assets::ParimutuelShare(7, 8); - "assets_parimutuel_share" -)] -#[test_case( - Assets::CampaignAsset(7); - "assets_campaign_asset" -)] -#[test_case( - Assets::CustomAsset(7); - "assets_custom_asset" -)] -#[test_case( - XcmAsset::ForeignAsset(7); - "xcm_assets_foreign" -)] +#[test_case(Asset::CategoricalOutcome(7, 8))] +#[test_case(Asset::ScalarOutcome(7, ScalarPosition::Long))] +#[test_case(Asset::PoolShare(7))] +#[test_case(Asset::ForeignAsset(7))] +#[test_case(Asset::ParimutuelShare(7, 8))] fn convert_unsupported_asset(asset: T) where T: Copy + Debug + PartialEq, diff --git a/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs b/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs index 834120424..618bb827f 100644 --- a/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs +++ b/runtime/zeitgeist/src/integration_tests/xcm/tests/transfers.rs @@ -27,7 +27,8 @@ use crate::{ test_net::{Polkadot, Sibling, Zeitgeist}, }, xcm_config::fees::default_per_second, - AssetManager, Balance, Balances, RuntimeOrigin, XTokens, ZeitgeistTreasuryAccount, + AssetManager, Balance, Balances, CurrencyId, RuntimeOrigin, Tokens, XTokens, + ZeitgeistTreasuryAccount, }; use frame_support::{assert_ok, traits::tokens::fungible::Mutate}; @@ -36,7 +37,7 @@ use xcm::latest::{Junction, Junction::*, Junctions::*, MultiLocation, WeightLimi use xcm_emulator::{RelayChain, TestExt}; use zeitgeist_primitives::{ constants::{BalanceFractionalDecimals, BASE}, - types::{CustomMetadata, XcmAsset, XcmMetadata}, + types::{Asset, CustomMetadata, XcmMetadata}, }; #[test] @@ -48,8 +49,8 @@ fn transfer_ztg_to_sibling() { Sibling::execute_with(|| { treasury_initial_balance = - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); register_foreign_ztg(None); }); @@ -58,7 +59,7 @@ fn transfer_ztg_to_sibling() { assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), - XcmAsset::Ztg, + CurrencyId::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -80,15 +81,12 @@ fn transfer_ztg_to_sibling() { }); Sibling::execute_with(|| { - let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let bob_expected = bob_initial_balance + transfer_amount - ztg_fee(); let treasury_expected = treasury_initial_balance + ztg_fee(); - - // Verify that bob() now has (amount transferred - fee) assert_eq!(current_balance, bob_expected); - // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()), + Tokens::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -104,8 +102,8 @@ fn transfer_ztg_to_sibling_with_custom_fee() { Sibling::execute_with(|| { treasury_initial_balance = - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let custom_metadata = CustomMetadata { xcm: XcmMetadata { fee_factor: Some(fee_factor) }, ..Default::default() @@ -118,7 +116,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { assert_eq!(Balances::free_balance(sibling_parachain_account()), 0); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), - XcmAsset::Ztg, + Asset::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -139,7 +137,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { }); Sibling::execute_with(|| { - let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let current_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); let custom_fee = ztg_fee() * fee_factor / BASE; let bob_expected = bob_initial_balance + transfer_amount - custom_fee; let treasury_expected = treasury_initial_balance + custom_fee; @@ -148,7 +146,7 @@ fn transfer_ztg_to_sibling_with_custom_fee() { assert_eq!(current_balance, bob_expected); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &ZeitgeistTreasuryAccount::get()), + AssetManager::free_balance(FOREIGN_ZTG_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -172,7 +170,7 @@ fn transfer_ztg_sibling_to_zeitgeist() { Sibling::execute_with(|| { register_foreign_ztg(None); - let bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()); + let bob_initial_balance = AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(bob()), @@ -192,7 +190,7 @@ fn transfer_ztg_sibling_to_zeitgeist() { )); // Confirm that Bobs's balance is initial balance - amount transferred assert_eq!( - AssetManager::free_balance(FOREIGN_ZTG_ID.into(), &bob()), + AssetManager::free_balance(FOREIGN_ZTG_ID, &bob()), bob_initial_balance - transfer_amount ); }); @@ -225,8 +223,8 @@ fn transfer_btc_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { register_btc(None); treasury_initial_balance = - AssetManager::free_balance(BTC_ID.into(), &ZeitgeistTreasuryAccount::get()); - zeitgeist_alice_initial_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + AssetManager::free_balance(BTC_ID, &ZeitgeistTreasuryAccount::get()); + zeitgeist_alice_initial_balance = AssetManager::free_balance(BTC_ID, &alice()); }); Sibling::execute_with(|| { @@ -241,7 +239,7 @@ fn transfer_btc_sibling_to_zeitgeist() { assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), // Target chain will interpret XcmAsset::Ztg as BTC in this context. - XcmAsset::Ztg, + Asset::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -271,12 +269,12 @@ fn transfer_btc_sibling_to_zeitgeist() { // Verify that remote Alice now has initial balance + amount transferred - fee assert_eq!( - AssetManager::free_balance(BTC_ID.into(), &alice()), + AssetManager::free_balance(BTC_ID, &alice()), zeitgeist_alice_initial_balance + expected_adjusted, ); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(BTC_ID.into(), &ZeitgeistTreasuryAccount::get()), + Tokens::free_balance(BTC_ID, &ZeitgeistTreasuryAccount::get()), // Align decimal fractional places expected_treasury ) @@ -300,7 +298,7 @@ fn transfer_btc_zeitgeist_to_sibling() { Zeitgeist::execute_with(|| { register_btc(None); - let alice_initial_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + let alice_initial_balance = AssetManager::free_balance(BTC_ID, &alice()); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), @@ -320,7 +318,7 @@ fn transfer_btc_zeitgeist_to_sibling() { )); // Confirm that Alice's balance is initial_balance - amount_transferred - let alice_balance = AssetManager::free_balance(BTC_ID.into(), &alice()); + let alice_balance = AssetManager::free_balance(BTC_ID, &alice()); let alice_expected = alice_initial_balance - adjusted_balance(btc(1), transfer_amount); assert_eq!(alice_balance, alice_expected); }); @@ -345,8 +343,8 @@ fn transfer_eth_sibling_to_zeitgeist() { Zeitgeist::execute_with(|| { register_eth(None); treasury_initial_balance = - AssetManager::free_balance(ETH_ID.into(), &ZeitgeistTreasuryAccount::get()); - zeitgeist_alice_initial_balance = AssetManager::free_balance(ETH_ID.into(), &alice()); + AssetManager::free_balance(ETH_ID, &ZeitgeistTreasuryAccount::get()); + zeitgeist_alice_initial_balance = AssetManager::free_balance(ETH_ID, &alice()); }); Sibling::execute_with(|| { @@ -360,8 +358,8 @@ fn transfer_eth_sibling_to_zeitgeist() { ); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), - // Target chain will interpret XcmAsset::Ztg as ETH in this context. - XcmAsset::Ztg, + // Target chain will interpret CurrencyId::Ztg as ETH in this context. + CurrencyId::Ztg, transfer_amount, Box::new( MultiLocation::new( @@ -391,12 +389,12 @@ fn transfer_eth_sibling_to_zeitgeist() { // Verify that remote Alice now has initial balance + amount transferred - fee assert_eq!( - AssetManager::free_balance(ETH_ID.into(), &alice()), + AssetManager::free_balance(ETH_ID, &alice()), zeitgeist_alice_initial_balance + expected_adjusted, ); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(ETH_ID.into(), &ZeitgeistTreasuryAccount::get()), + Tokens::free_balance(ETH_ID, &ZeitgeistTreasuryAccount::get()), // Align decimal fractional places expected_treasury ) @@ -420,7 +418,7 @@ fn transfer_eth_zeitgeist_to_sibling() { Zeitgeist::execute_with(|| { register_eth(None); - let alice_initial_balance = AssetManager::free_balance(ETH_ID.into(), &alice()); + let alice_initial_balance = AssetManager::free_balance(ETH_ID, &alice()); assert_ok!(XTokens::transfer( RuntimeOrigin::signed(alice()), @@ -440,7 +438,7 @@ fn transfer_eth_zeitgeist_to_sibling() { )); // Confirm that Alice's balance is initial_balance - amount_transferred - let alice_balance = AssetManager::free_balance(ETH_ID.into(), &alice()); + let alice_balance = AssetManager::free_balance(ETH_ID, &alice()); let alice_expected = alice_initial_balance - adjusted_balance(eth(1), transfer_amount); assert_eq!(alice_balance, alice_expected); }); @@ -465,8 +463,8 @@ fn transfer_dot_from_relay_chain() { Zeitgeist::execute_with(|| { register_foreign_parent(None); treasury_initial_balance = - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &ZeitgeistTreasuryAccount::get()); - bob_initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &bob()); + AssetManager::free_balance(FOREIGN_PARENT_ID, &ZeitgeistTreasuryAccount::get()); + bob_initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID, &bob()); }); Polkadot::execute_with(|| { @@ -487,10 +485,10 @@ fn transfer_dot_from_relay_chain() { let bob_expected = bob_initial_balance + adjusted_balance(dot(1), expected); let treasury_expected = treasury_initial_balance + adjusted_balance(dot(1), dot_fee()); - assert_eq!(AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &bob()), bob_expected); + assert_eq!(AssetManager::free_balance(FOREIGN_PARENT_ID, &bob()), bob_expected); // Verify that fees (of foreign currency) have been put into treasury assert_eq!( - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &ZeitgeistTreasuryAccount::get()), + AssetManager::free_balance(FOREIGN_PARENT_ID, &ZeitgeistTreasuryAccount::get()), treasury_expected ) }); @@ -513,7 +511,7 @@ fn transfer_dot_to_relay_chain() { Zeitgeist::execute_with(|| { register_foreign_parent(None); - let initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &alice()); + let initial_balance = AssetManager::free_balance(FOREIGN_PARENT_ID, &alice()); assert!(initial_balance >= transfer_amount_local); assert_ok!(XTokens::transfer( @@ -531,7 +529,7 @@ fn transfer_dot_to_relay_chain() { )); assert_eq!( - AssetManager::free_balance(FOREIGN_PARENT_ID.into(), &alice()), + AssetManager::free_balance(FOREIGN_PARENT_ID, &alice()), initial_balance - transfer_amount_local ) }); diff --git a/runtime/zeitgeist/src/lib.rs b/runtime/zeitgeist/src/lib.rs index 9887d9ccc..35d5adf80 100644 --- a/runtime/zeitgeist/src/lib.rs +++ b/runtime/zeitgeist/src/lib.rs @@ -30,7 +30,7 @@ use common_runtime::{ }; pub use frame_system::{ Call as SystemCall, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, - CheckTxVersion, CheckWeight, EnsureNever, EnsureSigned, + CheckTxVersion, CheckWeight, }; #[cfg(feature = "parachain")] pub use pallet_author_slot_filter::EligibilityValue; @@ -41,15 +41,11 @@ pub use crate::parachain_params::*; pub use crate::parameters::*; use alloc::vec; use frame_support::{ - traits::{ - AsEnsureOriginWithArg, ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, - InstanceFilter, Nothing, - }, + traits::{ConstU32, Contains, EitherOfDiverse, EqualPrivilegeOnly, InstanceFilter, Nothing}, weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight}, }; use frame_system::{EnsureRoot, EnsureWithSuccess}; use pallet_collective::{EnsureProportionAtLeast, EnsureProportionMoreThan, PrimeDefaultVote}; -use parity_scale_codec::Compact; use sp_runtime::traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256}; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -58,7 +54,7 @@ use zeitgeist_primitives::{constants::*, types::*}; use zrml_rikiddo::types::{EmaMarketVolume, FeeSigmoid, RikiddoSigmoidMV}; #[cfg(feature = "parachain")] use { - frame_support::traits::Everything, + frame_support::traits::{AsEnsureOriginWithArg, Everything}, xcm_builder::{EnsureXcmOrigin, FixedWeightBounds}, xcm_config::{ asset_registry::CustomAssetProcessor, @@ -115,7 +111,6 @@ impl Contains for IsCallable { kill_prefix, kill_storage, set_code, set_code_without_checks, set_storage, }; use orml_currencies::Call::update_balance; - use pallet_assets::Call::{destroy_accounts, destroy_approvals, finish_destroy}; use pallet_balances::Call::{force_set_balance, force_transfer}; use pallet_collective::Call::set_members; use pallet_contracts::Call::{ @@ -133,7 +128,7 @@ impl Contains for IsCallable { match runtime_call { // Membership is managed by the respective Membership instance RuntimeCall::AdvisoryCommittee(set_members { .. }) => false, - // See "balance.set_balance" + // See "balance.force_set_balance" RuntimeCall::AssetManager(update_balance { .. }) => false, RuntimeCall::Balances(inner_call) => { match inner_call { @@ -149,26 +144,6 @@ impl Contains for IsCallable { _ => true, } } - // Asset destruction is managed. Instead of deleting those dispatchable calls, they are - // filtered here instead to allow root to interact in case of emergency. - RuntimeCall::CampaignAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, - RuntimeCall::CustomAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, - RuntimeCall::MarketAssets(inner_call) => match inner_call { - destroy_accounts { .. } => false, - destroy_approvals { .. } => false, - finish_destroy { .. } => false, - _ => true, - }, // Permissioned contracts: Only deployable via utility.dispatch_as(...) RuntimeCall::Contracts(inner_call) => match inner_call { call { .. } => true, diff --git a/runtime/zeitgeist/src/parameters.rs b/runtime/zeitgeist/src/parameters.rs index 5c8fade66..94d54089e 100644 --- a/runtime/zeitgeist/src/parameters.rs +++ b/runtime/zeitgeist/src/parameters.rs @@ -22,7 +22,7 @@ clippy::arithmetic_side_effects )] -use super::{CampaignAssetsInstance, Runtime, VERSION}; +use super::{Runtime, VERSION}; use frame_support::{ dispatch::DispatchClass, parameter_types, @@ -35,7 +35,6 @@ use frame_support::{ }; use frame_system::limits::{BlockLength, BlockWeights}; use orml_traits::parameter_type_with_key; -use pallet_assets::WeightInfo; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use sp_runtime::{ traits::{AccountIdConversion, Bounded}, @@ -65,44 +64,6 @@ parameter_types! { } parameter_types! { - // Asset-Router - pub DestroyAccountWeight: Weight = - >::WeightInfo::destroy_accounts(1); - pub DestroyApprovalWeight: Weight = - >::WeightInfo::destroy_approvals(1); - pub DestroyFinishWeight: Weight = - >::WeightInfo::finish_destroy(); - - // Assets (Campaign) - pub const CampaignAssetsAccountDeposit: Balance = deposit(1, 16); - pub const CampaignAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - /// The amount of native currency that is frozen during the whole lifetime - /// of an asset class. Freezing happens at asset class creation. - /// Irrelevant - No origin can successfully call the associated dispatchable call. - pub const CampaignAssetsDeposit: Balance = 400 * BASE; - pub const CampaignAssetsStringLimit: u32 = 256; - pub const CampaignAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const CampaignAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - - // Assets (Custom) - pub const CustomAssetsAccountDeposit: Balance = deposit(1, 16); - pub const CustomAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - pub const CustomAssetsDeposit: Balance = 400 * BASE; - pub const CustomAssetsStringLimit: u32 = 50; - pub const CustomAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const CustomAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - - // Assets (Market) - pub const MarketAssetsAccountDeposit: Balance = deposit(1, 16); - pub const MarketAssetsApprovalDeposit: Balance = ExistentialDeposit::get(); - /// The amount of native currency that is frozen during the whole lifetime - /// if an asset class. Freezing happens at asset class creation. - /// Irrelevant - No origin can successfully call the associated dispatchable call. - pub const MarketAssetsDeposit: Balance = 400 * BASE; - pub const MarketAssetsStringLimit: u32 = 50; - pub const MarketAssetsMetadataDepositBase: Balance = deposit(1, 68); - pub const MarketAssetsMetadataDepositPerByte: Balance = deposit(0, 1); - // Authorized pub const AuthorizedPalletId: PalletId = AUTHORIZED_PALLET_ID; pub const CorrectionPeriod: BlockNumber = BLOCKS_PER_DAY; @@ -242,7 +203,7 @@ parameter_types! { pub const MaxLiquidityTreeDepth: u32 = 9u32; // ORML - pub const GetNativeCurrencyId: Assets = Asset::Ztg; + pub const GetNativeCurrencyId: CurrencyId = Asset::Ztg; // Prediction Market parameters /// (Slashable) Bond that is provided for creating an advised market that needs approval. @@ -401,8 +362,6 @@ parameter_types! { .build_or_panic(); // Transaction payment - /// A fee multiplier applied to the calculated fee factor for `CampaignAsset` - pub const CampaignAssetFeeMultiplier: u32 = 100; /// A fee mulitplier for Operational extrinsics to compute “virtual tip” /// to boost their priority. pub const OperationalFeeMultiplier: u8 = 5; @@ -510,17 +469,17 @@ parameter_type_with_key! { // 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: Currencies| -> Balance { + pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { - Currencies::CategoricalOutcome(_, _) => ExistentialDeposit::get(), - Currencies::ParimutuelShare(_, _) => ExistentialDeposit::get(), - Currencies::PoolShare(_) => ExistentialDeposit::get(), - Currencies::ScalarOutcome(_, _) => ExistentialDeposit::get(), + Asset::CategoricalOutcome(_,_) => ExistentialDeposit::get(), + Asset::CombinatorialOutcome => ExistentialDeposit::get(), + Asset::PoolShare(_) => ExistentialDeposit::get(), + Asset::ScalarOutcome(_,_) => ExistentialDeposit::get(), #[cfg(feature = "parachain")] - Currencies::ForeignAsset(id) => { + Asset::ForeignAsset(id) => { let maybe_metadata = < orml_asset_registry::Pallet as orml_traits::asset_registry::Inspect - >::metadata(&XcmAsset::ForeignAsset(*id)); + >::metadata(&Asset::ForeignAsset(*id)); if let Some(metadata) = maybe_metadata { return metadata.existential_deposit; @@ -529,7 +488,9 @@ parameter_type_with_key! { 1 } #[cfg(not(feature = "parachain"))] - Currencies::ForeignAsset(_) => ExistentialDeposit::get(), + Asset::ForeignAsset(_) => ExistentialDeposit::get(), + Asset::Ztg => ExistentialDeposit::get(), + Asset::ParimutuelShare(_, _) => ExistentialDeposit::get(), } }; } diff --git a/runtime/zeitgeist/src/xcm_config/asset_registry.rs b/runtime/zeitgeist/src/xcm_config/asset_registry.rs index ab6c618a4..4b3b044a6 100644 --- a/runtime/zeitgeist/src/xcm_config/asset_registry.rs +++ b/runtime/zeitgeist/src/xcm_config/asset_registry.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{AssetRegistryStringLimit, Balance, XcmAsset}; +use crate::{AssetRegistryStringLimit, Balance, CurrencyId}; use orml_traits::asset_registry::{AssetMetadata, AssetProcessor}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; @@ -29,14 +29,14 @@ use zeitgeist_primitives::types::CustomMetadata; /// Only pre check is to ensure an asset id was passed. pub struct CustomAssetProcessor; -impl AssetProcessor> +impl AssetProcessor> for CustomAssetProcessor { fn pre_register( - id: Option, + id: Option, metadata: AssetMetadata, ) -> Result< - (XcmAsset, AssetMetadata), + (CurrencyId, AssetMetadata), DispatchError, > { match id { @@ -46,7 +46,7 @@ impl AssetProcessor, ) -> Result<(), DispatchError> { Ok(()) diff --git a/runtime/zeitgeist/src/xcm_config/config.rs b/runtime/zeitgeist/src/xcm_config/config.rs index c86c0feba..4a39a2557 100644 --- a/runtime/zeitgeist/src/xcm_config/config.rs +++ b/runtime/zeitgeist/src/xcm_config/config.rs @@ -18,9 +18,9 @@ use super::fees::{native_per_second, FixedConversionRateProvider}; use crate::{ - AccountId, AssetManager, AssetRegistry, Assets, Balance, MaxAssetsIntoHolding, MaxInstructions, - ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, RuntimeCall, - RuntimeOrigin, UnitWeightCost, UniversalLocation, UnknownTokens, XcmpQueue, + AccountId, AssetManager, AssetRegistry, Balance, CurrencyId, MaxAssetsIntoHolding, + MaxInstructions, ParachainInfo, ParachainSystem, PolkadotXcm, RelayChainOrigin, RelayNetwork, + RuntimeCall, RuntimeOrigin, UnitWeightCost, UniversalLocation, UnknownTokens, XcmpQueue, ZeitgeistTreasuryAccount, }; @@ -52,8 +52,8 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, WithComputedOrigin, }; -use xcm_executor::{traits::TransactAsset, Assets as ExecutorAssets}; -use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::XcmAsset}; +use xcm_executor::{traits::TransactAsset, Assets}; +use zeitgeist_primitives::{constants::BalanceFractionalDecimals, types::Asset}; pub mod zeitgeist { #[cfg(any(test, feature = "runtime-benchmarks"))] @@ -165,7 +165,7 @@ impl TakeRevenue for ToTreasury { if let MultiAsset { id: Concrete(location), fun: Fungible(_amount) } = revenue { if let Some(asset_id) = - >::convert(&location) + >::convert(&location) { let adj_am = AlignedFractionalMultiAssetTransactor::adjust_fractional_places(&revenue).fun; @@ -221,9 +221,9 @@ pub struct AlignedFractionalTransactAsset< } impl< - AssetRegistry: Inspect, + AssetRegistry: Inspect, FracDecPlaces: Get, - CurrencyIdConvert: Convert>, + CurrencyIdConvert: Convert>, TransactAssetDelegate: TransactAsset, > AlignedFractionalTransactAsset< @@ -234,41 +234,29 @@ impl< > { fn adjust_fractional_places(asset: &MultiAsset) -> MultiAsset { - let (asset_id, amount) = - if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { - if let Fungible(amount) = asset.fun { - (*asset_id, amount) - } else { - return asset.clone(); + if let Some(ref asset_id) = CurrencyIdConvert::convert(asset.clone()) { + if let Fungible(amount) = asset.fun { + let mut asset_updated = asset.clone(); + let native_decimals = u32::from(FracDecPlaces::get()); + let metadata = AssetRegistry::metadata(asset_id); + + if let Some(metadata) = metadata { + let decimals = metadata.decimals; + + asset_updated.fun = if decimals > native_decimals { + let power = decimals.saturating_sub(native_decimals); + let adjust_factor = 10u128.saturating_pow(power); + // Floors the adjusted token amount, thus no tokens are generated + Fungible(amount.saturating_div(adjust_factor)) + } else { + let power = native_decimals.saturating_sub(decimals); + let adjust_factor = 10u128.saturating_pow(power); + Fungible(amount.saturating_mul(adjust_factor)) + }; + + return asset_updated; } - } else { - return asset.clone(); - }; - - let currency = if let Ok(currency) = XcmAsset::try_from(asset_id) { - currency - } else { - return asset.clone(); - }; - - let metadata = AssetRegistry::metadata(¤cy); - if let Some(metadata) = metadata { - let mut asset_adjusted = asset.clone(); - let decimals = metadata.decimals; - let native_decimals = u32::from(FracDecPlaces::get()); - - asset_adjusted.fun = if decimals > native_decimals { - let power = decimals.saturating_sub(native_decimals); - let adjust_factor = 10u128.saturating_pow(power); - // Floors the adjusted token amount, thus no tokens are generated - Fungible(amount.saturating_div(adjust_factor)) - } else { - let power = native_decimals.saturating_sub(decimals); - let adjust_factor = 10u128.saturating_pow(power); - Fungible(amount.saturating_mul(adjust_factor)) - }; - - return asset_adjusted; + } } asset.clone() @@ -276,8 +264,8 @@ impl< } impl< - AssetRegistry: Inspect, - CurrencyIdConvert: Convert>, + AssetRegistry: Inspect, + CurrencyIdConvert: Convert>, FracDecPlaces: Get, TransactAssetDelegate: TransactAsset, > TransactAsset @@ -301,7 +289,7 @@ impl< asset: &MultiAsset, location: &MultiLocation, maybe_context: Option<&XcmContext>, - ) -> Result { + ) -> Result { let asset_adjusted = Self::adjust_fractional_places(asset); TransactAssetDelegate::withdraw_asset(&asset_adjusted, location, maybe_context) } @@ -311,7 +299,7 @@ impl< from: &MultiLocation, to: &MultiLocation, context: &XcmContext, - ) -> Result { + ) -> Result { let asset_adjusted = Self::adjust_fractional_places(asset); TransactAssetDelegate::transfer_asset(&asset_adjusted, from, to, context) } @@ -332,17 +320,17 @@ pub type MultiAssetTransactor = MultiCurrencyAdapter< UnknownTokens, // This means that this adapter should handle any token that `AssetConvert` can convert // using AssetManager and UnknownTokens in all other cases. - IsNativeConcrete, + IsNativeConcrete, // Our chain's account ID type (we can't get away without mentioning it explicitly). AccountId, // Convert an XCM `MultiLocation` into a local account id. LocationToAccountId, // The AssetId that corresponds to the native currency. - Assets, + CurrencyId, // Struct that provides functions to convert `Asset` <=> `MultiLocation`. AssetConvert, // In case of deposit failure, known assets will be placed in treasury. - DepositToAlternative, + DepositToAlternative, >; /// AssetConvert @@ -354,35 +342,33 @@ pub struct AssetConvert; /// Convert our `Asset` type into its `MultiLocation` representation. /// Other chains need to know how this conversion takes place in order to /// handle it on their side. -impl Convert> for AssetConvert { - fn convert(id: Assets) -> Option { - >::convert_back(&id) - } -} - -impl Convert> for AssetConvert { - fn convert(location: MultiLocation) -> Option { - >::convert(&location) - } -} - -impl Convert> for AssetConvert { - fn convert(id: XcmAsset) -> Option { - >::convert_back(&id) +impl Convert> for AssetConvert { + fn convert(id: CurrencyId) -> Option { + match id { + Asset::Ztg => Some(MultiLocation::new( + 1, + X2( + Junction::Parachain(ParachainInfo::parachain_id().into()), + general_key(zeitgeist::KEY), + ), + )), + Asset::ForeignAsset(_) => AssetRegistry::multilocation(&id).ok()?, + _ => None, + } } } /// Convert an incoming `MultiLocation` into a `Asset` if possible. /// Here we need to know the canonical representation of all the tokens we handle in order to /// correctly convert their `MultiLocation` representation into our internal `Asset` type. -impl MaybeEquivalence for AssetConvert { - fn convert(location: &MultiLocation) -> Option { +impl MaybeEquivalence for AssetConvert { + fn convert(location: &MultiLocation) -> Option { match location { MultiLocation { parents: 0, interior: X1(GeneralKey { data, length }) } => { let key = &data[..data.len().min(*length as usize)]; if key == zeitgeist::KEY { - return Some(Assets::Ztg); + return Some(CurrencyId::Ztg); } None @@ -394,50 +380,32 @@ impl MaybeEquivalence for AssetConvert { let key = &data[..data.len().min(*length as usize)]; if *para_id == u32::from(ParachainInfo::parachain_id()) { - if key == zeitgeist::KEY { - return Some(Assets::Ztg); - } - - return None; + if key == zeitgeist::KEY { Some(CurrencyId::Ztg) } else { None } + } else { + AssetRegistry::location_to_asset_id(location) } - - AssetRegistry::location_to_asset_id(location).map(|a| a.into()) } - _ => AssetRegistry::location_to_asset_id(location).map(|a| a.into()), + _ => AssetRegistry::location_to_asset_id(location), } } - fn convert_back(id: &Assets) -> Option { + fn convert_back(id: &CurrencyId) -> Option { match id { - Assets::Ztg => Some(MultiLocation::new( + Asset::Ztg => Some(MultiLocation::new( 1, X2( Junction::Parachain(ParachainInfo::parachain_id().into()), general_key(zeitgeist::KEY), ), )), - Assets::ForeignAsset(_) => { - let asset = XcmAsset::try_from(*id).ok()?; - AssetRegistry::multilocation(&asset).ok()? - } + Asset::ForeignAsset(_) => AssetRegistry::multilocation(id).ok()?, _ => None, } } } -impl MaybeEquivalence for AssetConvert { - fn convert(location: &MultiLocation) -> Option { - >::convert(location) - .and_then(|asset| asset.try_into().ok()) - } - - fn convert_back(id: &XcmAsset) -> Option { - >::convert_back(&Assets::from(*id)) - } -} - -impl Convert> for AssetConvert { - fn convert(asset: MultiAsset) -> Option { +impl Convert> for AssetConvert { + fn convert(asset: MultiAsset) -> Option { if let MultiAsset { id: Concrete(location), .. } = asset { >::convert(&location) } else { @@ -446,6 +414,12 @@ impl Convert> for AssetConvert { } } +impl Convert> for AssetConvert { + fn convert(location: MultiLocation) -> Option { + >::convert(&location) + } +} + pub struct AccountIdToMultiLocation; impl Convert for AccountIdToMultiLocation { diff --git a/runtime/zeitgeist/src/xcm_config/fees.rs b/runtime/zeitgeist/src/xcm_config/fees.rs index 0b2f18661..2affbb614 100644 --- a/runtime/zeitgeist/src/xcm_config/fees.rs +++ b/runtime/zeitgeist/src/xcm_config/fees.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . -use crate::{Balance, XcmAsset}; +use crate::{Balance, CurrencyId}; use core::marker::PhantomData; use frame_support::weights::constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}; use xcm::latest::MultiLocation; @@ -56,7 +56,7 @@ pub struct FixedConversionRateProvider(PhantomData impl< AssetRegistry: orml_traits::asset_registry::Inspect< - AssetId = XcmAsset, + AssetId = CurrencyId, Balance = Balance, CustomMetadata = CustomMetadata, >, diff --git a/scripts/benchmarks/configuration.sh b/scripts/benchmarks/configuration.sh index cfc5d46bd..9f13d1edf 100644 --- a/scripts/benchmarks/configuration.sh +++ b/scripts/benchmarks/configuration.sh @@ -4,9 +4,9 @@ EXTERNAL_WEIGHTS_PATH="./runtime/common/src/weights/" # This script contains the configuration for other benchmarking scripts. export FRAME_PALLETS=( - frame_system pallet_assets 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 \ + 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}" diff --git a/zrml/asset-router/Cargo.toml b/zrml/asset-router/Cargo.toml deleted file mode 100644 index 8cb64f93a..000000000 --- a/zrml/asset-router/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[dependencies] -frame-support = { workspace = true } -frame-system = { workspace = true } -log = { workspace = true } -orml-traits = { workspace = true } -pallet-assets = { workspace = true } -parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } -scale-info = { workspace = true, features = ["derive"] } -sp-runtime = { workspace = true } -zeitgeist-macros = { workspace = true } -zeitgeist-primitives = { workspace = true } - -[dev-dependencies] -orml-tokens = { workspace = true, features = ["default"] } -pallet-balances = { workspace = true, features = ["default"] } -sp-io = { workspace = true, features = ["default"] } -test-case = { workspace = true } -zeitgeist-primitives = { workspace = true, features = ["default", "mock"] } - -[features] -default = ["std"] -runtime-benchmarks = ["pallet-assets/runtime-benchmarks"] -std = [ - "frame-support/std", - "frame-system/std", - "orml-traits/std", - "pallet-assets/std", - "parity-scale-codec/std", - "zeitgeist-primitives/std", -] -try-runtime = [ - "frame-support/try-runtime", -] - -[package] -authors = ["Zeitgeist PM "] -edition.workspace = true -name = "zrml-asset-router" -version = "0.5.3" diff --git a/zrml/asset-router/README.md b/zrml/asset-router/README.md deleted file mode 100644 index 34908131e..000000000 --- a/zrml/asset-router/README.md +++ /dev/null @@ -1,61 +0,0 @@ -# Asset Router - -The asset router allows to interact with different asset classes using one -overaching asset class. The caller is not required to be aware of which pallet -handles the asset class of the asset in question, as the asset router internally -routes the call to the appropriate pallet as defined in the pallet's -configuration. - -## Overview - -The asset router implements various ORML `MultiCurrency` traits as well as -various `Fungible` traits, thus it can be used in other pallets that require -those implementation (such as ORML Currencies). The asset router also provides -managed asset destruction, that handles asset destruction for all the assets -registered through the `ManagedDestroy` interface whenever on-chain execution -time is available. Finally, the asset router also provides a lazy migration -mechanism for asset types from the `CurrencyType` to the `MarketAssetType`. - -### Terminology - -- _Asset Type_: An asset type is used to represent assets that share the same - purpose. -- _Asset Class_: An asset class is an overarching collection of multible asset - types that share common properties. -- _Tokens_: Tokens are a countable number of instantiations of a specific asset - type that can be moved between accounts. -- _Lazy Migration_: A lazy migration migrates data and the control over the data - from a source to a destination over a prolonged amount of time, usually per - request of the data or after expiry of the data. -- _Managed Asset Destruction_: A mechanism to automatically destroy an asset - type. - -### Managed Asset Destruction - -Once an asset was registered for managed destruction, it's assigned a state and -stored in a sorted list within the `DestroyAssets` storage. Whenever weight is -available in a block, this pallet will process as many assets as possible from -that sorted list. To achieve that, it loops through all assets one by one and -for each asset, it runs through a state machine that ensures that every step -necessary to properly destroy an asset is executed and that the states are -updated accordingly. It might occur that the pallet that does the actual -destruction, i.e. that is invoked by the managed destruction routine to destroy -a specific asset (using the `Destroy` interface), throws an error. In that case -an asset is considered as `Indestructible` and stored in the -`IndestructibleAssets` storage, while also logging the incident. - -### Lazy migration from `CurrencyClass` to `MarketAssetClass` - -As some asset types within `CurrencyType` and `MarketAssetType` map to the same -asset type in the overarching `AssetType`, it is necessary to apply some -additional logic to determine when a function call with an asset of `AssetType` -should be invoked in `Currencies` and when it should be invoked in -`MarketAssets`. The approach this pallet uses is as follows: - -- Try to convert `AssetType` into `MarketAssetType` -- On success, check if `MarketAssetType` exists. - - If it does, invoke the function in `MarketAssets` - - If it does not, try to convert to `CurrencyType`. - - On success, invoke `Currencies` - - On failure, invoke `MarketAssets` -- On failure, continue trying to convert into other known asset types. diff --git a/zrml/asset-router/src/lib.rs b/zrml/asset-router/src/lib.rs deleted file mode 100644 index 802a2406f..000000000 --- a/zrml/asset-router/src/lib.rs +++ /dev/null @@ -1,520 +0,0 @@ -// Copyright 2023-2024 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 . - -#![feature(proc_macro_hygiene)] -#![doc = include_str!("../README.md")] -#![cfg_attr(not(feature = "std"), no_std)] - -extern crate alloc; - -pub use pallet::*; - -#[macro_use] -mod macros; -#[cfg(test)] -mod mock; -pub mod pallet_impl; -#[cfg(test)] -mod tests; -mod types; - -#[frame_support::pallet] -pub mod pallet { - pub(crate) use super::types::*; - pub(crate) use alloc::collections::BTreeMap; - pub(crate) use core::{fmt::Debug, marker::PhantomData}; - pub(crate) use frame_support::{ - ensure, - pallet_prelude::{DispatchResult, Hooks, StorageValue, ValueQuery, Weight}, - require_transactional, - traits::{ - tokens::{ - fungibles::{Create, Destroy, Inspect, Mutate, Unbalanced}, - DepositConsequence, Fortitude, Precision, Preservation, Provenance, - WithdrawConsequence, - }, - BalanceStatus as Status, ConstU32, - }, - BoundedVec, Parameter, - }; - pub(crate) use frame_system::pallet_prelude::BlockNumberFor; - use log; - pub(crate) use orml_traits::{ - arithmetic::Signed, - currency::{ - MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency, MultiReservableCurrency, - NamedMultiReservableCurrency, TransferAll, - }, - BalanceStatus, LockIdentifier, - }; - pub(crate) use pallet_assets::ManagedDestroy; - use parity_scale_codec::{FullCodec, MaxEncodedLen}; - use scale_info::TypeInfo; - pub(crate) use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Bounded, Get, MaybeSerializeDeserialize, Member, Zero}, - DispatchError, FixedPointOperand, SaturatedConversion, - }; - use zeitgeist_macros::unreachable_non_terminating; - - pub(crate) const LOG_TARGET: &str = "runtime::asset-router"; - pub(crate) const MAX_ASSET_DESTRUCTIONS_PER_BLOCK: u8 = 128; - pub(crate) const MAX_ASSETS_IN_DESTRUCTION: u32 = 2048; - const MAX_INDESTRUCTIBLE_ASSETS: u32 = 256; - // 1 ms minimum computation time. - pub(crate) const MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT: u64 = 1_000_000_000; - - pub trait AssetTraits: - Create - + Destroy - + Inspect - + Mutate - + Unbalanced - { - } - - impl AssetTraits for G - where - G: Create - + Destroy - + Inspect - + Mutate - + Unbalanced, - T: Config, - { - } - - #[pallet::config] - pub trait Config: frame_system::Config { - /// The overarching asset type that contains all assets classes. - type AssetType: Copy - + Debug - + Eq - + From - + From - + From - + From - + FullCodec - + MaxEncodedLen - + MaybeSerializeDeserialize - + Ord - + TypeInfo; - - /// The type that represents balances. - type Balance: Parameter - + Member - + AtLeast32BitUnsigned - + Default - + Copy - + MaybeSerializeDeserialize - + MaxEncodedLen - + FixedPointOperand; - - /// Logic that handles campaign assets by providing multiple fungible - /// trait implementations. - type CampaignAssets: AssetTraits; - /// The custom asset type. - type CampaignAssetType: TryFrom - + Copy - + Debug - + Eq - + FullCodec - + MaxEncodedLen - + MaybeSerializeDeserialize - + TypeInfo; - - /// Logic that handles currencies by providing multiple currencies - /// trait implementations. - type Currencies: TransferAll - + MultiCurrencyExtended< - Self::AccountId, - CurrencyId = Self::CurrencyType, - Balance = Self::Balance, - > + MultiLockableCurrency - + MultiReservableCurrency - + NamedMultiReservableCurrency - + Unbalanced; - /// The currency type. - type CurrencyType: TryFrom - + Copy - + Debug - + Eq - + FullCodec - + MaxEncodedLen - + MaybeSerializeDeserialize - + TypeInfo; - - /// Logic that handles custom assets by providing multiple fungible - /// trait implementations. - type CustomAssets: AssetTraits; - /// The custom asset type. - type CustomAssetType: TryFrom - + Copy - + Debug - + Eq - + FullCodec - + MaxEncodedLen - + MaybeSerializeDeserialize - + TypeInfo; - - /// Weight required for destroying one account. - type DestroyAccountWeight: Get; - /// Weight required for destroying one approval. - type DestroyApprovalWeight: Get; - /// Weight required for finishing the asset destruction process. - type DestroyFinishWeight: Get; - - /// Logic that handles market assets by providing multiple fungible - /// trait implementations. - type MarketAssets: AssetTraits; - /// The market asset type. - type MarketAssetType: TryFrom - + Copy - + Debug - + Eq - + FullCodec - + MaxEncodedLen - + MaybeSerializeDeserialize - + TypeInfo; - } - - /// Keeps track of assets that have to be destroyed. - #[pallet::storage] - pub(super) type DestroyAssets = StorageValue<_, DestroyAssetsT, ValueQuery>; - - /// Keeps track of assets that can't be destroyed. - #[pallet::storage] - pub(crate) type IndestructibleAssets = - StorageValue<_, BoundedVec>, ValueQuery>; - - #[pallet::error] - pub enum Error { - /// Cannot convert Amount (MultiCurrencyExtended implementation) into Balance type. - AmountIntoBalanceFailed, - /// Cannot start managed destruction as the asset was marked as indestructible. - AssetIndestructible, - /// Cannot start managed destruction as a destruction for the asset is in progress. - DestructionInProgress, - /// The vector holding all assets to destroy reached it's boundary. - TooManyManagedDestroys, - /// Asset conversion failed. - UnknownAsset, - /// Operation is not supported for given asset - Unsupported, - /// Only a partial amount was deposited - DepositOnlyPartial, - } - - #[pallet::pallet] - pub struct Pallet(PhantomData); - - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_idle(_: BlockNumberFor, mut remaining_weight: Weight) -> Weight { - let max_extra_weight = Self::on_idle_max_extra_weight(); - - if !remaining_weight - .all_gte(max_extra_weight.saturating_add(T::DbWeight::get().reads(1))) - { - return remaining_weight; - }; - - let mut destroy_assets = DestroyAssets::::get(); - if destroy_assets.len() == 0 { - return remaining_weight.saturating_sub(T::DbWeight::get().reads(1)); - } - - remaining_weight = remaining_weight - .saturating_sub(T::DbWeight::get().reads_writes(1, 1)) - .saturating_sub(max_extra_weight); - - remaining_weight = - Self::handle_asset_destruction(remaining_weight, &mut destroy_assets); - - DestroyAssets::::put(destroy_assets); - remaining_weight - } - } - - impl Pallet { - fn handle_asset_destruction( - mut remaining_weight: Weight, - destroy_assets: &mut DestroyAssetsT, - ) -> Weight { - let mut saftey_counter_outer = 0u8; - - 'outer: while let Some(mut asset) = destroy_assets.pop() { - // Only reachable if there is an error in the implementation of pop() for Vec. - unreachable_non_terminating!( - saftey_counter_outer != MAX_ASSET_DESTRUCTIONS_PER_BLOCK, - LOG_TARGET, - break, - "Destruction outer loop iteration guard triggered, iteration: {:?}", - saftey_counter_outer - ); - - let safety_counter_inner_max = DESTRUCTION_STATES; - let mut safety_counter_inner = 0u8; - - while *asset.state() != DestructionState::Destroyed - && *asset.state() != DestructionState::Indestructible - && safety_counter_inner < safety_counter_inner_max - { - match asset.state() { - DestructionState::Accounts => { - handle_asset_destruction!( - &mut asset, - remaining_weight, - destroy_assets, - handle_destroy_accounts, - 'outer - ); - } - DestructionState::Approvals => { - handle_asset_destruction!( - &mut asset, - remaining_weight, - destroy_assets, - handle_destroy_approvals, - 'outer - ); - } - DestructionState::Finalization => { - handle_asset_destruction!( - &mut asset, - remaining_weight, - destroy_assets, - handle_destroy_finish, - 'outer - ); - } - // Next two states should never occur. Just remove the asset. - DestructionState::Destroyed => { - unreachable_non_terminating!( - false, - LOG_TARGET, - "Asset {:?} has invalid state", - asset - ); - } - DestructionState::Indestructible => { - unreachable_non_terminating!( - false, - LOG_TARGET, - "Asset {:?} has invalid state", - asset - ); - } - } - - safety_counter_inner = safety_counter_inner.saturating_add(1); - } - - // Only reachable if there is an error in the destruction state machine. - unreachable_non_terminating!( - safety_counter_inner != safety_counter_inner_max, - LOG_TARGET, - "Destruction inner loop iteration guard triggered, asset: {:?}", - asset - ); - - saftey_counter_outer = saftey_counter_outer.saturating_add(1); - } - - remaining_weight - } - - fn handle_destroy_accounts( - asset: &mut AssetInDestruction, - mut remaining_weight: Weight, - ) -> DestructionResult { - if *asset.state() != DestructionState::Accounts { - return Err(DestructionError::WrongState(remaining_weight)); - } - let destroy_account_weight = T::DestroyAccountWeight::get(); - - let destroy_account_cap = - match remaining_weight.checked_div_per_component(&destroy_account_weight) { - Some(amount) => amount, - None => return Ok(DestructionOk::Incomplete(remaining_weight)), - }; - - match Self::destroy_accounts(*asset.asset(), destroy_account_cap.saturated_into()) { - Ok(destroyed_accounts) => { - // TODO(#1202): More precise weights - remaining_weight = remaining_weight.saturating_sub( - destroy_account_weight - .saturating_mul(destroyed_accounts.into()) - .max(destroy_account_weight), - ); - - if u64::from(destroyed_accounts) != destroy_account_cap { - asset.transit_state(); - Ok(DestructionOk::Complete(remaining_weight)) - } else { - Ok(DestructionOk::Incomplete(remaining_weight)) - } - } - Err(e) => { - // In this case, it is not known how many accounts have been destroyed prior - // to triggering this error. The only safe handling is consuming all the - // remaining weight. - let _ = Self::mark_asset_as_indestructible( - asset, - remaining_weight, - remaining_weight, - e, - ); - // Play it safe, consume all remaining weight. - Err(DestructionError::Indestructible(Weight::zero())) - } - } - } - - fn handle_destroy_approvals( - asset: &mut AssetInDestruction, - mut remaining_weight: Weight, - ) -> DestructionResult { - if *asset.state() != DestructionState::Approvals { - return Err(DestructionError::WrongState(remaining_weight)); - } - let destroy_approval_weight = T::DestroyApprovalWeight::get(); - - let destroy_approval_cap = - match remaining_weight.checked_div_per_component(&destroy_approval_weight) { - Some(amount) => amount, - None => return Ok(DestructionOk::Incomplete(remaining_weight)), - }; - - match Self::destroy_approvals(*asset.asset(), destroy_approval_cap.saturated_into()) { - Ok(destroyed_approvals) => { - // TODO(#1202): More precise weights - remaining_weight = remaining_weight.saturating_sub( - destroy_approval_weight - .saturating_mul(destroyed_approvals.into()) - .max(destroy_approval_weight), - ); - - if u64::from(destroyed_approvals) != destroy_approval_cap { - asset.transit_state(); - Ok(DestructionOk::Complete(remaining_weight)) - } else { - Ok(DestructionOk::Incomplete(remaining_weight)) - } - } - Err(e) => { - // In this case, it is not known how many approvals have been destroyed prior - // to triggering this error. The only safe handling is consuming all the - // remaining weight. - let _ = Self::mark_asset_as_indestructible( - asset, - remaining_weight, - remaining_weight, - e, - ); - // Play it safe, consume all remaining weight. - Err(DestructionError::Indestructible(Weight::zero())) - } - } - } - - fn handle_destroy_finish( - asset: &mut AssetInDestruction, - remaining_weight: Weight, - ) -> DestructionResult { - if *asset.state() != DestructionState::Finalization { - return Err(DestructionError::WrongState(remaining_weight)); - } - let destroy_finish_weight = T::DestroyFinishWeight::get(); - - if remaining_weight.all_gte(destroy_finish_weight) { - // TODO(#1202): More precise weights - if let Err(e) = Self::finish_destroy(*asset.asset()) { - let remaining_weight_err = Self::mark_asset_as_indestructible( - asset, - remaining_weight, - destroy_finish_weight, - e, - ); - return Err(DestructionError::Indestructible(remaining_weight_err)); - } - - asset.transit_state(); - return Ok(DestructionOk::Complete( - remaining_weight.saturating_sub(destroy_finish_weight), - )); - } - - Ok(DestructionOk::Incomplete(remaining_weight)) - } - - fn mark_asset_as_indestructible( - asset: &mut AssetInDestruction, - mut remaining_weight: Weight, - max_weight: Weight, - error: DispatchError, - ) -> Weight { - let asset_inner = *asset.asset(); - - log::error!( - target: LOG_TARGET, - "Error during managed asset account destruction of {:?}: {:?}", - asset_inner, - error - ); - - remaining_weight = remaining_weight.saturating_sub(max_weight); - - if let Err(e) = IndestructibleAssets::::try_mutate(|assets| { - let idx = assets.partition_point(|&asset_in_vec| asset_in_vec < asset_inner); - assets.try_insert(idx, asset_inner) - }) { - log::error!( - target: LOG_TARGET, - "Error during storage of indestructible asset {:?}, dropping asset: {:?}", - asset_inner, - e - ); - } - - asset.transit_indestructible(); - remaining_weight.saturating_sub(T::DbWeight::get().reads_writes(1, 1)) - } - - fn on_idle_max_extra_weight() -> Weight { - let max_proof_size_destructibles: u64 = - AssetInDestruction::::max_encoded_len() - .saturating_mul(MAX_ASSETS_IN_DESTRUCTION.saturated_into()) - .saturated_into(); - let max_proof_size_indestructibles: u64 = T::AssetType::max_encoded_len() - .saturating_mul(MAX_INDESTRUCTIBLE_ASSETS.saturated_into()) - .saturated_into(); - let max_proof_size_total = - max_proof_size_destructibles.saturating_add(max_proof_size_indestructibles); - - Weight::from_parts( - MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, - // Maximum proof size assuming writes on full storage. - max_proof_size_total, - ) - } - - #[inline] - pub(crate) fn log_unsupported(asset: T::AssetType, function: &str) { - log::warn!(target: LOG_TARGET, "Asset {:?} not supported in function {:?}", asset, function); - } - } -} diff --git a/zrml/asset-router/src/macros.rs b/zrml/asset-router/src/macros.rs deleted file mode 100644 index 06dff530c..000000000 --- a/zrml/asset-router/src/macros.rs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2024 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 . - -/// This macro converts the invoked asset type into the respective -/// implementation that handles it and finally calls the $method on it. -macro_rules! route_call { - ($currency_id:expr, $currency_method:ident, $asset_method:ident, $($args:expr),*) => { - if let Ok(asset) = T::MarketAssetType::try_from($currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - Ok(T::MarketAssets::$asset_method(asset, $($args),*)) - } else { - if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - Ok(>::$currency_method(currency, $($args),*)) - } else { - Ok(T::MarketAssets::$asset_method(asset, $($args),*)) - } - } - } else if let Ok(asset) = T::CampaignAssetType::try_from($currency_id) { - Ok(T::CampaignAssets::$asset_method(asset, $($args),*)) - } else if let Ok(asset) = T::CustomAssetType::try_from($currency_id) { - Ok(T::CustomAssets::$asset_method(asset, $($args),*)) - } else if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - Ok(>::$currency_method(currency, $($args),*)) - } else { - Err(Error::::UnknownAsset) - } - }; -} - -macro_rules! route_call_with_trait { - ($currency_id:expr, $trait:ident, $method:ident, $($args:expr),*) => { - if let Ok(asset) = T::MarketAssetType::try_from($currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - Ok(>::$method(asset, $($args),*)) - } else { - if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - Ok(>::$method(currency, $($args),*)) - } else { - Ok(>::$method(asset, $($args),*)) - } - } - } else if let Ok(asset) = T::CampaignAssetType::try_from($currency_id) { - Ok(>::$method(asset, $($args),*)) - } else if let Ok(asset) = T::CustomAssetType::try_from($currency_id) { - Ok(>::$method(asset, $($args),*)) - } else if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - Ok(>::$method(currency, $($args),*)) - } else { - Err(Error::::UnknownAsset) - } - }; -} - -/// This macro delegates a call to Currencies if the asset represents a currency, otherwise -/// it returns an error. -macro_rules! only_currency { - ($currency_id:expr, $error:expr, $currency_trait:ident, $currency_method:ident, $($args:expr),+) => { - if let Ok(asset) = T::MarketAssetType::try_from($currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - Self::log_unsupported($currency_id, stringify!($currency_method)); - $error - } else { - if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - >::$currency_method(currency, $($args),+) - } else { - Self::log_unsupported($currency_id, stringify!($currency_method)); - $error - } - } - } - else if let Ok(currency) = T::CurrencyType::try_from($currency_id) { - >::$currency_method(currency, $($args),+) - } else { - Self::log_unsupported($currency_id, stringify!($currency_method)); - $error - } - }; -} - -/// This macro delegates a call to one *Asset instance if the asset does not represent a currency, -/// otherwise it returns an error. -macro_rules! only_asset { - ($asset_id:expr, $error:expr, $asset_trait:ident, $asset_method:ident, $($args:expr),*) => { - if let Ok(asset) = T::MarketAssetType::try_from($asset_id) { - >::$asset_method(asset, $($args),*) - } else if let Ok(asset) = T::CampaignAssetType::try_from($asset_id) { - T::CampaignAssets::$asset_method(asset, $($args),*) - } else if let Ok(asset) = T::CustomAssetType::try_from($asset_id) { - T::CustomAssets::$asset_method(asset, $($args),*) - } else { - Self::log_unsupported($asset_id, stringify!($asset_method)); - $error - } - }; -} - -/// This macro handles the single stages of the asset destruction. -macro_rules! handle_asset_destruction { - ($asset:expr, $remaining_weight:expr, $asset_storage:expr, $asset_method:ident, $outer_loop:tt) => { - let state_before = *($asset.state()); - let call_result = Self::$asset_method($asset, $remaining_weight); - match call_result { - Ok(DestructionOk::Incomplete(weight)) => { - // Should be infallible since the asset was just popped and force inserting - // is not possible. - if let Err(e) = $asset_storage.try_insert($asset_storage.len(), *($asset)) { - log::error!( - target: LOG_TARGET, - "Cannot reintroduce asset {:?} into DestroyAssets storage: {:?}", - $asset, - e - ); - } - - $remaining_weight = weight; - break $outer_loop; - }, - Ok(DestructionOk::Complete(weight)) | Err(DestructionError::WrongState(weight)) => { - $remaining_weight = weight; - }, - Err(DestructionError::Indestructible(weight)) => { - $remaining_weight = weight; - - if state_before != DestructionState::Finalization { - break $outer_loop; - } else { - // In case destruction failed during finalization, there is most likely still - // some weight available. - break; - } - } - } - }; -} diff --git a/zrml/asset-router/src/mock.rs b/zrml/asset-router/src/mock.rs deleted file mode 100644 index 0b9486104..000000000 --- a/zrml/asset-router/src/mock.rs +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2023-2024 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)] - -extern crate alloc; - -use crate::{self as zrml_asset_router}; -use alloc::{collections::BTreeMap, vec, vec::Vec}; -use frame_support::{ - construct_runtime, - pallet_prelude::{DispatchResult, Weight}, - traits::{AsEnsureOriginWithArg, Everything}, -}; -use frame_system::{mocking::MockBlock, EnsureSigned}; -use orml_traits::parameter_type_with_key; -use pallet_assets::ManagedDestroy; -use parity_scale_codec::Compact; -use sp_runtime::{ - traits::{parameter_types, BlakeTwo256, ConstU128, ConstU32, IdentityLookup}, - BuildStorage, -}; -use zeitgeist_primitives::{ - constants::mock::{BlockHashCount, ExistentialDeposit, MaxLocks, MaxReserves, BASE}, - types::{ - AccountIdTest, Amount, Assets, Balance, CampaignAsset, CampaignAssetClass, CampaignAssetId, - Currencies, CustomAsset, CustomAssetClass, CustomAssetId, Hash, MarketAsset, - }, -}; - -pub(super) const ALICE: AccountIdTest = 0; -pub(super) const BOB: AccountIdTest = 1; -pub(super) const CHARLIE: AccountIdTest = 2; - -pub(super) const CAMPAIGN_ASSET: Assets = Assets::CampaignAsset(0); -pub(super) const CAMPAIGN_ASSET_INTERNAL: CampaignAssetClass = CampaignAssetClass(0); -pub(super) const CUSTOM_ASSET: Assets = Assets::CustomAsset(0); -pub(super) const CUSTOM_ASSET_INTERNAL: CustomAssetClass = CustomAssetClass(0); -pub(super) const MARKET_ASSET: Assets = Assets::CategoricalOutcome(7, 8); -pub(super) const MARKET_ASSET_INTERNAL: MarketAsset = MarketAsset::CategoricalOutcome(7, 8); -pub(super) const CURRENCY: Assets = Assets::ForeignAsset(0); -pub(super) const CURRENCY_OLD_OUTCOME: Assets = Assets::CategoricalOutcome(7, 8); -pub(super) const CURRENCY_INTERNAL: Currencies = Currencies::ForeignAsset(0); - -pub(super) const CAMPAIGN_ASSET_MIN_BALANCE: Balance = 2; -pub(super) const CUSTOM_ASSET_MIN_BALANCE: Balance = 3; -pub(super) const MARKET_ASSET_MIN_BALANCE: Balance = 4; -pub(super) const CURRENCY_MIN_BALANCE: Balance = 5; - -pub(super) const CAMPAIGN_ASSET_INITIAL_AMOUNT: Balance = 10; -pub(super) const CUSTOM_ASSET_INITIAL_AMOUNT: Balance = 20; -pub(super) const MARKET_ASSET_INITIAL_AMOUNT: Balance = 30; -pub(super) const CURRENCY_INITIAL_AMOUNT: Balance = 40; - -pub(super) const DESTROY_WEIGHT: Weight = Weight::from_parts(1000, 0); - -pub(super) type AccountId = ::AccountId; -pub(super) type CustomAssetsInstance = pallet_assets::Instance1; -pub(super) type CampaignAssetsInstance = pallet_assets::Instance2; -pub(super) type MarketAssetsInstance = pallet_assets::Instance3; - -parameter_types! { - pub const DestroyWeight: Weight = DESTROY_WEIGHT; -} - -construct_runtime!( - pub enum Runtime { - AssetRouter: zrml_asset_router, - Balances: pallet_balances, - CustomAssets: pallet_assets::, - CampaignAssets: pallet_assets::, - MarketAssets: pallet_assets::, - System: frame_system, - Tokens: orml_tokens, - } -); - -impl crate::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyWeight; - type DestroyApprovalWeight = DestroyWeight; - type DestroyFinishWeight = DestroyWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - -impl frame_system::Config for Runtime { - type AccountData = pallet_balances::AccountData; - type AccountId = AccountIdTest; - type BaseCallFilter = Everything; - type Block = MockBlock; - type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockWeights = (); - type RuntimeCall = RuntimeCall; - type DbWeight = (); - type RuntimeEvent = RuntimeEvent; - type Hash = Hash; - type Hashing = BlakeTwo256; - type Lookup = IdentityLookup; - type Nonce = u64; - type MaxConsumers = frame_support::traits::ConstU32<16>; - type OnKilledAccount = (); - type OnNewAccount = (); - type RuntimeOrigin = RuntimeOrigin; - type PalletInfo = PalletInfo; - type SS58Prefix = (); - type SystemWeightInfo = (); - type Version = (); - type OnSetCode = (); -} - -parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: Currencies| -> Balance { - CURRENCY_MIN_BALANCE - }; -} - -impl orml_tokens::Config for Runtime { - type Amount = Amount; - type Balance = Balance; - type CurrencyId = Currencies; - type DustRemovalWhitelist = (); - type RuntimeEvent = RuntimeEvent; - type ExistentialDeposits = ExistentialDeposits; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type CurrencyHooks = (); - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); -} - -// Required for runtime benchmarks -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = ConstU128<0>; - type AssetAccountDeposit = ConstU128<0>; - type AssetDeposit = ConstU128<0>; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureSigned; - type Destroyer = AssetRouter; - type Freezer = (); - type MetadataDepositBase = ConstU128<0>; - type MetadataDepositPerByte = ConstU128<0>; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = ConstU32<255>; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = ConstU128<0>; - type AssetAccountDeposit = ConstU128<0>; - type AssetDeposit = ConstU128<0>; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureSigned; - type Destroyer = AssetRouter; - type Freezer = (); - type MetadataDepositBase = ConstU128<0>; - type MetadataDepositPerByte = ConstU128<0>; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = ConstU32<255>; - type WeightInfo = (); -} - -// Required for runtime benchmarks -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = ConstU128<0>; - type AssetAccountDeposit = ConstU128<0>; - type AssetDeposit = ConstU128<0>; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureSigned; - type Destroyer = AssetRouter; - type Freezer = (); - type MetadataDepositBase = ConstU128<0>; - type MetadataDepositPerByte = ConstU128<0>; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = ConstU32<255>; - type WeightInfo = (); -} - -impl pallet_balances::Config for Runtime { - type AccountStore = System; - type Balance = Balance; - type DustRemoval = (); - type FreezeIdentifier = (); - type RuntimeHoldReason = (); - type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; - type MaxHolds = (); - type MaxFreezes = (); - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); -} - -pub(super) struct ExtBuilder { - balances: Vec<(AccountIdTest, Balance)>, -} - -impl Default for ExtBuilder { - fn default() -> Self { - Self { balances: vec![(ALICE, 1_000 * BASE), (BOB, 1_000 * BASE), (CHARLIE, 1_000 * BASE)] } - } -} - -impl ExtBuilder { - pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - - pallet_balances::GenesisConfig:: { balances: self.balances } - .assimilate_storage(&mut t) - .unwrap(); - - t.into() - } -} - -#[frame_support::transactional] -pub(super) fn managed_destroy_multi_transactional( - assets: BTreeMap>, -) -> DispatchResult { - AssetRouter::managed_destroy_multi(assets) -} diff --git a/zrml/asset-router/src/pallet_impl/balanced.rs b/zrml/asset-router/src/pallet_impl/balanced.rs deleted file mode 100644 index 2a55f30bc..000000000 --- a/zrml/asset-router/src/pallet_impl/balanced.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; -use frame_support::traits::tokens::fungibles::{Balanced, DecreaseIssuance, IncreaseIssuance}; - -impl Balanced for Pallet { - type OnDropCredit = DecreaseIssuance; - type OnDropDebt = IncreaseIssuance; -} diff --git a/zrml/asset-router/src/pallet_impl/create.rs b/zrml/asset-router/src/pallet_impl/create.rs deleted file mode 100644 index 3e59e1e5d..000000000 --- a/zrml/asset-router/src/pallet_impl/create.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl Create for Pallet { - fn create( - id: Self::AssetId, - admin: T::AccountId, - is_sufficient: bool, - min_balance: Self::Balance, - ) -> DispatchResult { - only_asset!( - id, - Err(Error::::Unsupported.into()), - Create, - create, - admin, - is_sufficient, - min_balance - ) - } -} diff --git a/zrml/asset-router/src/pallet_impl/destroy.rs b/zrml/asset-router/src/pallet_impl/destroy.rs deleted file mode 100644 index 7058b2499..000000000 --- a/zrml/asset-router/src/pallet_impl/destroy.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl Destroy for Pallet { - fn start_destroy(id: Self::AssetId, maybe_check_owner: Option) -> DispatchResult { - only_asset!( - id, - Err(Error::::Unsupported.into()), - Destroy, - start_destroy, - maybe_check_owner - ) - } - - fn destroy_accounts(id: Self::AssetId, max_items: u32) -> Result { - only_asset!(id, Err(Error::::Unsupported.into()), Destroy, destroy_accounts, max_items) - } - - fn destroy_approvals(id: Self::AssetId, max_items: u32) -> Result { - only_asset!(id, Err(Error::::Unsupported.into()), Destroy, destroy_approvals, max_items) - } - - fn finish_destroy(id: Self::AssetId) -> DispatchResult { - only_asset!(id, Err(Error::::Unsupported.into()), Destroy, finish_destroy,) - } -} diff --git a/zrml/asset-router/src/pallet_impl/inspect.rs b/zrml/asset-router/src/pallet_impl/inspect.rs deleted file mode 100644 index 22e441e98..000000000 --- a/zrml/asset-router/src/pallet_impl/inspect.rs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -// Supertrait of Create and Destroy -impl Inspect for Pallet { - type AssetId = T::AssetType; - type Balance = T::Balance; - - fn total_issuance(asset: Self::AssetId) -> Self::Balance { - route_call_with_trait!(asset, Inspect, total_issuance,).unwrap_or(Zero::zero()) - } - - fn active_issuance(asset: Self::AssetId) -> Self::Balance { - route_call_with_trait!(asset, Inspect, active_issuance,).unwrap_or(Zero::zero()) - } - - fn minimum_balance(asset: Self::AssetId) -> Self::Balance { - route_call_with_trait!(asset, Inspect, minimum_balance,).unwrap_or(Zero::zero()) - } - - fn balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance { - route_call_with_trait!(asset, Inspect, balance, who).unwrap_or(Zero::zero()) - } - - fn total_balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance { - route_call_with_trait!(asset, Inspect, total_balance, who).unwrap_or(Zero::zero()) - } - - fn reducible_balance( - asset: Self::AssetId, - who: &T::AccountId, - preservation: Preservation, - force: Fortitude, - ) -> Self::Balance { - route_call_with_trait!(asset, Inspect, reducible_balance, who, preservation, force) - .unwrap_or(Zero::zero()) - } - - fn can_deposit( - asset: Self::AssetId, - who: &T::AccountId, - amount: Self::Balance, - provenance: Provenance, - ) -> DepositConsequence { - route_call_with_trait!(asset, Inspect, can_deposit, who, amount, provenance) - .unwrap_or(DepositConsequence::UnknownAsset) - } - - fn can_withdraw( - asset: Self::AssetId, - who: &T::AccountId, - amount: Self::Balance, - ) -> WithdrawConsequence { - route_call_with_trait!(asset, Inspect, can_withdraw, who, amount) - .unwrap_or(WithdrawConsequence::UnknownAsset) - } - - fn asset_exists(asset: Self::AssetId) -> bool { - route_call_with_trait!(asset, Inspect, asset_exists,).unwrap_or(false) - } -} diff --git a/zrml/asset-router/src/pallet_impl/managed_destroy.rs b/zrml/asset-router/src/pallet_impl/managed_destroy.rs deleted file mode 100644 index fd22ac6b0..000000000 --- a/zrml/asset-router/src/pallet_impl/managed_destroy.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl Pallet { - fn add_asset_to_managed_destruction( - destroy_assets: &mut DestroyAssetsT, - asset: T::AssetType, - maybe_check_owner: Option, - ) -> DispatchResult { - ensure!(Self::asset_exists(asset), Error::::UnknownAsset); - frame_support::ensure!(!destroy_assets.is_full(), Error::::TooManyManagedDestroys); - let asset_to_insert = AssetInDestruction::new(asset); - - let idx = match destroy_assets.binary_search(&asset_to_insert) { - Ok(_) => return Err(Error::::DestructionInProgress.into()), - Err(idx) => { - if IndestructibleAssets::::get().binary_search(&asset).is_ok() { - return Err(Error::::AssetIndestructible.into()); - } - - idx - } - }; - - destroy_assets - .try_insert(idx, asset_to_insert) - .map_err(|_| Error::::TooManyManagedDestroys)?; - - Self::start_destroy(asset, maybe_check_owner)?; - Ok(()) - } -} - -impl ManagedDestroy for Pallet { - fn managed_destroy( - asset: Self::AssetId, - maybe_check_owner: Option, - ) -> DispatchResult { - let mut destroy_assets = DestroyAssets::::get(); - Self::add_asset_to_managed_destruction(&mut destroy_assets, asset, maybe_check_owner)?; - DestroyAssets::::put(destroy_assets); - Ok(()) - } - - fn managed_destroy_multi( - assets: BTreeMap>, - ) -> DispatchResult { - let mut destroy_assets = DestroyAssets::::get(); - - for (asset, maybe_check_owner) in assets { - Self::add_asset_to_managed_destruction(&mut destroy_assets, asset, maybe_check_owner)?; - } - - DestroyAssets::::put(destroy_assets); - Ok(()) - } -} diff --git a/zrml/asset-router/src/pallet_impl/mod.rs b/zrml/asset-router/src/pallet_impl/mod.rs deleted file mode 100644 index 6e6928d8c..000000000 --- a/zrml/asset-router/src/pallet_impl/mod.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2024 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 . - -pub mod balanced; -pub mod create; -pub mod destroy; -pub mod inspect; -pub mod managed_destroy; -pub mod multi_currency; -pub mod multi_currency_extended; -pub mod multi_lockable_currency; -pub mod multi_reserveable_currency; -pub mod named_multi_reserveable_currency; -pub mod transfer_all; -pub mod unbalanced; diff --git a/zrml/asset-router/src/pallet_impl/multi_currency.rs b/zrml/asset-router/src/pallet_impl/multi_currency.rs deleted file mode 100644 index 6d812aca9..000000000 --- a/zrml/asset-router/src/pallet_impl/multi_currency.rs +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl MultiCurrency for Pallet { - type CurrencyId = T::AssetType; - type Balance = T::Balance; - - fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance { - let min_balance = route_call!(currency_id, minimum_balance, minimum_balance,); - min_balance.unwrap_or_else(|_b| { - Self::log_unsupported(currency_id, "minimum_balance"); - Self::Balance::zero() - }) - } - - fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance { - let total_issuance = route_call!(currency_id, total_issuance, total_issuance,); - total_issuance.unwrap_or_else(|_b| { - Self::log_unsupported(currency_id, "total_issuance"); - Self::Balance::zero() - }) - } - - fn total_balance(currency_id: Self::CurrencyId, who: &T::AccountId) -> Self::Balance { - let total_balance = route_call!(currency_id, total_balance, balance, who); - total_balance.unwrap_or_else(|_b| { - Self::log_unsupported(currency_id, "total_balance"); - Self::Balance::zero() - }) - } - - fn free_balance(currency_id: Self::CurrencyId, who: &T::AccountId) -> Self::Balance { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - T::MarketAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Polite, - ) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::free_balance(currency, who) - } else { - T::MarketAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Polite, - ) - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Polite, - ) - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Polite, - ) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::free_balance(currency, who) - } else { - Self::log_unsupported(currency_id, "free_balance"); - Self::Balance::zero() - } - } - - fn ensure_can_withdraw( - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - let withdraw_consequence = if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - T::MarketAssets::can_withdraw(asset, who, amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return T::Currencies::ensure_can_withdraw(currency, who, amount); - } else { - T::MarketAssets::can_withdraw(asset, who, amount) - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::can_withdraw(asset, who, amount) - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::can_withdraw(asset, who, amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return T::Currencies::ensure_can_withdraw(currency, who, amount); - } else { - return Err(Error::::UnknownAsset.into()); - }; - - withdraw_consequence.into_result(false).map(|_| ()) - } - - fn transfer( - currency_id: Self::CurrencyId, - from: &T::AccountId, - to: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - T::MarketAssets::transfer(asset, from, to, amount, Preservation::Expendable) - .map(|_| ()) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::transfer(currency, from, to, amount) - } else { - T::MarketAssets::transfer(asset, from, to, amount, Preservation::Expendable) - .map(|_| ()) - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::transfer(asset, from, to, amount, Preservation::Expendable) - .map(|_| ()) - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::transfer(asset, from, to, amount, Preservation::Expendable).map(|_| ()) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::transfer(currency, from, to, amount) - } else { - Err(Error::::UnknownAsset.into()) - } - } - - fn deposit( - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - let eval_fungible_result = |b: Self::Balance| { - if b != amount { Err(Error::::DepositOnlyPartial.into()) } else { Ok(()) } - }; - - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - T::MarketAssets::mint_into(asset, who, amount).and_then(eval_fungible_result) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::deposit(currency, who, amount) - } else { - T::MarketAssets::mint_into(asset, who, amount).and_then(eval_fungible_result) - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::mint_into(asset, who, amount).and_then(eval_fungible_result) - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::mint_into(asset, who, amount).and_then(eval_fungible_result) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::deposit(currency, who, amount) - } else { - Err(Error::::UnknownAsset.into()) - } - } - - fn withdraw( - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - // Resulting balance can be ignored as `burn_from` ensures that the - // requested amount can be burned. - T::MarketAssets::burn_from(asset, who, amount, Precision::Exact, Fortitude::Force) - .map(|_| ()) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::withdraw(currency, who, amount) - } else { - T::MarketAssets::burn_from(asset, who, amount, Precision::Exact, Fortitude::Force) - .map(|_| ()) - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::burn_from(asset, who, amount, Precision::Exact, Fortitude::Force) - .map(|_| ()) - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::burn_from(asset, who, amount, Precision::Exact, Fortitude::Force) - .map(|_| ()) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::withdraw(currency, who, amount) - } else { - Err(Error::::UnknownAsset.into()) - } - } - - fn can_slash(currency_id: Self::CurrencyId, who: &T::AccountId, value: Self::Balance) -> bool { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - // Resulting balance can be ignored as `burn_from` ensures that the - // requested amount can be burned. - T::MarketAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Force, - ) >= value - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::can_slash(currency, who, value) - } else { - T::MarketAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Force, - ) >= value - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Force, - ) >= value - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::reducible_balance( - asset, - who, - Preservation::Expendable, - Fortitude::Force, - ) >= value - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::can_slash(currency, who, value) - } else { - Self::log_unsupported(currency_id, "can_slash"); - false - } - } - - fn slash( - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> Self::Balance { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - // Resulting balance can be ignored as `burn_from` ensures that the - // requested amount can be burned. - Self::withdraw(currency_id, who, amount).map(|_| Zero::zero()).unwrap_or(amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::slash(currency, who, amount) - } else { - Self::withdraw(currency_id, who, amount).map(|_| Zero::zero()).unwrap_or(amount) - } - } else if T::CampaignAssetType::try_from(currency_id).is_ok() { - Self::withdraw(currency_id, who, amount).map(|_| Zero::zero()).unwrap_or(amount) - } else if T::CustomAssetType::try_from(currency_id).is_ok() { - Self::withdraw(currency_id, who, amount).map(|_| Zero::zero()).unwrap_or(amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::slash(currency, who, amount) - } else { - Self::log_unsupported(currency_id, "slash"); - amount - } - } -} diff --git a/zrml/asset-router/src/pallet_impl/multi_currency_extended.rs b/zrml/asset-router/src/pallet_impl/multi_currency_extended.rs deleted file mode 100644 index 70ea1f499..000000000 --- a/zrml/asset-router/src/pallet_impl/multi_currency_extended.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl Pallet { - fn update_balance_asset( - currency_id: >::CurrencyId, - who: &T::AccountId, - by_amount: >::Amount, - ) -> DispatchResult { - if by_amount.is_zero() { - return Ok(()); - } - - // Ensure that no overflows happen during abs(). - let by_amount_abs = - if by_amount == >::Amount::min_value() { - return Err(Error::::AmountIntoBalanceFailed.into()); - } else { - by_amount.abs() - }; - - let by_balance = - TryInto::<>::Balance>::try_into(by_amount_abs) - .map_err(|_| Error::::AmountIntoBalanceFailed)?; - if by_amount.is_positive() { - Self::deposit(currency_id, who, by_balance) - } else { - Self::withdraw(currency_id, who, by_balance).map(|_| ()) - } - } -} - -impl MultiCurrencyExtended for Pallet { - type Amount = >::Amount; - - fn update_balance( - currency_id: Self::CurrencyId, - who: &T::AccountId, - by_amount: Self::Amount, - ) -> DispatchResult { - if by_amount.is_zero() { - return Ok(()); - } - - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - Self::update_balance_asset(currency_id, who, by_amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::update_balance(currency, who, by_amount) - } else { - Self::update_balance_asset(currency_id, who, by_amount) - } - } else if let Ok(_asset) = T::CampaignAssetType::try_from(currency_id) { - Self::update_balance_asset(currency_id, who, by_amount) - } else if let Ok(_asset) = T::CustomAssetType::try_from(currency_id) { - Self::update_balance_asset(currency_id, who, by_amount) - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::update_balance(currency, who, by_amount) - } else { - Err(Error::::UnknownAsset.into()) - } - } -} diff --git a/zrml/asset-router/src/pallet_impl/multi_lockable_currency.rs b/zrml/asset-router/src/pallet_impl/multi_lockable_currency.rs deleted file mode 100644 index 8a1fb832c..000000000 --- a/zrml/asset-router/src/pallet_impl/multi_lockable_currency.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl MultiLockableCurrency for Pallet { - type Moment = BlockNumberFor; - - fn set_lock( - lock_id: LockIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - return Err(Error::::Unsupported.into()); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::set_lock( - lock_id, currency, who, amount, - ); - } - - Err(Error::::Unsupported.into()) - } - - fn extend_lock( - lock_id: LockIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - amount: Self::Balance, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - return Err(Error::::Unsupported.into()); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::extend_lock( - lock_id, currency, who, amount, - ); - } - - Err(Error::::Unsupported.into()) - } - - fn remove_lock( - lock_id: LockIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - return Err(Error::::Unsupported.into()); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::remove_lock( - lock_id, currency, who, - ); - } - - Err(Error::::Unsupported.into()) - } -} diff --git a/zrml/asset-router/src/pallet_impl/multi_reserveable_currency.rs b/zrml/asset-router/src/pallet_impl/multi_reserveable_currency.rs deleted file mode 100644 index a6bed8360..000000000 --- a/zrml/asset-router/src/pallet_impl/multi_reserveable_currency.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl MultiReservableCurrency for Pallet { - fn can_reserve( - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> bool { - only_currency!(currency_id, false, MultiReservableCurrency, can_reserve, who, value) - } - - fn slash_reserved( - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> Self::Balance { - only_currency!(currency_id, value, MultiReservableCurrency, slash_reserved, who, value) - } - - fn reserved_balance(currency_id: Self::CurrencyId, who: &T::AccountId) -> Self::Balance { - only_currency!(currency_id, Zero::zero(), MultiReservableCurrency, reserved_balance, who) - } - - fn reserve( - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> DispatchResult { - only_currency!( - currency_id, - Err(Error::::Unsupported.into()), - MultiReservableCurrency, - reserve, - who, - value - ) - } - - fn unreserve( - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> Self::Balance { - only_currency!(currency_id, value, MultiReservableCurrency, unreserve, who, value) - } - - fn repatriate_reserved( - currency_id: Self::CurrencyId, - slashed: &T::AccountId, - beneficiary: &T::AccountId, - value: Self::Balance, - status: BalanceStatus, - ) -> Result { - only_currency!( - currency_id, - Err(Error::::Unsupported.into()), - MultiReservableCurrency, - repatriate_reserved, - slashed, - beneficiary, - value, - status - ) - } -} diff --git a/zrml/asset-router/src/pallet_impl/named_multi_reserveable_currency.rs b/zrml/asset-router/src/pallet_impl/named_multi_reserveable_currency.rs deleted file mode 100644 index c1f70393d..000000000 --- a/zrml/asset-router/src/pallet_impl/named_multi_reserveable_currency.rs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl NamedMultiReservableCurrency for Pallet { - type ReserveIdentifier = - >::ReserveIdentifier; - - fn reserved_balance_named( - id: &Self::ReserveIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - ) -> Self::Balance { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - Self::log_unsupported(currency_id, "reserved_balance_named"); - return Zero::zero(); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::reserved_balance_named( - id, currency, who, - ); - } - - Self::log_unsupported(currency_id, "reserved_balance_named"); - Zero::zero() - } - - fn reserve_named( - id: &Self::ReserveIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> DispatchResult { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - return Err(Error::::Unsupported.into()); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::reserve_named( - id, currency, who, value, - ); - } - - Err(Error::::Unsupported.into()) - } - - fn unreserve_named( - id: &Self::ReserveIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> Self::Balance { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - Self::log_unsupported(currency_id, "unreserve_named"); - return value; - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::unreserve_named( - id, currency, who, value, - ); - } - - Self::log_unsupported(currency_id, "unreserve_named"); - value - } - - fn slash_reserved_named( - id: &Self::ReserveIdentifier, - currency_id: Self::CurrencyId, - who: &T::AccountId, - value: Self::Balance, - ) -> Self::Balance { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - Self::log_unsupported(currency_id, "slash_reserved_named"); - return value; - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::slash_reserved_named( - id, currency, who, value - ); - } - - Self::log_unsupported(currency_id, "slash_reserved_named"); - value - } - - fn repatriate_reserved_named( - id: &Self::ReserveIdentifier, - currency_id: Self::CurrencyId, - slashed: &T::AccountId, - beneficiary: &T::AccountId, - value: Self::Balance, - status: Status, - ) -> Result { - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - if T::MarketAssets::asset_exists(asset) { - return Err(Error::::Unsupported.into()); - } - } - if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - return >::repatriate_reserved_named( - id, currency, slashed, beneficiary, value, status - ); - } - - Err(Error::::Unsupported.into()) - } -} diff --git a/zrml/asset-router/src/pallet_impl/transfer_all.rs b/zrml/asset-router/src/pallet_impl/transfer_all.rs deleted file mode 100644 index 0dd0f829f..000000000 --- a/zrml/asset-router/src/pallet_impl/transfer_all.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; - -impl TransferAll for Pallet { - #[require_transactional] - fn transfer_all(source: &T::AccountId, dest: &T::AccountId) -> DispatchResult { - // Only transfers assets maintained in orml-tokens, not implementable for pallet-assets - >::transfer_all(source, dest) - } -} diff --git a/zrml/asset-router/src/pallet_impl/unbalanced.rs b/zrml/asset-router/src/pallet_impl/unbalanced.rs deleted file mode 100644 index ecffc76c2..000000000 --- a/zrml/asset-router/src/pallet_impl/unbalanced.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2024 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 crate::pallet::*; -use frame_support::traits::tokens::fungibles::{Dust, Unbalanced}; - -impl Unbalanced for Pallet { - fn handle_raw_dust(asset: Self::AssetId, amount: Self::Balance) { - let _ = route_call_with_trait!(asset, Unbalanced, handle_raw_dust, amount); - } - - fn handle_dust(dust: Dust) { - let Dust(currency_id, amount) = dust; - - if let Ok(asset) = T::MarketAssetType::try_from(currency_id) { - // Route "pre new asset system" market assets to `CurrencyType` - if T::MarketAssets::asset_exists(asset) { - T::MarketAssets::handle_dust(Dust(asset, amount)); - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::handle_dust(Dust(currency, amount)); - } else { - T::MarketAssets::handle_dust(Dust(asset, amount)); - } - } else if let Ok(asset) = T::CampaignAssetType::try_from(currency_id) { - T::CampaignAssets::handle_dust(Dust(asset, amount)); - } else if let Ok(asset) = T::CustomAssetType::try_from(currency_id) { - T::CustomAssets::handle_dust(Dust(asset, amount)); - } else if let Ok(currency) = T::CurrencyType::try_from(currency_id) { - T::Currencies::handle_dust(Dust(currency, amount)); - } - } - - fn write_balance( - asset: Self::AssetId, - who: &T::AccountId, - amount: Self::Balance, - ) -> Result, DispatchError> { - route_call_with_trait!(asset, Unbalanced, write_balance, who, amount)? - } - - fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance) { - let _ = route_call_with_trait!(asset, Unbalanced, set_total_issuance, amount); - } - - fn decrease_balance( - asset: Self::AssetId, - who: &T::AccountId, - amount: Self::Balance, - precision: Precision, - preservation: Preservation, - force: Fortitude, - ) -> Result { - route_call_with_trait!( - asset, - Unbalanced, - decrease_balance, - who, - amount, - precision, - preservation, - force - )? - } - - fn increase_balance( - asset: Self::AssetId, - who: &T::AccountId, - amount: Self::Balance, - precision: Precision, - ) -> Result { - route_call_with_trait!(asset, Unbalanced, increase_balance, who, amount, precision)? - } - - fn deactivate(asset: Self::AssetId, amount: Self::Balance) { - let _ = route_call_with_trait!(asset, Unbalanced, deactivate, amount); - } - - fn reactivate(asset: Self::AssetId, amount: Self::Balance) { - let _ = route_call_with_trait!(asset, Unbalanced, reactivate, amount); - } -} diff --git a/zrml/asset-router/src/tests/create.rs b/zrml/asset-router/src/tests/create.rs deleted file mode 100644 index 4b81382ac..000000000 --- a/zrml/asset-router/src/tests/create.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use frame_support::traits::tokens::fungibles::Inspect; - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert!(AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert!(AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert!(AssetRouter::asset_exists(MARKET_ASSET)); - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - }); -} - -#[test] -fn routes_currencies_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_noop!( - AssetRouter::create(CURRENCY, ALICE, true, CURRENCY_MIN_BALANCE), - Error::::Unsupported - ); - }); -} diff --git a/zrml/asset-router/src/tests/custom_types.rs b/zrml/asset-router/src/tests/custom_types.rs deleted file mode 100644 index 0faf7bc68..000000000 --- a/zrml/asset-router/src/tests/custom_types.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2024 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 crate::{AssetInDestruction, DestructionState}; - -type Aid = AssetInDestruction; - -#[test] -fn asset_in_destruction_created_properly() { - let aid = Aid::new(2); - assert_eq!(*aid.asset(), 2); - assert_eq!(*aid.state(), DestructionState::Accounts); -} - -#[test] -fn asset_in_destruction_transitions_states_properly() { - let mut aid = Aid::new(2); - - aid.transit_state(); - assert_eq!(*aid.state(), DestructionState::Approvals); - - aid.transit_state(); - assert_eq!(*aid.state(), DestructionState::Finalization); - - aid.transit_state(); - assert_eq!(*aid.state(), DestructionState::Destroyed); - - aid.transit_state(); - assert_eq!(*aid.state(), DestructionState::Destroyed); -} - -#[test] -fn asset_in_destruction_indestructible_state_works() { - let mut aid = Aid::new(2); - - aid.transit_indestructible(); - assert_eq!(*aid.state(), DestructionState::Indestructible); - - aid.transit_state(); - assert_eq!(*aid.state(), DestructionState::Indestructible); -} - -#[test] -fn asset_in_destruction_ordering_works() { - // Order by destruction state first. - let asset_1 = Aid::new(0); - let mut asset_2 = asset_1; - assert_eq!(asset_2.transit_state(), Some(&DestructionState::Approvals)); - let mut asset_3 = asset_2; - assert_eq!(asset_3.transit_state(), Some(&DestructionState::Finalization)); - let mut asset_4 = asset_3; - assert_eq!(asset_4.transit_state(), Some(&DestructionState::Destroyed)); - let mut asset_5 = asset_1; - asset_5.transit_indestructible(); - - let mut asset_vec = vec![asset_5, asset_4, asset_3, asset_2, asset_1]; - let mut expected = vec![asset_1, asset_2, asset_3, asset_4, asset_5]; - asset_vec.sort(); - assert_eq!(asset_vec, expected); - - // On equal destruction state, order by asset id. - let mut asset_dif_id_1 = Aid::new(1); - asset_dif_id_1.transit_state(); - let mut asset_dif_id_2 = Aid::new(2); - asset_dif_id_2.transit_state(); - - asset_vec.push(asset_dif_id_1); - asset_vec.push(asset_dif_id_2); - asset_vec.sort(); - expected = vec![asset_1, asset_dif_id_2, asset_dif_id_1, asset_2, asset_3, asset_4, asset_5]; - assert_eq!(asset_vec, expected); -} diff --git a/zrml/asset-router/src/tests/destroy.rs b/zrml/asset-router/src/tests/destroy.rs deleted file mode 100644 index cca618b9b..000000000 --- a/zrml/asset-router/src/tests/destroy.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use frame_support::traits::tokens::fungibles::Inspect; - -fn test_helper(asset: Assets, initial_amount: ::Balance) { - assert_ok!(>::deposit( - asset, - &ALICE, - initial_amount - )); - assert!(AssetRouter::asset_exists(asset)); - assert_ok!(AssetRouter::start_destroy(asset, None)); - assert_eq!(AssetRouter::destroy_accounts(asset, 100), Ok(1)); - assert_eq!(AssetRouter::destroy_approvals(asset, 100), Ok(1)); - assert_ok!(AssetRouter::finish_destroy(asset)); - assert!(!AssetRouter::asset_exists(asset)); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE,)); - assert_ok!( - pallet_assets::Call::::approve_transfer { - id: CAMPAIGN_ASSET_INTERNAL.into(), - delegate: BOB, - amount: 1 - } - .dispatch_bypass_filter(Signed(ALICE).into()) - ); - - test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE,)); - assert_ok!( - pallet_assets::Call::::approve_transfer { - id: CUSTOM_ASSET_INTERNAL.into(), - delegate: BOB, - amount: 1 - } - .dispatch_bypass_filter(Signed(ALICE).into()) - ); - - test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE,)); - assert_ok!( - pallet_assets::Call::::approve_transfer { - id: MARKET_ASSET_INTERNAL, - delegate: BOB, - amount: 1 - } - .dispatch_bypass_filter(Signed(ALICE).into()) - ); - - test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_currencies_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(>::deposit( - CURRENCY, - &ALICE, - CURRENCY_INITIAL_AMOUNT - )); - assert_noop!(AssetRouter::start_destroy(CURRENCY, None), Error::::Unsupported); - assert_noop!(AssetRouter::destroy_accounts(CURRENCY, 100), Error::::Unsupported); - assert_noop!(AssetRouter::destroy_approvals(CURRENCY, 100), Error::::Unsupported); - assert_noop!(AssetRouter::finish_destroy(CURRENCY), Error::::Unsupported); - }); -} diff --git a/zrml/asset-router/src/tests/inspect.rs b/zrml/asset-router/src/tests/inspect.rs deleted file mode 100644 index ea71939c2..000000000 --- a/zrml/asset-router/src/tests/inspect.rs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use crate::*; -use frame_support::traits::tokens::fungibles::Inspect; - -fn test_helper( - asset: Assets, - initial_amount: ::Balance, - min_balance: ::Balance, -) { - assert_ok!(>::deposit( - asset, - &ALICE, - initial_amount - )); - assert!(AssetRouter::asset_exists(asset)); - assert_eq!(>::total_issuance(asset), initial_amount); - assert_eq!(AssetRouter::active_issuance(asset), initial_amount); - assert_eq!(AssetRouter::balance(asset, &ALICE), initial_amount); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount); - assert_eq!( - AssetRouter::reducible_balance(asset, &ALICE, Preservation::Protect, Fortitude::Force), - initial_amount - min_balance - ); - assert_eq!( - AssetRouter::can_withdraw(asset, &ALICE, initial_amount), - WithdrawConsequence::ReducedToZero(0) - ); - assert_eq!( - AssetRouter::can_deposit(asset, &ALICE, 1, Provenance::Minted), - DepositConsequence::Success - ); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use orml_traits::MultiCurrency; - - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE,)); - assert_eq!( - >::minimum_balance(CAMPAIGN_ASSET), - CAMPAIGN_ASSET_MIN_BALANCE - ); - test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT, CAMPAIGN_ASSET_MIN_BALANCE); - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use orml_traits::MultiCurrency; - - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE,)); - assert_eq!( - >::minimum_balance(CUSTOM_ASSET), - CUSTOM_ASSET_MIN_BALANCE - ); - test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT, CUSTOM_ASSET_MIN_BALANCE); - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use orml_traits::MultiCurrency; - - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE,)); - assert_eq!( - >::minimum_balance(MARKET_ASSET), - MARKET_ASSET_MIN_BALANCE - ); - test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT, MARKET_ASSET_MIN_BALANCE); - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_currencies_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!( - >::minimum_balance(CURRENCY), - CURRENCY_MIN_BALANCE - ); - assert_eq!( - >::minimum_balance(CURRENCY_OLD_OUTCOME), - CURRENCY_MIN_BALANCE - ); - - test_helper(CURRENCY, CURRENCY_INITIAL_AMOUNT, CURRENCY_MIN_BALANCE); - test_helper(CURRENCY_OLD_OUTCOME, CURRENCY_INITIAL_AMOUNT, CURRENCY_MIN_BALANCE); - - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - }); -} diff --git a/zrml/asset-router/src/tests/managed_destroy.rs b/zrml/asset-router/src/tests/managed_destroy.rs deleted file mode 100644 index 1c2700ffb..000000000 --- a/zrml/asset-router/src/tests/managed_destroy.rs +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use crate::{ - AssetInDestruction, DestroyAssets, DestructionState, IndestructibleAssets, Weight, - MAX_ASSET_DESTRUCTIONS_PER_BLOCK, MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, -}; -use frame_support::{ - traits::{tokens::fungibles::Inspect, Get}, - weights::RuntimeDbWeight, - BoundedVec, -}; -use pallet_assets::ManagedDestroy; - -#[test] -fn adds_assets_properly() { - ExtBuilder::default().build().execute_with(|| { - let campaign_asset = AssetInDestruction::new(CAMPAIGN_ASSET); - let custom_asset = AssetInDestruction::new(CUSTOM_ASSET); - - assert_noop!( - AssetRouter::managed_destroy(CAMPAIGN_ASSET, None), - Error::::UnknownAsset - ); - - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::managed_destroy(CAMPAIGN_ASSET, None)); - assert_noop!( - AssetRouter::managed_destroy(CAMPAIGN_ASSET, None), - Error::::DestructionInProgress - ); - assert_eq!(DestroyAssets::::get(), vec![campaign_asset]); - - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::managed_destroy(CUSTOM_ASSET, None)); - let mut expected = vec![campaign_asset, custom_asset]; - expected.sort(); - assert_eq!(DestroyAssets::::get(), expected); - - IndestructibleAssets::::put(BoundedVec::truncate_from(vec![ - CAMPAIGN_ASSET, - CUSTOM_ASSET, - ])); - DestroyAssets::::kill(); - assert_noop!( - AssetRouter::managed_destroy(CAMPAIGN_ASSET, None), - Error::::AssetIndestructible - ); - assert_noop!( - AssetRouter::managed_destroy(CUSTOM_ASSET, None), - Error::::AssetIndestructible - ); - }); -} - -#[test] -fn adds_multi_assets_properly() { - ExtBuilder::default().build().execute_with(|| { - let assets = BTreeMap::from([(CAMPAIGN_ASSET, None), (CUSTOM_ASSET, None)]); - let campaign_asset = AssetInDestruction::new(CAMPAIGN_ASSET); - let custom_asset = AssetInDestruction::new(CUSTOM_ASSET); - - assert_noop!( - managed_destroy_multi_transactional(assets.clone()), - Error::::UnknownAsset - ); - - for (asset, _) in assets.clone() { - assert_ok!(AssetRouter::create(asset, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - } - - assert_ok!(managed_destroy_multi_transactional(assets.clone())); - - for (asset, _) in assets.clone() { - assert_noop!( - AssetRouter::managed_destroy(asset, None), - Error::::DestructionInProgress - ); - } - - assert_noop!( - managed_destroy_multi_transactional(assets.clone()), - Error::::DestructionInProgress - ); - let mut expected = vec![campaign_asset, custom_asset]; - expected.sort(); - assert_eq!(DestroyAssets::::get(), expected); - - IndestructibleAssets::::put(BoundedVec::truncate_from(vec![ - CAMPAIGN_ASSET, - CUSTOM_ASSET, - ])); - DestroyAssets::::kill(); - assert_noop!( - managed_destroy_multi_transactional(assets), - Error::::AssetIndestructible - ); - }); -} - -#[test] -fn destroys_assets_fully_works_properly() { - ExtBuilder::default().build().execute_with(|| { - let assets_raw = [(CAMPAIGN_ASSET, None), (CUSTOM_ASSET, None), (MARKET_ASSET, None)]; - let assets = BTreeMap::from_iter(assets_raw.to_vec()); - - for (asset, _) in &assets_raw[..] { - assert_ok!(AssetRouter::create(*asset, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - } - - assert_ok!( - pallet_assets::Call::::approve_transfer { - id: CAMPAIGN_ASSET_INTERNAL.into(), - delegate: BOB, - amount: 1 - } - .dispatch_bypass_filter(Signed(ALICE).into()) - ); - - assert_ok!(managed_destroy_multi_transactional(assets.clone())); - assert_eq!(DestroyAssets::::get().len(), 3); - - let available_weight = (2 * MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT).into(); - let remaining_weight = AssetRouter::on_idle(0, available_weight); - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - assert_eq!(IndestructibleAssets::::get(), vec![]); - assert_eq!(DestroyAssets::::get(), vec![]); - - let mut consumed_weight = available_weight - 3u64 * 3u64 * DESTROY_WEIGHT; - // Consider safety buffer for extra execution time and storage proof size - consumed_weight = consumed_weight - .saturating_sub(Weight::from_parts(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, 45_824)); - assert_eq!(remaining_weight, consumed_weight); - }) -} - -#[test] -fn destroys_assets_partially_properly() { - ExtBuilder::default().build().execute_with(|| { - let assets_raw = [(CAMPAIGN_ASSET, None), (CUSTOM_ASSET, None), (MARKET_ASSET, None)]; - let assets = BTreeMap::from_iter(assets_raw.to_vec()); - - for (asset, _) in &assets_raw[..] { - assert_ok!(AssetRouter::create(*asset, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - } - - assert_ok!(managed_destroy_multi_transactional(assets.clone())); - assert_eq!(DestroyAssets::::get().len(), 3); - - let mut available_weight: Weight = - Weight::from_all(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT) + 2u64 * DESTROY_WEIGHT; - // Make on_idle only partially delete the first asset - let _ = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 3); - - // Now delete each asset one by one by supplying exactly the required weight - available_weight = Weight::from_all(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT) + DESTROY_WEIGHT; - let _ = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 2); - - available_weight = - Weight::from_all(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT) + 3u64 * DESTROY_WEIGHT; - let _ = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 1); - - let _ = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 0); - - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - }) -} - -#[test] -fn properly_handles_indestructible_assets() { - ExtBuilder::default().build().execute_with(|| { - let assets_raw = vec![CAMPAIGN_ASSET, CUSTOM_ASSET, MARKET_ASSET]; - let mut destroy_assets = DestroyAssets::::get(); - let available_weight = (4 * MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT).into(); - - for asset in assets_raw { - destroy_assets.force_push(AssetInDestruction::new(asset)); - } - - destroy_assets.sort(); - - let setup_state = || { - assert_ok!(AssetRouter::create( - *destroy_assets[0].asset(), - ALICE, - true, - CAMPAIGN_ASSET_MIN_BALANCE - )); - assert_ok!(AssetRouter::create( - *destroy_assets[2].asset(), - ALICE, - true, - CAMPAIGN_ASSET_MIN_BALANCE - )); - assert_ok!(AssetRouter::start_destroy(*destroy_assets[0].asset(), None)); - assert_ok!(AssetRouter::start_destroy(*destroy_assets[2].asset(), None)); - }; - - // [1] Asset is indestructible and not in Finalization state, - // i.e. weight consumption bounded but unknown. - setup_state(); - DestroyAssets::::put(destroy_assets.clone()); - assert_eq!(DestroyAssets::::get().len(), 3); - let remaining_weight = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 1); - assert_eq!(remaining_weight, 0.into()); - - // Destroy remaining assets - let _ = AssetRouter::on_idle(0, available_weight); - assert_eq!(DestroyAssets::::get().len(), 0); - assert_eq!(IndestructibleAssets::::get().len(), 1); - - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - - // [2] Asset is indestructible and in Finalization state, - // i.e. weight consumption bounded and known. - DestroyAssets::::kill(); - IndestructibleAssets::::kill(); - setup_state(); - destroy_assets[1].transit_state(); - destroy_assets[1].transit_state(); - DestroyAssets::::put(destroy_assets); - assert_eq!(DestroyAssets::::get().len(), 3); - let remaining_weight = AssetRouter::on_idle(0, available_weight); - let mut consumed_weight = available_weight - 2u32 * 3u32 * DESTROY_WEIGHT - DESTROY_WEIGHT; - // Consider safety buffer for extra execution time and storage proof size - consumed_weight = consumed_weight - .saturating_sub(Weight::from_parts(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, 45_824)); - assert_eq!(remaining_weight, consumed_weight); - assert_eq!(DestroyAssets::::get().len(), 0); - assert_eq!(IndestructibleAssets::::get().len(), 1); - - assert!(!AssetRouter::asset_exists(CAMPAIGN_ASSET)); - assert!(!AssetRouter::asset_exists(CUSTOM_ASSET)); - assert!(!AssetRouter::asset_exists(MARKET_ASSET)); - }) -} - -#[test] -fn does_not_execute_on_insufficient_weight() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::managed_destroy(CAMPAIGN_ASSET, None)); - assert_eq!(DestroyAssets::::get().len(), 1); - - let db_weight: RuntimeDbWeight = ::DbWeight::get(); - let mut available_weight = Weight::from_parts(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, 45_824) - + db_weight.reads(1) - - 1u64.into(); - let mut remaining_weight = AssetRouter::on_idle(0, available_weight); - assert_eq!(available_weight, remaining_weight); - assert_eq!(DestroyAssets::::get().len(), 1); - - available_weight += Weight::from_all(1u64) + db_weight.writes(1); - let mut remaining_weight_expected: Weight = 0u64.into(); - remaining_weight = AssetRouter::on_idle(0, available_weight); - assert_eq!(remaining_weight_expected, remaining_weight); - assert_eq!(DestroyAssets::::get().len(), 1); - - remaining_weight_expected = 1u64.into(); - available_weight += 3u64 * DESTROY_WEIGHT + remaining_weight_expected; - remaining_weight = AssetRouter::on_idle(0, available_weight); - assert_eq!(remaining_weight_expected, remaining_weight); - assert_eq!(DestroyAssets::::get().len(), 0); - }) -} - -#[test] -fn does_skip_and_remove_assets_in_invalid_state() { - ExtBuilder::default().build().execute_with(|| { - let mut campaign_asset = AssetInDestruction::new(CAMPAIGN_ASSET); - campaign_asset.transit_state(); - campaign_asset.transit_state(); - assert_eq!(*campaign_asset.transit_state().unwrap(), DestructionState::Destroyed); - let mut custom_asset = AssetInDestruction::new(CUSTOM_ASSET); - custom_asset.transit_indestructible(); - - let assets_raw = BoundedVec::truncate_from(vec![campaign_asset, custom_asset]); - DestroyAssets::::put(assets_raw); - let db_weight: RuntimeDbWeight = ::DbWeight::get(); - let available_weight = Weight::from_parts(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, 45_824) - + db_weight.reads_writes(1, 1) - + DESTROY_WEIGHT; - - let remaining_weight = AssetRouter::on_idle(0, available_weight); - // No destroy routine was called - assert_eq!(remaining_weight, DESTROY_WEIGHT); - // Asset in invalid states got removed - assert_eq!(DestroyAssets::::get().len(), 0); - }); -} - -#[test] -#[should_panic(expected = "Destruction outer loop iteration guard triggered")] -fn does_trigger_on_idle_outer_loop_safety_guard() { - ExtBuilder::default().build().execute_with(|| { - for asset_num in 0..=MAX_ASSET_DESTRUCTIONS_PER_BLOCK { - let asset = Assets::CampaignAsset(asset_num as u128); - assert_ok!(AssetRouter::create(asset, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::managed_destroy(asset, None)); - } - - let db_weight: RuntimeDbWeight = ::DbWeight::get(); - let available_weight = Weight::from_parts(MIN_ON_IDLE_EXTRA_COMPUTATION_WEIGHT, 45_824) - + db_weight.reads(1) - + DESTROY_WEIGHT * 3 * (MAX_ASSET_DESTRUCTIONS_PER_BLOCK + 1) as u64; - - let _ = AssetRouter::on_idle(0, available_weight); - }); -} diff --git a/zrml/asset-router/src/tests/mod.rs b/zrml/asset-router/src/tests/mod.rs deleted file mode 100644 index 48a23763d..000000000 --- a/zrml/asset-router/src/tests/mod.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::{mock::*, Error}; -use alloc::collections::BTreeMap; -use frame_support::{ - assert_noop, assert_ok, - dispatch::RawOrigin::Signed, - traits::{ - tokens::{ - fungibles::{Create, Destroy}, - DepositConsequence, WithdrawConsequence, - }, - OnIdle, UnfilteredDispatchable, - }, -}; -use orml_traits::{ - BalanceStatus, MultiCurrencyExtended, MultiLockableCurrency, MultiReservableCurrency, - NamedMultiReservableCurrency, -}; -use zeitgeist_primitives::types::Assets; - -mod create; -mod custom_types; -mod destroy; -mod inspect; -mod managed_destroy; -mod multi_currency; -mod multi_lockable_currency; -mod multi_reservable_currency; -mod named_multi_reservable_currency; -mod unbalanced; diff --git a/zrml/asset-router/src/tests/multi_currency.rs b/zrml/asset-router/src/tests/multi_currency.rs deleted file mode 100644 index ddc0f7233..000000000 --- a/zrml/asset-router/src/tests/multi_currency.rs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use orml_traits::MultiCurrency; -use test_case::test_case; -use zeitgeist_primitives::types::{Amount, Balance}; - -fn test_helper( - asset: Assets, - initial_amount: ::Balance, - min_balance: ::Balance, -) { - assert_eq!(AssetRouter::minimum_balance(asset), min_balance); - assert_ok!(AssetRouter::deposit(asset, &ALICE, initial_amount)); - assert_eq!(AssetRouter::total_issuance(asset), initial_amount); - assert_eq!(AssetRouter::total_balance(asset, &ALICE), initial_amount); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount); - assert_ok!(AssetRouter::ensure_can_withdraw(asset, &ALICE, initial_amount)); - assert!(AssetRouter::ensure_can_withdraw(asset, &ALICE, initial_amount + 1).is_err()); - assert_ok!(AssetRouter::transfer(asset, &ALICE, &BOB, min_balance)); - assert_eq!(AssetRouter::free_balance(asset, &BOB), min_balance); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount - min_balance); - assert_ok!(AssetRouter::withdraw(asset, &ALICE, 1)); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount - min_balance - 1); - assert!(AssetRouter::can_slash(asset, &ALICE, 1)); - assert_eq!(AssetRouter::slash(asset, &ALICE, 1), 0); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount - min_balance - 2); - assert_ok!(AssetRouter::update_balance( - asset, - &ALICE, - >::Amount::from(1u8) - - >::Amount::from(2u8) - )); - assert_eq!(AssetRouter::free_balance(asset, &ALICE), initial_amount - min_balance - 3); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use frame_support::traits::tokens::fungibles::Inspect; - - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - - test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT, CAMPAIGN_ASSET_MIN_BALANCE); - - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use frame_support::traits::tokens::fungibles::Inspect; - - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE)); - - test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT, CUSTOM_ASSET_MIN_BALANCE); - - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - use frame_support::traits::tokens::fungibles::Inspect; - - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE)); - - test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT, MARKET_ASSET_MIN_BALANCE); - - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(CURRENCY_INTERNAL), 0); - }); -} - -#[test] -fn routes_currencies_correctly() { - ExtBuilder::default().build().execute_with(|| { - use frame_support::traits::tokens::fungibles::Inspect; - - test_helper(CURRENCY, CURRENCY_INITIAL_AMOUNT, CURRENCY_MIN_BALANCE); - test_helper(CURRENCY_OLD_OUTCOME, CURRENCY_INITIAL_AMOUNT, CURRENCY_MIN_BALANCE); - - assert_eq!( - >::total_issuance(CAMPAIGN_ASSET_INTERNAL), - 0 - ); - assert_eq!(>::total_issuance(CUSTOM_ASSET_INTERNAL), 0); - assert_eq!(>::total_issuance(MARKET_ASSET_INTERNAL), 0); - }); -} - -#[test_case(0, Some(0); "zero")] -#[test_case(Amount::MAX, Some(Amount::MAX.unsigned_abs() as Balance); "max")] -#[test_case(Amount::MIN, None; "min")] -#[test_case(Amount::MIN + 1, Some((Amount::MIN + 1).unsigned_abs() as Balance); "min_plus_one")] -fn update_balance_handles_overflows_correctly(update: Amount, expected: Option) { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - - if update.is_negative() { - assert_ok!(AssetRouter::update_balance(CAMPAIGN_ASSET, &ALICE, Amount::MAX)); - } - - if let Some(expected_inner) = expected { - assert_ok!(AssetRouter::update_balance(CAMPAIGN_ASSET, &ALICE, update)); - - if update.is_negative() { - assert_eq!( - AssetRouter::free_balance(CAMPAIGN_ASSET, &ALICE), - Amount::MAX as Balance - expected_inner - ); - } else { - assert_eq!(AssetRouter::free_balance(CAMPAIGN_ASSET, &ALICE), expected_inner); - } - } else { - assert_noop!( - AssetRouter::update_balance(CAMPAIGN_ASSET, &ALICE, update), - Error::::AmountIntoBalanceFailed - ); - } - }); -} diff --git a/zrml/asset-router/src/tests/multi_lockable_currency.rs b/zrml/asset-router/src/tests/multi_lockable_currency.rs deleted file mode 100644 index 20497d243..000000000 --- a/zrml/asset-router/src/tests/multi_lockable_currency.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use orml_traits::MultiCurrency; -use test_case::test_case; - -fn unroutable_test_helper(asset: Assets) { - assert_noop!( - AssetRouter::set_lock(Default::default(), asset, &ALICE, 1), - Error::::Unsupported - ); - assert_noop!( - AssetRouter::extend_lock(Default::default(), asset, &ALICE, 1), - Error::::Unsupported - ); - assert_noop!( - AssetRouter::remove_lock(Default::default(), asset, &ALICE), - Error::::Unsupported - ); -} - -#[test_case(CURRENCY; "foreign")] -#[test_case(CURRENCY_OLD_OUTCOME; "old_outcome")] -fn routes_currencies_correctly(currency_id: Assets) { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::deposit(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT)); - assert_ok!(AssetRouter::set_lock(Default::default(), currency_id, &ALICE, 1)); - assert_eq!( - orml_tokens::Accounts::::get::< - u128, - ::CurrencyId, - >(ALICE, currency_id.try_into().unwrap()) - .frozen, - 1 - ); - assert_ok!(AssetRouter::extend_lock(Default::default(), currency_id, &ALICE, 2)); - assert_eq!( - orml_tokens::Accounts::::get::< - u128, - ::CurrencyId, - >(ALICE, currency_id.try_into().unwrap()) - .frozen, - 2 - ); - assert_ok!(AssetRouter::remove_lock(Default::default(), currency_id, &ALICE)); - assert_eq!( - orml_tokens::Accounts::::get::< - u128, - ::CurrencyId, - >(ALICE, currency_id.try_into().unwrap()) - .frozen, - 0 - ); - }); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CAMPAIGN_ASSET); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CUSTOM_ASSET); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(MARKET_ASSET); - }); -} diff --git a/zrml/asset-router/src/tests/multi_reservable_currency.rs b/zrml/asset-router/src/tests/multi_reservable_currency.rs deleted file mode 100644 index 029ce57d6..000000000 --- a/zrml/asset-router/src/tests/multi_reservable_currency.rs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use orml_traits::MultiCurrency; -use test_case::test_case; - -fn unroutable_test_helper(asset: Assets, initial_amount: ::Balance) { - assert_ok!(AssetRouter::deposit(asset, &ALICE, initial_amount)); - assert!(!AssetRouter::can_reserve(asset, &ALICE, initial_amount)); - assert_noop!( - AssetRouter::reserve(asset, &ALICE, initial_amount), - Error::::Unsupported - ); - assert_eq!(AssetRouter::reserved_balance(asset, &ALICE), 0); - assert_eq!(AssetRouter::slash_reserved(asset, &ALICE, 1), 1); - assert_noop!( - AssetRouter::repatriate_reserved(asset, &ALICE, &BOB, 1, BalanceStatus::Reserved), - Error::::Unsupported - ); - assert_eq!(AssetRouter::unreserve(asset, &ALICE, 1), 1); -} - -#[test_case(CURRENCY; "foreign")] -#[test_case(CURRENCY_OLD_OUTCOME; "old_outcome")] -fn routes_currencies_correctly(currency_id: Assets) { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::deposit(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT)); - - assert!(AssetRouter::can_reserve(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT)); - assert!(!AssetRouter::can_reserve(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT + 1)); - assert_ok!(AssetRouter::reserve(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT)); - assert_eq!(AssetRouter::reserved_balance(currency_id, &ALICE), CURRENCY_INITIAL_AMOUNT); - assert_eq!(AssetRouter::slash_reserved(currency_id, &ALICE, 1), 0); - assert_eq!( - AssetRouter::repatriate_reserved( - currency_id, - &ALICE, - &BOB, - CURRENCY_MIN_BALANCE, - BalanceStatus::Reserved - ) - .unwrap(), - 0 - ); - assert_eq!(AssetRouter::reserved_balance(currency_id, &BOB), CURRENCY_MIN_BALANCE); - assert_eq!( - AssetRouter::reserved_balance(currency_id, &ALICE), - CURRENCY_INITIAL_AMOUNT - CURRENCY_MIN_BALANCE - 1 - ); - assert_eq!(AssetRouter::unreserve(currency_id, &ALICE, 1), 0); - assert_eq!( - AssetRouter::reserved_balance(currency_id, &ALICE), - CURRENCY_INITIAL_AMOUNT - CURRENCY_MIN_BALANCE - 2 - ); - }); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT); - }); -} diff --git a/zrml/asset-router/src/tests/named_multi_reservable_currency.rs b/zrml/asset-router/src/tests/named_multi_reservable_currency.rs deleted file mode 100644 index 94f05ef5c..000000000 --- a/zrml/asset-router/src/tests/named_multi_reservable_currency.rs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2023-2024 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)] - -use super::*; -use orml_traits::MultiCurrency; -use test_case::test_case; - -fn unroutable_test_helper(asset: Assets, initial_amount: ::Balance) { - assert_ok!(AssetRouter::deposit(asset, &ALICE, initial_amount)); - assert_noop!( - AssetRouter::reserve_named(&Default::default(), asset, &ALICE, initial_amount), - Error::::Unsupported - ); - assert_eq!(AssetRouter::slash_reserved_named(&Default::default(), asset, &ALICE, 1), 1); - assert_noop!( - AssetRouter::repatriate_reserved_named( - &Default::default(), - asset, - &ALICE, - &BOB, - 1, - BalanceStatus::Reserved - ), - Error::::Unsupported - ); - assert_eq!(AssetRouter::unreserve_named(&Default::default(), asset, &ALICE, 1), 1); - assert_eq!(AssetRouter::reserved_balance_named(&Default::default(), asset, &ALICE), 0); -} - -#[test_case(CURRENCY; "foreign")] -#[test_case(CURRENCY_OLD_OUTCOME; "old_outcome")] -fn routes_currencies_correctly(currency_id: Assets) { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::deposit(currency_id, &ALICE, CURRENCY_INITIAL_AMOUNT)); - assert_ok!(AssetRouter::reserve_named( - &Default::default(), - currency_id, - &ALICE, - CURRENCY_INITIAL_AMOUNT - )); - assert_eq!( - AssetRouter::reserved_balance_named(&Default::default(), currency_id, &ALICE), - CURRENCY_INITIAL_AMOUNT - ); - assert_eq!( - AssetRouter::slash_reserved_named(&Default::default(), currency_id, &ALICE, 1), - 0 - ); - assert_eq!( - AssetRouter::repatriate_reserved_named( - &Default::default(), - currency_id, - &ALICE, - &BOB, - CURRENCY_MIN_BALANCE, - BalanceStatus::Reserved - ) - .unwrap(), - 0 - ); - assert_eq!( - AssetRouter::reserved_balance_named(&Default::default(), currency_id, &BOB), - CURRENCY_MIN_BALANCE - ); - assert_eq!( - AssetRouter::reserved_balance_named(&Default::default(), currency_id, &ALICE), - CURRENCY_INITIAL_AMOUNT - CURRENCY_MIN_BALANCE - 1 - ); - assert_eq!(AssetRouter::unreserve_named(&Default::default(), currency_id, &ALICE, 1), 0); - assert_eq!( - AssetRouter::reserved_balance_named(&Default::default(), currency_id, &ALICE), - CURRENCY_INITIAL_AMOUNT - CURRENCY_MIN_BALANCE - 2 - ); - }); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE,)); - - unroutable_test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT); - }); -} diff --git a/zrml/asset-router/src/tests/unbalanced.rs b/zrml/asset-router/src/tests/unbalanced.rs deleted file mode 100644 index 2614c9f1f..000000000 --- a/zrml/asset-router/src/tests/unbalanced.rs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2024 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)] - -use super::*; -use crate::*; -use frame_support::{ - assert_storage_noop, - traits::{fungibles::Dust, tokens::fungibles::Unbalanced}, -}; -use orml_traits::MultiCurrency; - -fn test_helper(asset: Assets, initial_amount: ::Balance) { - assert_eq!( - >::total_balance(asset, &ALICE), - initial_amount - ); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, 1, Precision::Exact)); - assert_eq!( - >::total_balance(asset, &ALICE), - initial_amount + 1 - ); - assert_ok!(AssetRouter::decrease_balance( - asset, - &ALICE, - 1, - Precision::Exact, - Preservation::Expendable, - Fortitude::Polite - )); - assert_eq!( - >::total_balance(asset, &ALICE), - initial_amount - ); - AssetRouter::set_total_issuance(asset, 1337); - assert_eq!(>::total_issuance(asset), 1337); - assert_storage_noop!(AssetRouter::deactivate(asset, 1)); - assert_storage_noop!(AssetRouter::reactivate(asset, 1)); - assert_storage_noop!(AssetRouter::handle_raw_dust(asset, 1)); -} - -#[test] -fn routes_campaign_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::deposit(CAMPAIGN_ASSET, &ALICE, CAMPAIGN_ASSET_INITIAL_AMOUNT)); - - test_helper(CAMPAIGN_ASSET, CAMPAIGN_ASSET_INITIAL_AMOUNT); - - assert_eq!(>::total_issuance(CUSTOM_ASSET), 0); - assert_eq!(>::total_issuance(MARKET_ASSET), 0); - assert_eq!(>::total_issuance(CURRENCY), 0); - }); -} - -#[test] -#[should_panic] -fn campaign_assets_panic_on_write_balance() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - let _ = AssetRouter::write_balance(CAMPAIGN_ASSET, &ALICE, 42); - }); -} - -#[test] -#[should_panic] -fn campaign_assets_panic_on_handle_dust() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CAMPAIGN_ASSET, ALICE, true, CAMPAIGN_ASSET_MIN_BALANCE)); - AssetRouter::handle_dust(Dust(CAMPAIGN_ASSET, 1)); - }); -} - -#[test] -fn routes_custom_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::deposit(CUSTOM_ASSET, &ALICE, CUSTOM_ASSET_INITIAL_AMOUNT)); - - test_helper(CUSTOM_ASSET, CUSTOM_ASSET_INITIAL_AMOUNT); - - assert_eq!(>::total_issuance(CAMPAIGN_ASSET), 0); - assert_eq!(>::total_issuance(MARKET_ASSET), 0); - assert_eq!(>::total_issuance(CURRENCY), 0); - }); -} - -#[test] -#[should_panic] -fn custom_assets_panic_on_write_balance() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE)); - let _ = AssetRouter::write_balance(CUSTOM_ASSET, &ALICE, 42); - }); -} - -#[test] -#[should_panic] -fn custom_assets_panic_on_handle_dust() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(CUSTOM_ASSET, ALICE, true, CUSTOM_ASSET_MIN_BALANCE)); - AssetRouter::handle_dust(Dust(CUSTOM_ASSET, 1)); - }); -} - -#[test] -fn routes_market_assets_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE)); - assert_ok!(AssetRouter::deposit(MARKET_ASSET, &ALICE, MARKET_ASSET_INITIAL_AMOUNT)); - - test_helper(MARKET_ASSET, MARKET_ASSET_INITIAL_AMOUNT); - - assert_eq!(>::total_issuance(CAMPAIGN_ASSET), 0); - assert_eq!(>::total_issuance(CUSTOM_ASSET), 0); - assert_eq!(>::total_issuance(CURRENCY), 0); - }); -} - -#[test] -#[should_panic] -fn market_assets_panic_on_write_balance() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE)); - let _ = AssetRouter::write_balance(MARKET_ASSET, &ALICE, 42); - }); -} - -#[test] -#[should_panic] -fn market_assets_panic_on_handle_dust() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::create(MARKET_ASSET, ALICE, true, MARKET_ASSET_MIN_BALANCE)); - AssetRouter::handle_dust(Dust(MARKET_ASSET, 1)); - }); -} - -#[test] -fn routes_currencies_correctly() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(AssetRouter::write_balance(CURRENCY, &ALICE, CURRENCY_INITIAL_AMOUNT)); - test_helper(CURRENCY, CURRENCY_INITIAL_AMOUNT); - assert_storage_noop!(AssetRouter::handle_dust(Dust(CURRENCY, 1))); - assert_ok!(AssetRouter::write_balance(CURRENCY, &ALICE, CURRENCY_MIN_BALANCE)); - assert_eq!(AssetRouter::free_balance(CURRENCY, &ALICE), CURRENCY_MIN_BALANCE); - - assert_eq!(>::total_issuance(CAMPAIGN_ASSET), 0); - assert_eq!(>::total_issuance(CUSTOM_ASSET), 0); - assert_eq!(>::total_issuance(MARKET_ASSET), 0); - }); -} diff --git a/zrml/asset-router/src/types.rs b/zrml/asset-router/src/types.rs deleted file mode 100644 index 91ec53a22..000000000 --- a/zrml/asset-router/src/types.rs +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2024 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 crate::{BoundedVec, Config, ConstU32, Weight, MAX_ASSETS_IN_DESTRUCTION}; -use core::cmp::Ordering; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; - -pub(crate) type DestroyAssetsT = BoundedVec< - AssetInDestruction<::AssetType>, - ConstU32<{ MAX_ASSETS_IN_DESTRUCTION }>, ->; - -pub(crate) enum DestructionOk { - Complete(Weight), - Incomplete(Weight), -} - -pub(crate) enum DestructionError { - Indestructible(Weight), - WrongState(Weight), -} - -pub(crate) type DestructionResult = Result; - -#[derive( - Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Decode, Encode, MaxEncodedLen, TypeInfo, -)] -pub(crate) enum DestructionState { - Accounts, - Approvals, - Finalization, - Destroyed, - Indestructible, -} -pub(crate) const DESTRUCTION_STATES: u8 = 5; - -#[derive(Clone, Copy, Encode, Eq, Debug, Decode, MaxEncodedLen, PartialEq, TypeInfo)] -pub(crate) struct AssetInDestruction { - asset: A, - state: DestructionState, -} - -impl PartialOrd for AssetInDestruction -where - A: Eq + Ord + PartialEq + PartialOrd, -{ - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -// Ordering for binary search of assets in destruction. -// Prioritize asset state first, then asset. -impl Ord for AssetInDestruction -where - A: Eq + Ord + PartialEq + PartialOrd, -{ - fn cmp(&self, other: &Self) -> Ordering { - match self.state.cmp(&other.state) { - Ordering::Equal => { - // Since asset destruction will always pop from the vector, sorting has to be reverse. - match self.asset.cmp(&other.asset) { - Ordering::Equal => Ordering::Equal, - Ordering::Less => Ordering::Greater, - Ordering::Greater => Ordering::Less, - } - } - Ordering::Less => Ordering::Less, - Ordering::Greater => Ordering::Greater, - } - } -} - -impl AssetInDestruction { - pub(crate) fn new(asset: A) -> Self { - AssetInDestruction { asset, state: DestructionState::Accounts } - } - - pub(crate) fn asset(&self) -> &A { - &self.asset - } - - pub(crate) fn state(&self) -> &DestructionState { - &self.state - } - - pub(crate) fn transit_indestructible(&mut self) { - self.state = DestructionState::Indestructible; - } - - // Returns the new state on change, None otherwise - pub(crate) fn transit_state(&mut self) -> Option<&DestructionState> { - let state_before = self.state; - - self.state = match self.state { - DestructionState::Accounts => DestructionState::Approvals, - DestructionState::Approvals => DestructionState::Finalization, - DestructionState::Destroyed => DestructionState::Destroyed, - DestructionState::Finalization => DestructionState::Destroyed, - DestructionState::Indestructible => DestructionState::Indestructible, - }; - - if state_before != self.state { Some(&self.state) } else { None } - } -} diff --git a/zrml/authorized/src/lib.rs b/zrml/authorized/src/lib.rs index cef2b7483..4c2615887 100644 --- a/zrml/authorized/src/lib.rs +++ b/zrml/authorized/src/lib.rs @@ -49,8 +49,8 @@ mod pallet { use zeitgeist_primitives::{ traits::{DisputeApi, DisputeMaxWeightApi, DisputeResolutionApi}, types::{ - AuthorityReport, BaseAsset, GlobalDisputeItem, Market, MarketDisputeMechanism, - MarketStatus, OutcomeReport, ResultWithWeightInfo, + AuthorityReport, GlobalDisputeItem, Market, MarketDisputeMechanism, MarketStatus, + OutcomeReport, ResultWithWeightInfo, }, }; use zrml_market_commons::MarketCommonsPalletApi; @@ -72,7 +72,6 @@ mod pallet { BalanceOf, BlockNumberFor, MomentOf, - BaseAsset, MarketIdOf, >; @@ -372,13 +371,13 @@ where use frame_support::traits::Get; use sp_runtime::{traits::AccountIdConversion, Perbill}; use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, ScoringRule, }; Market { + base_asset: Asset::Ztg, market_id: Default::default(), - base_asset: BaseAsset::Ztg, creation: MarketCreation::Permissionless, creator_fee: Perbill::zero(), creator: T::PalletId::get().into_account_truncating(), diff --git a/zrml/authorized/src/weights.rs b/zrml/authorized/src/weights.rs index 2132a798b..8372f608f 100644 --- a/zrml/authorized/src/weights.rs +++ b/zrml/authorized/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_authorized //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -63,34 +63,34 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_authorized (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) /// The range of component `m` is `[1, 63]`. fn authorize_market_outcome_first_report(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `854 + m * (22 ±0)` - // Estimated: `9208` - // Minimum execution time: 40_270 nanoseconds. - Weight::from_parts(52_925_446, 9208) - // Standard Error: 9_823 - .saturating_add(Weight::from_parts(6_925, 0).saturating_mul(m.into())) + // Measured: `757 + m * (22 ±0)` + // Estimated: `4507` + // Minimum execution time: 42_950 nanoseconds. + Weight::from_parts(52_839_698, 4507) + // Standard Error: 11_853 + .saturating_add(Weight::from_parts(236_800, 0).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) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn authorize_market_outcome_existing_report() -> Weight { // Proof Size summary in bytes: - // Measured: `626` - // Estimated: `5691` - // Minimum execution time: 35_520 nanoseconds. - Weight::from_parts(43_000_000, 5691) + // Measured: `561` + // Estimated: `4159` + // Minimum execution time: 39_960 nanoseconds. + Weight::from_parts(48_520_000, 4159) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -98,17 +98,17 @@ impl WeightInfoZeitgeist for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 340 nanoseconds. - Weight::from_parts(440_000, 0) + // Minimum execution time: 470 nanoseconds. + Weight::from_parts(550_000, 0) } - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn on_resolution_weight() -> Weight { // Proof Size summary in bytes: - // Measured: `250` - // Estimated: `2524` - // Minimum execution time: 10_190 nanoseconds. - Weight::from_parts(12_490_000, 2524) + // Measured: `217` + // Estimated: `3514` + // Minimum execution time: 10_960 nanoseconds. + Weight::from_parts(13_300_000, 3514) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -116,39 +116,39 @@ impl WeightInfoZeitgeist for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_720 nanoseconds. - Weight::from_parts(3_440_000, 0) + // Minimum execution time: 3_590 nanoseconds. + Weight::from_parts(3_880_000, 0) } - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:0) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:0) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn get_auto_resolve_weight() -> Weight { // Proof Size summary in bytes: - // Measured: `250` - // Estimated: `2524` - // Minimum execution time: 9_550 nanoseconds. - Weight::from_parts(11_820_000, 2524).saturating_add(T::DbWeight::get().reads(1)) + // Measured: `217` + // Estimated: `3514` + // Minimum execution time: 9_940 nanoseconds. + Weight::from_parts(12_081_000, 3514).saturating_add(T::DbWeight::get().reads(1)) } fn has_failed_weight() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 320 nanoseconds. - Weight::from_parts(400_000, 0) + // Minimum execution time: 600 nanoseconds. + Weight::from_parts(630_000, 0) } fn on_global_dispute_weight() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 300 nanoseconds. - Weight::from_parts(380_000, 0) + // Minimum execution time: 500 nanoseconds. + Weight::from_parts(540_000, 0) } - /// Storage: Authorized AuthorizedOutcomeReports (r:0 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:0 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn clear_weight() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_510 nanoseconds. - Weight::from_parts(3_060_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 3_690 nanoseconds. + Weight::from_parts(3_880_000, 0).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/court/src/benchmarks.rs b/zrml/court/src/benchmarks.rs index ace5d2ce1..2a6c5828d 100644 --- a/zrml/court/src/benchmarks.rs +++ b/zrml/court/src/benchmarks.rs @@ -41,7 +41,7 @@ use sp_runtime::{ use zeitgeist_primitives::{ traits::{DisputeApi, DisputeResolutionApi}, types::{ - BaseAsset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, OutcomeReport, Report, ScoringRule, }, }; @@ -55,7 +55,7 @@ where { Market { market_id: 0u8.into(), - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: account("creator", 0, 0), diff --git a/zrml/court/src/lib.rs b/zrml/court/src/lib.rs index 7e6b8b8f4..2f2258094 100644 --- a/zrml/court/src/lib.rs +++ b/zrml/court/src/lib.rs @@ -29,6 +29,7 @@ use crate::{ }; use alloc::{ collections::{BTreeMap, BTreeSet}, + format, vec::Vec, }; use core::marker::PhantomData; @@ -67,7 +68,7 @@ use zeitgeist_primitives::{ math::checked_ops_res::{CheckedAddRes, CheckedRemRes, CheckedSubRes}, traits::{DisputeApi, DisputeMaxWeightApi, DisputeResolutionApi}, types::{ - BaseAsset, GlobalDisputeItem, Market, MarketDisputeMechanism, MarketStatus, OutcomeReport, + GlobalDisputeItem, Market, MarketDisputeMechanism, MarketStatus, OutcomeReport, ResultWithWeightInfo, }, }; @@ -221,14 +222,8 @@ mod pallet { pub(crate) type MarketIdOf = <::MarketCommons as MarketCommonsPalletApi>::MarketId; pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; - pub(crate) type MarketOf = Market< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAsset, - MarketIdOf, - >; + pub(crate) type MarketOf = + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; pub(crate) type HashOf = ::Hash; pub(crate) type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; diff --git a/zrml/court/src/tests.rs b/zrml/court/src/tests.rs index 3ac398a58..3e9450f49 100644 --- a/zrml/court/src/tests.rs +++ b/zrml/court/src/tests.rs @@ -60,9 +60,9 @@ use zeitgeist_primitives::{ }, traits::DisputeApi, types::{ - AccountIdTest, BaseAsset, Deadlines, GlobalDisputeItem, Market, MarketBonds, - MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, - OutcomeReport, Report, ScoringRule, + AccountIdTest, Asset, Deadlines, GlobalDisputeItem, Market, MarketBonds, MarketCreation, + MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, OutcomeReport, Report, + ScoringRule, }, }; use zrml_market_commons::{Error as MError, MarketCommonsPalletApi}; @@ -71,7 +71,7 @@ const ORACLE_REPORT: OutcomeReport = OutcomeReport::Scalar(u128::MAX); const DEFAULT_MARKET: MarketOf = Market { market_id: 0, - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: 0, diff --git a/zrml/court/src/weights.rs b/zrml/court/src/weights.rs index 54512e245..ba7c73a28 100644 --- a/zrml/court/src/weights.rs +++ b/zrml/court/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_court //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -74,424 +74,432 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_court (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court Participants (r:1 w:1) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:1 w:1) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `j` is `[0, 999]`. fn join_court(j: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1179 + j * (96 ±0)` - // Estimated: `102997` - // Minimum execution time: 49_610 nanoseconds. - Weight::from_parts(51_968_323, 102997) - // Standard Error: 1_183 - .saturating_add(Weight::from_parts(157_814, 0).saturating_mul(j.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `1082 + j * (96 ±0)` + // Estimated: `97487` + // Minimum execution time: 70_120 nanoseconds. + Weight::from_parts(104_617_890, 97487) + // Standard Error: 1_533 + .saturating_add(Weight::from_parts(169_978, 0).saturating_mul(j.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court Participants (r:6 w:1) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:6 w:1) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `j` is `[5, 999]`. /// The range of component `d` is `[1, 5]`. fn delegate(j: u32, d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + j * (98 ±0) + d * (683 ±0)` - // Estimated: `102997 + d * (2726 ±0)` - // Minimum execution time: 82_510 nanoseconds. - Weight::from_parts(48_425_156, 102997) - // Standard Error: 1_128 - .saturating_add(Weight::from_parts(204_131, 0).saturating_mul(j.into())) - // Standard Error: 244_957 - .saturating_add(Weight::from_parts(9_230_967, 0).saturating_mul(d.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `0 + d * (651 ±0) + j * (98 ±0)` + // Estimated: `97487 + d * (2726 ±0)` + // Minimum execution time: 111_671 nanoseconds. + Weight::from_parts(91_977_310, 97487) + // Standard Error: 1_492 + .saturating_add(Weight::from_parts(225_927, 0).saturating_mul(j.into())) + // Standard Error: 323_881 + .saturating_add(Weight::from_parts(14_144_892, 0).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 2726).saturating_mul(d.into())) } - /// Storage: Court Participants (r:1 w:1) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) + /// Storage: `Court::Participants` (r:1 w:1) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) /// The range of component `j` is `[0, 999]`. fn prepare_exit_court(j: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1117 + j * (96 ±0)` - // Estimated: `99223` - // Minimum execution time: 34_180 nanoseconds. - Weight::from_parts(38_897_220, 99223) - // Standard Error: 848 - .saturating_add(Weight::from_parts(135_091, 0).saturating_mul(j.into())) + // Measured: `1020 + j * (96 ±0)` + // Estimated: `97487` + // Minimum execution time: 39_270 nanoseconds. + Weight::from_parts(70_821_465, 97487) + // Standard Error: 1_114 + .saturating_add(Weight::from_parts(134_246, 0).saturating_mul(j.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Court Participants (r:1 w:1) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Court::Participants` (r:1 w:1) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) fn exit_court_remove() -> Weight { // Proof Size summary in bytes: - // Measured: `340` - // Estimated: `6500` - // Minimum execution time: 43_340 nanoseconds. - Weight::from_parts(52_540_000, 6500) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `276` + // Estimated: `4764` + // Minimum execution time: 72_321 nanoseconds. + Weight::from_parts(74_920_000, 4764) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Court Participants (r:1 w:1) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `Court::Participants` (r:1 w:1) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) fn exit_court_set() -> Weight { // Proof Size summary in bytes: - // Measured: `340` - // Estimated: `6500` - // Minimum execution time: 40_611 nanoseconds. - Weight::from_parts(50_010_000, 6500) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `276` + // Estimated: `4764` + // Minimum execution time: 60_241 nanoseconds. + Weight::from_parts(61_800_000, 4764) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) /// The range of component `d` is `[1, 510]`. fn vote(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `484 + d * (53 ±0)` - // Estimated: `155273` - // Minimum execution time: 54_120 nanoseconds. - Weight::from_parts(65_086_980, 155273) - // Standard Error: 1_797 - .saturating_add(Weight::from_parts(174_008, 0).saturating_mul(d.into())) + // Measured: `387 + d * (53 ±0)` + // Estimated: `153439` + // Minimum execution time: 75_670 nanoseconds. + Weight::from_parts(82_899_200, 153439) + // Standard Error: 1_081 + .saturating_add(Weight::from_parts(168_916, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Court Participants (r:1 w:0) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:1 w:0) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) /// The range of component `d` is `[1, 510]`. fn denounce_vote(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1625 + d * (53 ±0)` - // Estimated: `163681` - // Minimum execution time: 58_060 nanoseconds. - Weight::from_parts(77_818_158, 163681) - // Standard Error: 2_836 - .saturating_add(Weight::from_parts(208_984, 0).saturating_mul(d.into())) + // Measured: `1496 + d * (53 ±0)` + // Estimated: `153439` + // Minimum execution time: 72_850 nanoseconds. + Weight::from_parts(122_229_287, 153439) + // Standard Error: 2_413 + .saturating_add(Weight::from_parts(214_002, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Court Participants (r:1 w:0) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:1 w:0) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) /// The range of component `d` is `[1, 510]`. fn reveal_vote(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2195 + d * (53 ±0)` - // Estimated: `163681` - // Minimum execution time: 95_291 nanoseconds. - Weight::from_parts(113_379_389, 163681) - // Standard Error: 2_305 - .saturating_add(Weight::from_parts(167_661, 0).saturating_mul(d.into())) + // Measured: `2034 + d * (53 ±0)` + // Estimated: `153439` + // Minimum execution time: 123_340 nanoseconds. + Weight::from_parts(143_162_366, 153439) + // Standard Error: 1_630 + .saturating_add(Weight::from_parts(166_050, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Court Courts (r:1 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court SelectionNonce (r:1 w:1) - /// Proof: Court SelectionNonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) - /// Storage: Court Participants (r:347 w:343) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court RequestBlock (r:1 w:0) - /// Proof: Court RequestBlock (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `Court::Courts` (r:1 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectionNonce` (r:1 w:1) + /// Proof: `Court::SelectionNonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:347 w:343) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::RequestBlock` (r:1 w:0) + /// Proof: `Court::RequestBlock` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// The range of component `j` is `[255, 1000]`. /// The range of component `a` is `[0, 2]`. /// The range of component `r` is `[0, 62]`. /// The range of component `f` is `[0, 62]`. fn appeal(j: u32, a: u32, _r: u32, _f: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `929 + j * (153 ±0) + a * (27536 ±0) + r * (16 ±0) + f * (16 ±0)` - // Estimated: `539453 + j * (194 ±3) + a * (318078 ±1_049)` - // Minimum execution time: 3_930_223 nanoseconds. - Weight::from_parts(4_460_615_000, 539453) - // Standard Error: 100_366 - .saturating_add(Weight::from_parts(7_622_232, 0).saturating_mul(j.into())) - // Standard Error: 34_944_607 - .saturating_add(Weight::from_parts(5_013_268_130, 0).saturating_mul(a.into())) + // Measured: `0 + a * (24688 ±0) + f * (16 ±0) + j * (149 ±0) + r * (16 ±0)` + // Estimated: `268138 + a * (318078 ±1_049) + j * (194 ±3)` + // Minimum execution time: 5_533_132 nanoseconds. + Weight::from_parts(6_091_374_000, 268138) + // Standard Error: 119_001 + .saturating_add(Weight::from_parts(10_513_554, 0).saturating_mul(j.into())) + // Standard Error: 41_432_880 + .saturating_add(Weight::from_parts(6_976_024_571, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().reads((127_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(100)) .saturating_add(T::DbWeight::get().writes((117_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 194).saturating_mul(j.into())) .saturating_add(Weight::from_parts(0, 318078).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 194).saturating_mul(j.into())) } - /// Storage: Court Courts (r:1 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court Participants (r:510 w:510) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: System Account (r:511 w:510) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Court::Courts` (r:1 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:510 w:510) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:511 w:510) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `d` is `[5, 510]`. fn reassign_court_stakes(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1044 + d * (587 ±0)` - // Estimated: `157880 + d * (5333 ±0)` - // Minimum execution time: 153_091 nanoseconds. - Weight::from_parts(185_300_000, 157880) - // Standard Error: 140_663 - .saturating_add(Weight::from_parts(69_219_929, 0).saturating_mul(d.into())) + // Measured: `947 + d * (523 ±0)` + // Estimated: `153439 + d * (2726 ±0)` + // Minimum execution time: 203_641 nanoseconds. + Weight::from_parts(249_281_000, 153439) + // Standard Error: 171_943 + .saturating_add(Weight::from_parts(126_319_071, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(d.into()))) - .saturating_add(Weight::from_parts(0, 5333).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 2726).saturating_mul(d.into())) } - /// Storage: Court YearlyInflation (r:0 w:1) - /// Proof: Court YearlyInflation (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: `Court::YearlyInflation` (r:0 w:1) + /// Proof: `Court::YearlyInflation` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) fn set_inflation() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 15_140 nanoseconds. - Weight::from_parts(18_380_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 19_400 nanoseconds. + Weight::from_parts(20_320_000, 0).saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Court YearlyInflation (r:1 w:0) - /// Proof: Court YearlyInflation (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:0) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: System Account (r:999 w:999) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Court::YearlyInflation` (r:1 w:0) + /// Proof: `Court::YearlyInflation` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:0) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:999 w:999) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `j` is `[1, 1000]`. fn handle_inflation(j: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + j * (267 ±0)` - // Estimated: `96996 + j * (2607 ±0)` - // Minimum execution time: 40_780 nanoseconds. - Weight::from_parts(41_230_000, 96996) - // Standard Error: 31_831 - .saturating_add(Weight::from_parts(21_157_879, 0).saturating_mul(j.into())) + // Measured: `0 + j * (235 ±0)` + // Estimated: `97487 + j * (2607 ±0)` + // Minimum execution time: 54_890 nanoseconds. + Weight::from_parts(55_571_000, 97487) + // Standard Error: 42_436 + .saturating_add(Weight::from_parts(34_908_020, 0).saturating_mul(j.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(j.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(j.into()))) .saturating_add(Weight::from_parts(0, 2607).saturating_mul(j.into())) } - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court SelectionNonce (r:1 w:1) - /// Proof: Court SelectionNonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) - /// Storage: Court Participants (r:240 w:236) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectionNonce` (r:1 w:1) + /// Proof: `Court::SelectionNonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:240 w:236) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 3]`. fn select_participants(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `114768 + a * (16253 ±0)` - // Estimated: `175425 + a * (136685 ±1_677)` - // Minimum execution time: 1_761_346 nanoseconds. - Weight::from_parts(1_588_336_592, 175425) - // Standard Error: 49_849_271 - .saturating_add(Weight::from_parts(3_297_691_181, 0).saturating_mul(a.into())) + // Measured: `113583 + a * (14765 ±0)` + // Estimated: `97487 + a * (136685 ±1_677)` + // Minimum execution time: 2_334_927 nanoseconds. + Weight::from_parts(2_046_084_164, 97487) + // Standard Error: 61_887_211 + .saturating_add(Weight::from_parts(4_470_109_395, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(31)) .saturating_add(T::DbWeight::get().reads((50_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(26)) .saturating_add(T::DbWeight::get().writes((50_u64).saturating_mul(a.into()))) .saturating_add(Weight::from_parts(0, 136685).saturating_mul(a.into())) } - /// Storage: Court NextCourtId (r:1 w:1) - /// Proof: Court NextCourtId (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:1) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court SelectionNonce (r:1 w:1) - /// Proof: Court SelectionNonce (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) - /// Storage: Court Participants (r:31 w:31) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court RequestBlock (r:1 w:0) - /// Proof: Court RequestBlock (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:0 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court CourtIdToMarketId (r:0 w:1) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court MarketIdToCourtId (r:0 w:1) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court Courts (r:0 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) + /// Storage: `Court::NextCourtId` (r:1 w:1) + /// Proof: `Court::NextCourtId` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:1) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectionNonce` (r:1 w:1) + /// Proof: `Court::SelectionNonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:31 w:31) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::RequestBlock` (r:1 w:0) + /// Proof: `Court::RequestBlock` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:0 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtIdToMarketId` (r:0 w:1) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::MarketIdToCourtId` (r:0 w:1) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:0 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// The range of component `j` is `[31, 1000]`. /// The range of component `r` is `[0, 62]`. fn on_dispute(j: u32, r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `6220 + j * (104 ±0) + r * (16 ±0)` - // Estimated: `181024 + j * (8 ±0) + r * (25 ±4)` - // Minimum execution time: 307_741 nanoseconds. - Weight::from_parts(414_864_557, 181024) - // Standard Error: 3_471 - .saturating_add(Weight::from_parts(252_484, 0).saturating_mul(j.into())) - // Standard Error: 53_808 - .saturating_add(Weight::from_parts(293_295, 0).saturating_mul(r.into())) + // Measured: `5181 + j * (104 ±0) + r * (16 ±0)` + // Estimated: `97487 + j * (8 ±0) + r * (25 ±4)` + // Minimum execution time: 458_771 nanoseconds. + Weight::from_parts(545_196_348, 97487) + // Standard Error: 5_074 + .saturating_add(Weight::from_parts(344_054, 0).saturating_mul(j.into())) + // Standard Error: 78_650 + .saturating_add(Weight::from_parts(727_968, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(34)) .saturating_add(T::DbWeight::get().writes(36)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(j.into())) .saturating_add(Weight::from_parts(0, 25).saturating_mul(r.into())) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:0) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Court Participants (r:510 w:510) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:0) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:510 w:510) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) /// The range of component `d` is `[1, 510]`. fn on_resolution(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `1019 + d * (256 ±0)` - // Estimated: `163470 + d * (2726 ±0)` - // Minimum execution time: 48_260 nanoseconds. - Weight::from_parts(57_730_000, 163470) - // Standard Error: 21_662 - .saturating_add(Weight::from_parts(7_738_635, 0).saturating_mul(d.into())) + // Measured: `890 + d * (224 ±0)` + // Estimated: `153439 + d * (2726 ±0)` + // Minimum execution time: 73_910 nanoseconds. + Weight::from_parts(77_041_000, 153439) + // Standard Error: 27_015 + .saturating_add(Weight::from_parts(10_592_807, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(d.into()))) .saturating_add(Weight::from_parts(0, 2726).saturating_mul(d.into())) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:4 w:4) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: System Account (r:4 w:4) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:4 w:4) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:4 w:4) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 4]`. fn exchange(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `453 + a * (352 ±0)` - // Estimated: `5339 + a * (6331 ±0)` - // Minimum execution time: 15_140 nanoseconds. - Weight::from_parts(20_515_445, 5339) - // Standard Error: 205_998 - .saturating_add(Weight::from_parts(37_613_284, 0).saturating_mul(a.into())) + // Measured: `388 + a * (320 ±0)` + // Estimated: `3814 + a * (3724 ±0)` + // Minimum execution time: 24_510 nanoseconds. + Weight::from_parts(34_027_716, 3814) + // Standard Error: 193_772 + .saturating_add(Weight::from_parts(45_190_549, 0).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_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 6331).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 3724).saturating_mul(a.into())) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) fn get_auto_resolve() -> Weight { // Proof Size summary in bytes: - // Measured: `456` - // Estimated: `5339` - // Minimum execution time: 12_640 nanoseconds. - Weight::from_parts(15_900_000, 5339).saturating_add(T::DbWeight::get().reads(2)) + // Measured: `391` + // Estimated: `3814` + // Minimum execution time: 19_370 nanoseconds. + Weight::from_parts(22_610_000, 3814).saturating_add(T::DbWeight::get().reads(2)) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:0) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:0) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:0) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:0) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) fn has_failed() -> Weight { // Proof Size summary in bytes: - // Measured: `3982` - // Estimated: `107518` - // Minimum execution time: 38_350 nanoseconds. - Weight::from_parts(49_300_000, 107518).saturating_add(T::DbWeight::get().reads(5)) + // Measured: `3854` + // Estimated: `97487` + // Minimum execution time: 59_860 nanoseconds. + Weight::from_parts(71_241_000, 97487).saturating_add(T::DbWeight::get().reads(5)) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court Participants (r:510 w:510) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:510 w:510) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) /// The range of component `a` is `[0, 4]`. /// The range of component `d` is `[1, 510]`. fn on_global_dispute(_a: u32, d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `519 + a * (66 ±0) + d * (256 ±0)` - // Estimated: `157788 + d * (2726 ±0)` - // Minimum execution time: 32_990 nanoseconds. - Weight::from_parts(151_250_645, 157788) - // Standard Error: 30_049 - .saturating_add(Weight::from_parts(7_774_671, 0).saturating_mul(d.into())) + // Measured: `422 + a * (66 ±0) + d * (224 ±0)` + // Estimated: `153439 + d * (2726 ±0)` + // Minimum execution time: 49_460 nanoseconds. + Weight::from_parts(53_661_000, 153439) + // Standard Error: 16_081 + .saturating_add(Weight::from_parts(10_876_738, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(d.into()))) .saturating_add(Weight::from_parts(0, 2726).saturating_mul(d.into())) } - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court Participants (r:510 w:510) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: Court Courts (r:0 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:510 w:510) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:0 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// The range of component `d` is `[1, 510]`. fn clear(d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `432 + d * (256 ±0)` - // Estimated: `154964 + d * (2726 ±0)` - // Minimum execution time: 26_200 nanoseconds. - Weight::from_parts(32_380_000, 154964) - // Standard Error: 15_021 - .saturating_add(Weight::from_parts(7_510_395, 0).saturating_mul(d.into())) + // Measured: `367 + d * (224 ±0)` + // Estimated: `153439 + d * (2726 ±0)` + // Minimum execution time: 47_960 nanoseconds. + Weight::from_parts(51_290_000, 153439) + // Standard Error: 19_628 + .saturating_add(Weight::from_parts(10_330_139, 0).saturating_mul(d.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(d.into()))) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/zrml/global-disputes/src/utils.rs b/zrml/global-disputes/src/utils.rs index c26bd8865..277ec7189 100644 --- a/zrml/global-disputes/src/utils.rs +++ b/zrml/global-disputes/src/utils.rs @@ -25,7 +25,6 @@ type MarketOf = zeitgeist_primitives::types::Market< BalanceOf, BlockNumberFor, MomentOf, - zeitgeist_primitives::types::BaseAsset, MarketIdOf, >; @@ -39,7 +38,7 @@ where zeitgeist_primitives::types::Market { market_id: Default::default(), - base_asset: zeitgeist_primitives::types::BaseAsset::Ztg, + base_asset: zeitgeist_primitives::types::Asset::Ztg, creation: zeitgeist_primitives::types::MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: T::GlobalDisputesPalletId::get().into_account_truncating(), diff --git a/zrml/global-disputes/src/weights.rs b/zrml/global-disputes/src/weights.rs index 7185025ae..fa1ce5cd6 100644 --- a/zrml/global-disputes/src/weights.rs +++ b/zrml/global-disputes/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_global_disputes //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -62,165 +62,173 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_global_disputes (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:1) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Outcomes (r:1 w:1) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Locks (r:1 w:1) - /// Proof: GlobalDisputes Locks (max_values: None, max_size: Some(1641), added: 4116, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:1) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Outcomes` (r:1 w:1) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Locks` (r:1 w:1) + /// Proof: `GlobalDisputes::Locks` (`max_values`: None, `max_size`: Some(1641), added: 4116, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) /// The range of component `o` is `[2, 10]`. /// The range of component `v` is `[0, 49]`. - fn vote_on_outcome(o: u32, v: u32) -> Weight { + fn vote_on_outcome(_o: u32, v: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `581 + o * (33 ±0) + v * (32 ±0)` - // Estimated: `13631` - // Minimum execution time: 58_630 nanoseconds. - Weight::from_parts(70_092_958, 13631) - // Standard Error: 73_330 - .saturating_add(Weight::from_parts(356_105, 0).saturating_mul(o.into())) - // Standard Error: 12_896 - .saturating_add(Weight::from_parts(114_716, 0).saturating_mul(v.into())) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `452 + o * (33 ±0) + v * (32 ±0)` + // Estimated: `5106` + // Minimum execution time: 82_530 nanoseconds. + Weight::from_parts(126_323_142, 5106) + // Standard Error: 22_453 + .saturating_add(Weight::from_parts(322_465, 0).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: GlobalDisputes Locks (r:1 w:1) - /// Proof: GlobalDisputes Locks (max_values: None, max_size: Some(1641), added: 4116, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:50 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::Locks` (r:1 w:1) + /// Proof: `GlobalDisputes::Locks` (`max_values`: None, `max_size`: Some(1641), added: 4116, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:50 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 50]`. /// The range of component `o` is `[1, 10]`. fn unlock_vote_balance_set(l: u32, o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + l * (467 ±0) + o * (1600 ±0)` - // Estimated: `10497 + l * (2871 ±0)` - // Minimum execution time: 38_041 nanoseconds. - Weight::from_parts(46_882_976, 10497) - // Standard Error: 47_099 - .saturating_add(Weight::from_parts(4_725_103, 0).saturating_mul(l.into())) - // Standard Error: 247_202 - .saturating_add(Weight::from_parts(890_884, 0).saturating_mul(o.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `0 + l * (435 ±0) + o * (1600 ±0)` + // Estimated: `5106 + l * (2871 ±0)` + // Minimum execution time: 56_730 nanoseconds. + Weight::from_parts(51_193_349, 5106) + // Standard Error: 54_481 + .saturating_add(Weight::from_parts(5_744_146, 0).saturating_mul(l.into())) + // Standard Error: 285_947 + .saturating_add(Weight::from_parts(1_940_891, 0).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into()))) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 2871).saturating_mul(l.into())) } - /// Storage: GlobalDisputes Locks (r:1 w:1) - /// Proof: GlobalDisputes Locks (max_values: None, max_size: Some(1641), added: 4116, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:50 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: Balances Locks (r:1 w:1) - /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::Locks` (r:1 w:1) + /// Proof: `GlobalDisputes::Locks` (`max_values`: None, `max_size`: Some(1641), added: 4116, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:50 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:1) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:0) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `l` is `[0, 50]`. /// The range of component `o` is `[1, 10]`. - fn unlock_vote_balance_remove(l: u32, _o: u32) -> Weight { + fn unlock_vote_balance_remove(l: u32, o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + l * (451 ±0) + o * (1600 ±0)` - // Estimated: `10497 + l * (2871 ±0)` - // Minimum execution time: 38_470 nanoseconds. - Weight::from_parts(55_026_649, 10497) - // Standard Error: 45_140 - .saturating_add(Weight::from_parts(4_559_687, 0).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `0 + l * (419 ±0) + o * (1600 ±0)` + // Estimated: `5106 + l * (2871 ±0)` + // Minimum execution time: 63_810 nanoseconds. + Weight::from_parts(41_027_507, 5106) + // Standard Error: 59_734 + .saturating_add(Weight::from_parts(5_838_666, 0).saturating_mul(l.into())) + // Standard Error: 313_522 + .saturating_add(Weight::from_parts(1_959_676, 0).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into()))) - .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 2871).saturating_mul(l.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:1) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Outcomes (r:1 w:1) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:1) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Outcomes` (r:1 w:1) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `w` is `[1, 10]`. - fn add_vote_outcome(_w: u32) -> Weight { + fn add_vote_outcome(w: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `777 + w * (32 ±0)` - // Estimated: `11515` - // Minimum execution time: 70_410 nanoseconds. - Weight::from_parts(98_017_145, 11515) + // Measured: `680 + w * (32 ±0)` + // Estimated: `4159` + // Minimum execution time: 106_460 nanoseconds. + Weight::from_parts(145_681_201, 4159) + // Standard Error: 153_921 + .saturating_add(Weight::from_parts(432_081, 0).saturating_mul(w.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: GlobalDisputes Outcomes (r:1 w:0) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: System Account (r:11 w:11) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::Outcomes` (r:1 w:0) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:11 w:11) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `o` is `[1, 10]`. fn reward_outcome_owner_shared_possession(o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `561 + o * (41 ±0)` - // Estimated: `8574 + o * (2790 ±20)` - // Minimum execution time: 77_830 nanoseconds. - Weight::from_parts(63_317_800, 8574) - // Standard Error: 328_030 - .saturating_add(Weight::from_parts(36_970_797, 0).saturating_mul(o.into())) + // Measured: `464 + o * (41 ±0)` + // Estimated: `3861 + o * (2790 ±20)` + // Minimum execution time: 127_700 nanoseconds. + Weight::from_parts(94_671_964, 3861) + // Standard Error: 784_808 + .saturating_add(Weight::from_parts(78_157_454, 0).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()))) .saturating_add(Weight::from_parts(0, 2790).saturating_mul(o.into())) } - /// Storage: GlobalDisputes Outcomes (r:1 w:0) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::Outcomes` (r:1 w:0) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn reward_outcome_owner_paid_possession() -> Weight { // Proof Size summary in bytes: - // Measured: `608` - // Estimated: `10955` - // Minimum execution time: 78_530 nanoseconds. - Weight::from_parts(95_780_000, 10955) + // Measured: `511` + // Estimated: `6204` + // Minimum execution time: 155_170 nanoseconds. + Weight::from_parts(156_761_000, 6204) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:1) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Outcomes (r:250 w:249) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:1) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Outcomes` (r:250 w:249) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) /// The range of component `k` is `[2, 248]`. /// The range of component `o` is `[1, 10]`. fn purge_outcomes(k: u32, _o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `480 + k * (122 ±0) + o * (32 ±0)` - // Estimated: `8611 + k * (2870 ±0)` - // Minimum execution time: 96_590 nanoseconds. - Weight::from_parts(16_892_762, 8611) - // Standard Error: 75_754 - .saturating_add(Weight::from_parts(21_079_551, 0).saturating_mul(k.into())) + // Measured: `385 + k * (90 ±0) + o * (32 ±0)` + // Estimated: `6730 + k * (2870 ±0)` + // Minimum execution time: 82_060 nanoseconds. + Weight::from_parts(95_131_000, 6730) + // Standard Error: 32_542 + .saturating_add(Weight::from_parts(12_152_119, 0).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()))) .saturating_add(Weight::from_parts(0, 2870).saturating_mul(k.into())) } - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Outcomes (r:250 w:249) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Outcomes` (r:250 w:249) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) /// The range of component `k` is `[2, 248]`. /// The range of component `o` is `[1, 10]`. fn refund_vote_fees(k: u32, _o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `480 + k * (122 ±0) + o * (32 ±0)` - // Estimated: `8611 + k * (2870 ±0)` - // Minimum execution time: 89_620 nanoseconds. - Weight::from_parts(90_779_105, 8611) - // Standard Error: 72_050 - .saturating_add(Weight::from_parts(20_636_324, 0).saturating_mul(k.into())) + // Measured: `385 + k * (90 ±0) + o * (32 ±0)` + // Estimated: `6730 + k * (2870 ±0)` + // Minimum execution time: 77_700 nanoseconds. + Weight::from_parts(78_360_000, 6730) + // Standard Error: 31_180 + .saturating_add(Weight::from_parts(12_401_094, 0).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(1)) diff --git a/zrml/hybrid-router/Cargo.toml b/zrml/hybrid-router/Cargo.toml index 430caa5c0..38899d9cf 100644 --- a/zrml/hybrid-router/Cargo.toml +++ b/zrml/hybrid-router/Cargo.toml @@ -13,7 +13,6 @@ cfg-if = { workspace = true, optional = true } orml-asset-registry = { workspace = true, optional = true } orml-currencies = { workspace = true, optional = true } orml-tokens = { workspace = true, optional = true } -pallet-assets = { workspace = true, optional = true } pallet-balances = { workspace = true, optional = true } pallet-insecure-randomness-collective-flip = { workspace = true, optional = true } pallet-timestamp = { workspace = true, optional = true } @@ -23,7 +22,6 @@ serde = { workspace = true, optional = true } sp-io = { workspace = true, optional = true } xcm = { workspace = true, optional = true } xcm-builder = { workspace = true, optional = true } -zrml-asset-router = { workspace = true, optional = true } zrml-authorized = { workspace = true, optional = true } zrml-court = { workspace = true, optional = true } zrml-global-disputes = { workspace = true, optional = true } @@ -45,7 +43,6 @@ mock = [ "orml-asset-registry/default", "orml-currencies/default", "orml-tokens/default", - "pallet-assets/default", "pallet-balances/default", "pallet-insecure-randomness-collective-flip/default", "pallet-timestamp/default", @@ -55,7 +52,6 @@ mock = [ "sp-io/default", "xcm/default", "zeitgeist-primitives/mock", - "zrml-asset-router/default", "zrml-market-commons/default", "zrml-neo-swaps/default", "zrml-orderbook/default", @@ -75,7 +71,6 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "pallet-assets?/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "zrml-prediction-markets/runtime-benchmarks", ] diff --git a/zrml/hybrid-router/src/benchmarking.rs b/zrml/hybrid-router/src/benchmarking.rs index f94fb75db..23d7c9415 100644 --- a/zrml/hybrid-router/src/benchmarking.rs +++ b/zrml/hybrid-router/src/benchmarking.rs @@ -39,10 +39,7 @@ use zeitgeist_primitives::{ constants::{base_multiples::*, CENT}, math::fixed::{BaseProvider, FixedDiv, ZeitgeistBase}, traits::{CompleteSetOperationsApi, DeployPoolApi, HybridRouterOrderbookApi}, - types::{ - Asset, BaseAssetClass, Market, MarketCreation, MarketPeriod, MarketStatus, MarketType, - ScoringRule, - }, + types::{Asset, Market, MarketCreation, MarketPeriod, MarketStatus, MarketType, ScoringRule}, }; use zrml_market_commons::MarketCommonsPalletApi; @@ -69,11 +66,10 @@ fn create_spot_prices(asset_count: u16) -> Vec> { amounts } -fn create_market( - caller: T::AccountId, - base_asset: BaseAssetClass, - asset_count: u16, -) -> MarketIdOf { +fn create_market(caller: T::AccountId, base_asset: AssetOf, asset_count: u16) -> MarketIdOf +where + T: Config, +{ let market = Market { market_id: 0u8.into(), base_asset, @@ -99,13 +95,13 @@ fn create_market( fn create_market_and_deploy_pool( caller: T::AccountId, - base_asset: BaseAssetClass, + base_asset: AssetOf, asset_count: u16, amount: BalanceOf, ) -> MarketIdOf { let market_id = create_market::(caller.clone(), base_asset, asset_count); - let total_cost = amount + T::AssetManager::minimum_balance(base_asset.into()); - assert_ok!(T::AssetManager::deposit(base_asset.into(), &caller, total_cost)); + let total_cost = amount + T::AssetManager::minimum_balance(base_asset); + assert_ok!(T::AssetManager::deposit(base_asset, &caller, total_cost)); assert_ok_with_transaction!(T::CompleteSetOperations::buy_complete_set( caller.clone(), market_id, @@ -128,7 +124,7 @@ mod benchmarks { #[benchmark] fn buy(n: Linear<2, 16>, o: Linear<0, 10>) { let buyer: T::AccountId = whitelisted_caller(); - let base_asset = BaseAssetClass::Ztg; + let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( buyer.clone(), @@ -139,7 +135,7 @@ mod benchmarks { let asset = Asset::CategoricalOutcome(market_id, 0u16); let amount_in = _1000.saturated_into(); - assert_ok!(T::AssetManager::deposit(base_asset.into(), &buyer, amount_in)); + assert_ok!(T::AssetManager::deposit(base_asset, &buyer, amount_in)); let spot_prices = create_spot_prices::(asset_count); let first_spot_price = spot_prices[0]; @@ -148,7 +144,7 @@ mod benchmarks { let orders = (0u128..o as u128).collect::>(); let maker_asset = asset; let maker_amount = _20.saturated_into(); - let taker_asset: AssetOf = base_asset.into(); + let taker_asset = base_asset; let taker_amount: BalanceOf = _11.saturated_into(); assert!(taker_amount.bdiv_floor(maker_amount).unwrap() > first_spot_price); for (i, order_id) in orders.iter().enumerate() { @@ -182,14 +178,14 @@ mod benchmarks { let buyer_limit_order = T::Orderbook::order(o as u128).unwrap(); assert_eq!(buyer_limit_order.market_id, market_id); assert_eq!(buyer_limit_order.maker, buyer); - assert_eq!(buyer_limit_order.maker_asset, base_asset.into()); + assert_eq!(buyer_limit_order.maker_asset, base_asset); assert_eq!(buyer_limit_order.taker_asset, asset); } #[benchmark] fn sell(n: Linear<2, 10>, o: Linear<0, 10>) { let seller: T::AccountId = whitelisted_caller(); - let base_asset = BaseAssetClass::Ztg; + let base_asset = Asset::Ztg; let asset_count = n.try_into().unwrap(); let market_id = create_market_and_deploy_pool::( seller.clone(), @@ -204,15 +200,15 @@ mod benchmarks { // seller base asset amount needs to exist, // otherwise repatriate_reserved_named from order book fails // with DeadAccount for base asset repatriate to seller beneficiary - let min_balance = T::AssetManager::minimum_balance(base_asset.into()); - assert_ok!(T::AssetManager::deposit(base_asset.into(), &seller, min_balance)); + let min_balance = T::AssetManager::minimum_balance(base_asset); + assert_ok!(T::AssetManager::deposit(base_asset, &seller, min_balance)); let spot_prices = create_spot_prices::(asset_count); let first_spot_price = spot_prices[0]; let min_price = _1_100.saturated_into(); let orders = (0u128..o as u128).collect::>(); - let maker_asset: AssetOf = base_asset.into(); + let maker_asset: AssetOf = base_asset; let maker_amount: BalanceOf = _9.saturated_into(); let taker_asset = asset; let taker_amount = _100.saturated_into(); @@ -221,7 +217,11 @@ mod benchmarks { let order_creator: T::AccountId = account("order_creator", *order_id as u32, 0); let surplus = ((i + 1) as u128) * _1_2; let taker_amount = taker_amount + surplus.saturated_into::>(); - assert_ok!(T::AssetManager::deposit(maker_asset, &order_creator, maker_amount)); + assert_ok!(T::AssetManager::deposit( + maker_asset, + &order_creator, + maker_amount + _100.saturated_into() + )); T::Orderbook::place_order( order_creator, market_id, @@ -250,7 +250,7 @@ mod benchmarks { assert_eq!(seller_limit_order.market_id, market_id); assert_eq!(seller_limit_order.maker, seller); assert_eq!(seller_limit_order.maker_asset, asset); - assert_eq!(seller_limit_order.taker_asset, base_asset.into()); + assert_eq!(seller_limit_order.taker_asset, base_asset); } impl_benchmark_test_suite!( diff --git a/zrml/hybrid-router/src/lib.rs b/zrml/hybrid-router/src/lib.rs index d04f9476b..1544559d2 100644 --- a/zrml/hybrid-router/src/lib.rs +++ b/zrml/hybrid-router/src/lib.rs @@ -65,7 +65,7 @@ mod pallet { }, orderbook::{Order, OrderId}, traits::{HybridRouterAmmApi, HybridRouterOrderbookApi}, - types::{Asset, BaseAsset}, + types::Asset, }; use zrml_market_commons::MarketCommonsPalletApi; @@ -425,7 +425,7 @@ mod pallet { mut remaining: BalanceOf, who: &AccountIdOf, market_id: MarketIdOf, - base_asset: BaseAsset, + base_asset: AssetOf, asset: AssetOf, price_limit: BalanceOf, ) -> Result, DispatchError> { @@ -441,7 +441,7 @@ mod pallet { Err(_) => continue, }; - let order_price = order.price(base_asset.into())?; + let order_price = order.price(base_asset)?; match tx_type { TxType::Buy => { @@ -596,8 +596,8 @@ mod pallet { ensure!(asset_count as usize == assets.len(), Error::::AssetCountMismatch); let (asset_in, asset_out) = match tx_type { - TxType::Buy => (market.base_asset.into(), asset), - TxType::Sell => (asset, market.base_asset.into()), + TxType::Buy => (market.base_asset, asset), + TxType::Sell => (asset, market.base_asset), }; T::AssetManager::ensure_can_withdraw(asset_in, &who, amount_in)?; @@ -638,7 +638,7 @@ mod pallet { if !remaining.is_zero() { let (maker_asset, maker_amount, taker_asset, taker_amount) = match tx_type { TxType::Buy => { - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let maker_amount = remaining; let taker_asset = asset; let taker_amount = remaining.bdiv_ceil(price_limit)?; @@ -647,7 +647,7 @@ mod pallet { TxType::Sell => { let maker_asset = asset; let maker_amount = remaining; - let taker_asset = market.base_asset.into(); + let taker_asset = market.base_asset; let taker_amount = price_limit.bmul_floor(remaining)?; (maker_asset, maker_amount, taker_asset, taker_amount) } diff --git a/zrml/hybrid-router/src/mock.rs b/zrml/hybrid-router/src/mock.rs index c6195e160..8246d648e 100644 --- a/zrml/hybrid-router/src/mock.rs +++ b/zrml/hybrid-router/src/mock.rs @@ -27,50 +27,42 @@ use crate::{AssetOf, BalanceOf, MarketIdOf}; use core::marker::PhantomData; use frame_support::{ construct_runtime, ord_parameter_types, parameter_types, - traits::{AsEnsureOriginWithArg, Contains, Everything, NeverEnsureOrigin}, + traits::{Contains, Everything, NeverEnsureOrigin}, }; -use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSigned, EnsureSignedBy}; +use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSignedBy}; use orml_traits::MultiCurrency; -use parity_scale_codec::Compact; use sp_runtime::{ traits::{BlakeTwo256, ConstU32, Get, IdentityLookup, Zero}, BuildStorage, Perbill, Percent, SaturatedConversion, }; use zeitgeist_primitives::{ constants::mock::{ - AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AssetsAccountDeposit, - AssetsApprovalDeposit, AssetsDeposit, AssetsMetadataDepositBase, - AssetsMetadataDepositPerByte, AssetsStringLimit, AuthorizedPalletId, BlockHashCount, - BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, + AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AuthorizedPalletId, + BlockHashCount, BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, CloseEarlyProtectionBlockPeriod, CloseEarlyProtectionTimeFramePeriod, CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, - DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, - ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, HybridRouterPalletId, InflationPeriod, LiquidityMiningPalletId, - LockId, MaxAppeals, MaxApprovals, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, - MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, - MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOrders, - MaxOwners, MaxRejectReasonLen, MaxReserves, MaxSelectedDraws, MaxYearlyInflation, - MinCategories, MinDisputeDuration, MinJurorStake, MinOracleDuration, MinOutcomeVoteAmount, - MinimumPeriod, NeoMaxSwapFee, NeoSwapsPalletId, OrderbookPalletId, OutcomeBond, - OutcomeFactor, OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, + ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, + GlobalDisputeLockId, GlobalDisputesPalletId, HybridRouterPalletId, InflationPeriod, + LiquidityMiningPalletId, LockId, MaxAppeals, MaxApprovals, MaxCourtParticipants, + MaxCreatorFee, MaxDelegations, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, + MaxGlobalDisputeVotes, MaxGracePeriod, MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, + MaxOracleDuration, MaxOrders, MaxOwners, MaxRejectReasonLen, MaxReserves, MaxSelectedDraws, + MaxYearlyInflation, MinCategories, MinDisputeDuration, MinJurorStake, MinOracleDuration, + MinOutcomeVoteAmount, MinimumPeriod, NeoMaxSwapFee, NeoSwapsPalletId, OrderbookPalletId, + OutcomeBond, OutcomeFactor, OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, SimpleDisputesPalletId, TreasuryPalletId, VotePeriod, VotingOutcomeFee, BASE, CENT, MAX_ASSETS, }, traits::DistributeFees, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, CampaignAsset, - CampaignAssetId, Currencies, CustomAsset, CustomAssetId, Hash, MarketAsset, MarketId, - Moment, + AccountIdTest, Amount, Balance, BasicCurrencyAdapter, CurrencyId, Hash, MarketId, Moment, }, }; #[cfg(feature = "parachain")] use { - orml_traits::asset_registry::AssetProcessor, - parity_scale_codec::Encode, - sp_runtime::DispatchError, - zeitgeist_primitives::types::Asset, - zeitgeist_primitives::types::{CustomMetadata, XcmAsset}, + orml_traits::asset_registry::AssetProcessor, parity_scale_codec::Encode, + sp_runtime::DispatchError, zeitgeist_primitives::types::Asset, + zeitgeist_primitives::types::CustomMetadata, }; pub const ALICE: AccountIdTest = 0; @@ -154,24 +146,16 @@ impl Contains for DustRemovalWhitelist { } } -pub(super) type CustomAssetsInstance = pallet_assets::Instance1; -pub(super) type CampaignAssetsInstance = pallet_assets::Instance2; -pub(super) type MarketAssetsInstance = pallet_assets::Instance3; - construct_runtime!( pub enum Runtime { HybridRouter: zrml_hybrid_router, Orderbook: zrml_orderbook, - AssetRouter: zrml_asset_router, NeoSwaps: zrml_neo_swaps, #[cfg(feature = "parachain")] AssetRegistry: orml_asset_registry, Authorized: zrml_authorized, Balances: pallet_balances, Court: zrml_court, - CampaignAssets: pallet_assets::, - CustomAssets: pallet_assets::, - MarketAssets: pallet_assets::, AssetManager: orml_currencies, LiquidityMining: zrml_liquidity_mining, MarketCommons: zrml_market_commons, @@ -201,122 +185,6 @@ impl crate::Config for Runtime { type WeightInfo = zrml_hybrid_router::weights::WeightInfo; } -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - impl zrml_orderbook::Config for Runtime { type AssetManager = AssetManager; type ExternalFees = ExternalFees; @@ -344,8 +212,6 @@ impl zrml_prediction_markets::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; type ApproveOrigin = EnsureSignedBy; - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; #[cfg(feature = "parachain")] type AssetRegistry = AssetRegistry; type Authorized = Authorized; @@ -376,7 +242,6 @@ impl zrml_prediction_markets::Config for Runtime { type MinCategories = MinCategories; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; - type OnStateTransition = (); type OracleBond = OracleBond; type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; @@ -473,9 +338,9 @@ cfg_if::cfg_if!( >; pub struct NoopAssetProcessor {} - impl AssetProcessor for NoopAssetProcessor { - fn pre_register(id: Option, asset_metadata: AssetMetadata) - -> Result<(XcmAsset, AssetMetadata), DispatchError> { + impl AssetProcessor for NoopAssetProcessor { + fn pre_register(id: Option, asset_metadata: AssetMetadata) + -> Result<(CurrencyId, AssetMetadata), DispatchError> { Ok((id.unwrap(), asset_metadata)) } } @@ -483,7 +348,7 @@ cfg_if::cfg_if!( impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CustomMetadata = CustomMetadata; - type AssetId = XcmAsset; + type AssetId = CurrencyId; type AuthorityOrigin = EnsureRoot; type AssetProcessor = NoopAssetProcessor; type Balance = Balance; @@ -495,7 +360,7 @@ cfg_if::cfg_if!( impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = (); } @@ -503,7 +368,7 @@ impl orml_currencies::Config for Runtime { impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = DustRemovalWhitelist; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -625,8 +490,8 @@ impl ExtBuilder { { orml_tokens::GenesisConfig:: { balances: vec![ - (ALICE, FOREIGN_ASSET.try_into().unwrap(), INITIAL_BALANCE), - (FEE_ACCOUNT, FOREIGN_ASSET.try_into().unwrap(), INITIAL_BALANCE), + (ALICE, FOREIGN_ASSET, INITIAL_BALANCE), + (FEE_ACCOUNT, FOREIGN_ASSET, INITIAL_BALANCE), ], } .assimilate_storage(&mut t) @@ -637,7 +502,7 @@ impl ExtBuilder { }; orml_asset_registry::GenesisConfig:: { assets: vec![( - FOREIGN_ASSET.try_into().unwrap(), + FOREIGN_ASSET, AssetMetadata { decimals: 18, name: "MKL".as_bytes().to_vec().try_into().unwrap(), @@ -648,7 +513,7 @@ impl ExtBuilder { } .encode(), )], - last_asset_id: FOREIGN_ASSET.try_into().unwrap(), + last_asset_id: FOREIGN_ASSET, } .assimilate_storage(&mut t) .unwrap(); diff --git a/zrml/hybrid-router/src/tests/buy.rs b/zrml/hybrid-router/src/tests/buy.rs index e3da80452..dec84799d 100644 --- a/zrml/hybrid-router/src/tests/buy.rs +++ b/zrml/hybrid-router/src/tests/buy.rs @@ -16,6 +16,7 @@ // along with Zeitgeist. If not, see . use super::*; +use zeitgeist_primitives::types::Asset; #[test] fn buy_from_amm_and_then_fill_specified_order() { @@ -34,7 +35,7 @@ fn buy_from_amm_and_then_fill_specified_order() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; let order_maker_amount = _12; @@ -87,7 +88,7 @@ fn buy_from_amm_and_then_fill_specified_order() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: 85665315968, taker_asset: BASE_ASSET, taker_amount: unfilled_base_asset_amount, @@ -115,7 +116,7 @@ fn buy_from_amm_if_specified_order_has_higher_prices_than_the_amm() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _4; @@ -153,7 +154,7 @@ fn buy_from_amm_if_specified_order_has_higher_prices_than_the_amm() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _4, taker_asset: BASE_ASSET, taker_amount: _2, @@ -178,7 +179,7 @@ fn buy_fill_multiple_orders_if_amm_spot_price_higher_than_order_prices() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; let order_maker_amount = _1; @@ -237,7 +238,7 @@ fn buy_fill_specified_order_partially_if_amm_spot_price_higher() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _8; @@ -276,7 +277,7 @@ fn buy_fill_specified_order_partially_if_amm_spot_price_higher() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _4, taker_asset: BASE_ASSET, taker_amount: _2, @@ -301,7 +302,7 @@ fn buy_fails_if_asset_not_equal_to_order_book_maker_asset() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _1; assert_ok!(AssetManager::deposit(BASE_ASSET, &CHARLIE, order_maker_amount)); @@ -311,7 +312,7 @@ fn buy_fails_if_asset_not_equal_to_order_book_maker_asset() { market_id, BASE_ASSET, order_maker_amount, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), _2, )); @@ -354,7 +355,7 @@ fn buy_fails_if_order_price_above_max_price() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _1; @@ -362,7 +363,7 @@ fn buy_fails_if_order_price_above_max_price() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _2, @@ -407,7 +408,7 @@ fn buy_from_amm() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let max_price = _3_4.saturated_into::>(); let orders = vec![]; @@ -456,7 +457,7 @@ fn buy_max_price_lower_than_amm_spot_price_results_in_place_order() { let market = Markets::::get(market_id).unwrap(); let base_asset = market.base_asset; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; //* max_price is just 1 smaller than the spot price of the AMM //* this results in no buy on the AMM, but places an order on the order book @@ -483,7 +484,7 @@ fn buy_max_price_lower_than_amm_spot_price_results_in_place_order() { Order { market_id, maker: ALICE, - maker_asset: base_asset.into(), + maker_asset: base_asset, maker_amount: _2, taker_asset: asset, taker_amount: _4, @@ -510,7 +511,7 @@ fn buy_from_amm_but_low_amount() { let market = Markets::::get(market_id).unwrap(); let base_asset = market.base_asset; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; //* max_price is just 1 larger than the spot price of the AMM //* this results in a low buy amount_in on the AMM @@ -550,7 +551,7 @@ fn buy_from_amm_but_low_amount() { Order { market_id, maker: ALICE, - maker_asset: base_asset.into(), + maker_asset: base_asset, maker_amount: 19999999970, taker_asset: asset, taker_amount: 39999999933, @@ -575,7 +576,7 @@ fn buy_from_amm_only() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let max_price = _3_4.saturated_into::>(); let orders = vec![]; @@ -623,7 +624,7 @@ fn buy_places_limit_order_no_pool() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -648,7 +649,7 @@ fn buy_places_limit_order_no_pool() { Order { market_id, maker: ALICE, - maker_asset: base_asset.into(), + maker_asset: base_asset, maker_amount: 10 * BASE, taker_asset: asset, taker_amount: 20 * BASE, @@ -670,7 +671,7 @@ fn buy_fails_if_balance_too_low() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; assert_eq!(Balances::set_balance(&ALICE, amount - 1), amount - 1); @@ -710,7 +711,7 @@ fn buy_emits_event() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _1000 * 100; assert_ok!(AssetManager::deposit(BASE_ASSET, &ALICE, amount_in)); @@ -780,7 +781,7 @@ fn buy_fails_if_asset_count_mismatch() { let asset_count = 2; assert_ne!(required_asset_count, asset_count); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 2 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -814,7 +815,7 @@ fn buy_fails_if_price_limit_too_high() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE + 1).saturated_into::>(); let orders = vec![]; @@ -848,7 +849,7 @@ fn buy_succeeds_for_place_order_below_minimum_balance_soft_failure() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 1; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -887,7 +888,7 @@ fn buy_succeeds_for_numerical_soft_failure() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _1_100; let max_price = (_3_4).saturated_into::>(); @@ -912,7 +913,7 @@ fn buy_succeeds_for_numerical_soft_failure() { maker: ALICE, maker_asset: BASE_ASSET, maker_amount: _1_100, - taker_asset: Assets::CategoricalOutcome(market_id, 0), + taker_asset: Asset::CategoricalOutcome(market_id, 0), taker_amount: 133333334, } ); @@ -935,7 +936,7 @@ fn buy_just_one_unit_from_amm() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 1; let order_maker_amount = _2; @@ -943,7 +944,7 @@ fn buy_just_one_unit_from_amm() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _1, @@ -956,6 +957,8 @@ fn buy_just_one_unit_from_amm() { let max_price = (_1_2 + 1).saturated_into::>(); let orders = vec![order_id]; let strategy = Strategy::LimitOrder; + // Prevent ED error by giving Alice some extra tokens. + assert_ok!(AssetManager::deposit(asset, &ALICE, _1)); assert_ok!(HybridRouter::buy( RuntimeOrigin::signed(ALICE), market_id, @@ -973,7 +976,7 @@ fn buy_just_one_unit_from_amm() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _2, taker_asset: BASE_ASSET, taker_amount: _1, @@ -998,7 +1001,7 @@ fn buy_succeeds_for_fill_order_below_minimum_balance_soft_failure() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 1; let order_maker_amount = _2; @@ -1006,7 +1009,7 @@ fn buy_succeeds_for_fill_order_below_minimum_balance_soft_failure() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _1, @@ -1019,6 +1022,8 @@ fn buy_succeeds_for_fill_order_below_minimum_balance_soft_failure() { let max_price = _3_4.saturated_into::>(); let orders = vec![order_id]; let strategy = Strategy::LimitOrder; + // Prevent ED error by giving Alice some extra tokens. + assert_ok!(AssetManager::deposit(asset, &ALICE, _1)); assert_ok!(HybridRouter::buy( RuntimeOrigin::signed(ALICE), market_id, @@ -1036,7 +1041,7 @@ fn buy_succeeds_for_fill_order_below_minimum_balance_soft_failure() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _2, taker_asset: BASE_ASSET, taker_amount: _1, @@ -1061,7 +1066,7 @@ fn buy_succeeds_for_place_order_partial_fill_near_full_fill_not_allowed() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _1 - 1; let order_maker_amount = _2; @@ -1069,7 +1074,7 @@ fn buy_succeeds_for_place_order_partial_fill_near_full_fill_not_allowed() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _1, @@ -1099,7 +1104,7 @@ fn buy_succeeds_for_place_order_partial_fill_near_full_fill_not_allowed() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _2, taker_asset: BASE_ASSET, taker_amount: _1, @@ -1124,7 +1129,7 @@ fn buy_only_executes_first_order_from_orders_vector() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _1; let order_maker_amount = _2; @@ -1132,7 +1137,7 @@ fn buy_only_executes_first_order_from_orders_vector() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _1, @@ -1143,7 +1148,7 @@ fn buy_only_executes_first_order_from_orders_vector() { assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(DAVE), market_id, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), order_maker_amount, BASE_ASSET, _1, @@ -1176,7 +1181,7 @@ fn buy_only_executes_first_order_from_orders_vector() { Order { market_id, maker: CHARLIE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _2, taker_asset: BASE_ASSET, taker_amount: _1, @@ -1190,7 +1195,7 @@ fn buy_skips_fill_order_if_order_not_present_and_places_new_order() { ExtBuilder::default().build().execute_with(|| { let market_id = 0; let mut market = market_mock::(MARKET_CREATOR); - market.base_asset = BASE_ASSET.try_into().unwrap(); + market.base_asset = BASE_ASSET; let required_asset_count = match &market.market_type { MarketType::Scalar(_) => panic!("Categorical market type is expected!"), MarketType::Categorical(categories) => *categories, @@ -1199,7 +1204,7 @@ fn buy_skips_fill_order_if_order_not_present_and_places_new_order() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![42]; @@ -1223,7 +1228,7 @@ fn buy_skips_fill_order_if_order_not_present_and_places_new_order() { maker: ALICE, maker_asset: BASE_ASSET, maker_amount: 10 * BASE, - taker_asset: Assets::CategoricalOutcome(market_id, 0), + taker_asset: Asset::CategoricalOutcome(market_id, 0), taker_amount: 20 * BASE, } ); @@ -1243,7 +1248,7 @@ fn buy_fails_if_max_orders_exceeded() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = (0u128..100u128 + 1u128).collect::>(); @@ -1277,7 +1282,7 @@ fn buy_fails_if_amount_is_zero() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 0; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -1311,7 +1316,7 @@ fn buy_fails_if_cancel_strategy_applied() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -1337,7 +1342,7 @@ fn buy_fails_if_market_does_not_exist() { ExtBuilder::default().build().execute_with(|| { let market_id = 0; let asset_count = 2; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; diff --git a/zrml/hybrid-router/src/tests/mod.rs b/zrml/hybrid-router/src/tests/mod.rs index da55d7ba8..78c80d8a2 100644 --- a/zrml/hybrid-router/src/tests/mod.rs +++ b/zrml/hybrid-router/src/tests/mod.rs @@ -18,10 +18,7 @@ #![cfg(all(feature = "mock", test))] use crate::{mock::*, types::*, utils::*, AccountIdOf, BalanceOf, MarketIdOf, *}; -use frame_support::{ - assert_noop, assert_ok, - traits::{fungible::Mutate, tokens::Precision}, -}; +use frame_support::{assert_noop, assert_ok, traits::fungible::Mutate}; use orml_currencies::Error as CurrenciesError; use orml_tokens::Error as TokensError; use orml_traits::MultiCurrency; @@ -30,8 +27,8 @@ use zeitgeist_primitives::{ constants::{base_multiples::*, BASE, CENT}, orderbook::Order, types::{ - AccountIdTest, Assets, Deadlines, MarketCreation, MarketPeriod, MarketStatus, MarketType, - MultiHash, ScoringRule, + AccountIdTest, Asset, Deadlines, MarketCreation, MarketId, MarketPeriod, MarketStatus, + MarketType, MultiHash, ScoringRule, }, }; use zrml_market_commons::{Error as MError, MarketCommonsPalletApi, Markets}; @@ -42,13 +39,13 @@ mod buy; mod sell; #[cfg(not(feature = "parachain"))] -const BASE_ASSET: Assets = Assets::Ztg; +const BASE_ASSET: Asset = Asset::Ztg; #[cfg(feature = "parachain")] -const BASE_ASSET: Assets = FOREIGN_ASSET; +const BASE_ASSET: Asset = FOREIGN_ASSET; fn create_market( creator: AccountIdTest, - base_asset: Assets, + base_asset: AssetOf, market_type: MarketType, scoring_rule: ScoringRule, ) -> MarketIdOf { @@ -57,7 +54,7 @@ fn create_market( metadata[1] = 0x30; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(creator), - base_asset.try_into().unwrap(), + base_asset, Perbill::zero(), EVE, MarketPeriod::Block(0..2), @@ -77,7 +74,7 @@ fn create_market( fn create_market_and_deploy_pool( creator: AccountIdOf, - base_asset: Assets, + base_asset: AssetOf, market_type: MarketType, amount: BalanceOf, spot_prices: Vec>, diff --git a/zrml/hybrid-router/src/tests/sell.rs b/zrml/hybrid-router/src/tests/sell.rs index 030daf36d..1d76359f5 100644 --- a/zrml/hybrid-router/src/tests/sell.rs +++ b/zrml/hybrid-router/src/tests/sell.rs @@ -16,7 +16,7 @@ // along with Zeitgeist. If not, see . use super::*; -use frame_support::traits::fungibles::Unbalanced; +use zeitgeist_primitives::types::Asset; #[test] fn sell_to_amm_and_then_fill_specified_order() { @@ -35,7 +35,7 @@ fn sell_to_amm_and_then_fill_specified_order() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; let order_maker_amount = _6; @@ -52,7 +52,7 @@ fn sell_to_amm_and_then_fill_specified_order() { let order_ids = Orders::::iter().map(|(k, _)| k).collect::>(); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let min_price = _1_4.saturated_into::>(); let strategy = Strategy::LimitOrder; @@ -92,7 +92,7 @@ fn sell_to_amm_and_then_fill_specified_order() { maker: CHARLIE, maker_asset: BASE_ASSET, maker_amount: 52804047165, - taker_asset: Assets::CategoricalOutcome(market_id, 0), + taker_asset: Asset::CategoricalOutcome(market_id, 0), taker_amount: unfilled_base_asset_amount, } ); @@ -118,7 +118,7 @@ fn sell_to_amm_if_specified_order_has_lower_prices_than_the_amm() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _1; let order_maker_amount = _1; @@ -135,7 +135,7 @@ fn sell_to_amm_if_specified_order_has_lower_prices_than_the_amm() { let order_ids = Orders::::iter().map(|(k, _)| k).collect::>(); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); let min_price = _1_4.saturated_into::>(); let strategy = Strategy::LimitOrder; @@ -162,7 +162,7 @@ fn sell_to_amm_if_specified_order_has_lower_prices_than_the_amm() { maker: CHARLIE, maker_asset: BASE_ASSET, maker_amount: _1, - taker_asset: Assets::CategoricalOutcome(market_id, 0), + taker_asset: Asset::CategoricalOutcome(market_id, 0), taker_amount: _2, } ); @@ -185,7 +185,7 @@ fn sell_fill_multiple_orders_if_amm_spot_price_lower_than_order_prices() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; let order_maker_amount = _1_2; @@ -210,7 +210,7 @@ fn sell_fill_multiple_orders_if_amm_spot_price_lower_than_order_prices() { let order_ids = Orders::::iter().map(|(k, _)| k).collect::>(); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let min_price = _1_4.saturated_into::>(); let strategy = Strategy::LimitOrder; @@ -246,7 +246,7 @@ fn sell_fill_specified_order_partially_if_amm_spot_price_lower() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _4; @@ -265,7 +265,7 @@ fn sell_fill_specified_order_partially_if_amm_spot_price_lower() { assert_eq!(order_ids.len(), 1); let order_id = order_ids[0]; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); let min_price = _1_4.saturated_into::>(); let orders = vec![order_id]; @@ -289,7 +289,7 @@ fn sell_fill_specified_order_partially_if_amm_spot_price_lower() { maker: CHARLIE, maker_asset: BASE_ASSET, maker_amount: _3, - taker_asset: Assets::CategoricalOutcome(market_id, 0), + taker_asset: Asset::CategoricalOutcome(market_id, 0), taker_amount: _6, } ); @@ -312,11 +312,11 @@ fn sell_fails_if_asset_not_equal_to_order_book_taker_asset() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; let maker_amount = _1; - assert_ok!(AssetRouter::increase_balance(asset, &CHARLIE, maker_amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &CHARLIE, maker_amount,)); assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(CHARLIE), @@ -331,7 +331,7 @@ fn sell_fails_if_asset_not_equal_to_order_book_taker_asset() { assert_eq!(order_ids.len(), 1); let order_id = order_ids[0]; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let min_price = _1_4.saturated_into::>(); let orders = vec![order_id]; @@ -368,7 +368,7 @@ fn sell_fails_if_order_price_below_min_price() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; let order_maker_amount = _1; @@ -378,7 +378,7 @@ fn sell_fails_if_order_price_below_min_price() { market_id, BASE_ASSET, order_maker_amount, - Assets::CategoricalOutcome(market_id, 0), + Asset::CategoricalOutcome(market_id, 0), amount, )); @@ -386,7 +386,7 @@ fn sell_fails_if_order_price_below_min_price() { assert_eq!(order_ids.len(), 1); let order_id = order_ids[0]; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, 5 * amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, 5 * amount,)); let min_price = _3_4.saturated_into::>(); let orders = vec![order_id]; @@ -423,10 +423,10 @@ fn sell_to_amm() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); let min_price = _1_4.saturated_into::>(); let orders = vec![]; @@ -475,10 +475,10 @@ fn sell_min_price_higher_than_amm_spot_price_results_in_place_order() { let market = Markets::::get(market_id).unwrap(); let base_asset = market.base_asset; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); //* spot price of the AMM is 1 smaller than the min_price //* this results in no sell on the AMM, but places an order on the order book @@ -507,7 +507,7 @@ fn sell_min_price_higher_than_amm_spot_price_results_in_place_order() { maker: ALICE, maker_asset: asset, maker_amount: _2, - taker_asset: base_asset.into(), + taker_asset: base_asset, taker_amount: _1, } ); @@ -532,10 +532,10 @@ fn sell_to_amm_but_low_amount() { let market = Markets::::get(market_id).unwrap(); let base_asset = market.base_asset; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _2; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); //* min_price is just 1 smaller than the spot price of the AMM //* this results in a low sell amount_in on the AMM @@ -577,7 +577,7 @@ fn sell_to_amm_but_low_amount() { maker: ALICE, maker_asset: asset, maker_amount: 19999999942, - taker_asset: base_asset.into(), + taker_asset: base_asset, taker_amount: 9999999969, } ); @@ -600,12 +600,10 @@ fn sell_succeeds_for_numerical_soft_failure() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _1000 * 100; - // increase_balance does not set total issuance - AssetRouter::set_total_issuance(asset, amount_in); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let min_price = (_1_100 / 1000).saturated_into::>(); let orders = vec![]; @@ -627,7 +625,7 @@ fn sell_succeeds_for_numerical_soft_failure() { Order { market_id, maker: ALICE, - maker_asset: Assets::CategoricalOutcome(market_id, 0), + maker_asset: Asset::CategoricalOutcome(market_id, 0), maker_amount: _1000 * 100, taker_asset: BASE_ASSET, taker_amount: _1, @@ -652,10 +650,10 @@ fn sell_to_amm_only() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = _2; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); let min_price = _1_4.saturated_into::>(); let orders = vec![]; @@ -703,10 +701,10 @@ fn sell_places_limit_order_no_pool() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount,)); let min_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -733,7 +731,7 @@ fn sell_places_limit_order_no_pool() { maker: ALICE, maker_asset: asset, maker_amount: 10 * BASE, - taker_asset: base_asset.into(), + taker_asset: base_asset, taker_amount: 5 * BASE, } ); @@ -753,10 +751,10 @@ fn sell_fails_if_balance_too_low() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount = 10 * BASE; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount - 1, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount - 1,)); let min_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -794,7 +792,7 @@ fn sell_emits_event() { swap_fee, ); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = _1000 * 100; let min_price = _1_100.saturated_into::>(); @@ -807,7 +805,7 @@ fn sell_emits_event() { let order_creator = i as AccountIdTest; let surplus = ((i + 1) as u128) * _1_2; let taker_amount = taker_amount + surplus.saturated_into::>(); - assert_ok!(AssetManager::deposit(maker_asset, &order_creator, maker_amount)); + assert_ok!(AssetManager::deposit(maker_asset, &order_creator, maker_amount + _100)); assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(order_creator), market_id, @@ -820,9 +818,7 @@ fn sell_emits_event() { let order_ids = Orders::::iter().map(|(k, _)| k).collect::>(); - // increase_balance does not set total issuance - AssetRouter::set_total_issuance(asset, amount_in); - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let strategy = Strategy::LimitOrder; assert_ok!(HybridRouter::sell( @@ -868,10 +864,10 @@ fn sell_fails_if_asset_count_mismatch() { let asset_count = 2; assert_ne!(required_asset_count, asset_count); - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = 2 * BASE; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -905,7 +901,7 @@ fn sell_fails_if_amount_is_zero() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = 0; let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; @@ -939,9 +935,9 @@ fn sell_fails_if_cancel_strategy_applied() { Markets::::insert(market_id, market); let asset_count = required_asset_count; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = 10 * BASE; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; let strategy = Strategy::ImmediateOrCancel; @@ -966,9 +962,9 @@ fn sell_fails_if_market_does_not_exist() { ExtBuilder::default().build().execute_with(|| { let market_id = 0; let asset_count = 2; - let asset = Assets::CategoricalOutcome(market_id, 0); + let asset = Asset::CategoricalOutcome(market_id, 0); let amount_in = 10 * BASE; - assert_ok!(AssetRouter::increase_balance(asset, &ALICE, amount_in, Precision::Exact)); + assert_ok!(AssetManager::deposit(asset, &ALICE, amount_in,)); let max_price = (BASE / 2).saturated_into::>(); let orders = vec![]; let strategy = Strategy::ImmediateOrCancel; diff --git a/zrml/hybrid-router/src/utils.rs b/zrml/hybrid-router/src/utils.rs index 0dcc0e1ed..808296e26 100644 --- a/zrml/hybrid-router/src/utils.rs +++ b/zrml/hybrid-router/src/utils.rs @@ -21,13 +21,13 @@ use crate::{AccountIdOf, BalanceOf, MarketIdOf}; use frame_system::pallet_prelude::BlockNumberFor; use zeitgeist_primitives::{ traits::MarketCommonsPalletApi, - types::{BaseAsset, Market}, + types::{Asset, Market}, }; pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; pub(crate) type MarketOf = - Market, BalanceOf, BlockNumberFor, MomentOf, BaseAsset, MarketIdOf>; + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; pub(crate) fn market_mock(creator: T::AccountId) -> MarketOf where @@ -37,14 +37,14 @@ where use zeitgeist_primitives::{ constants::mock::PmPalletId, types::{ - BaseAssetClass, Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, ScoringRule, + Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, + MarketStatus, MarketType, ScoringRule, }, }; zeitgeist_primitives::types::Market { market_id: 0u8.into(), - base_asset: BaseAssetClass::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: Perbill::zero(), creator, diff --git a/zrml/hybrid-router/src/weights.rs b/zrml/hybrid-router/src/weights.rs index f039ad7d6..999a531dd 100644 --- a/zrml/hybrid-router/src/weights.rs +++ b/zrml/hybrid-router/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_hybrid_router //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -56,86 +56,82 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_hybrid_router (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Orderbook Orders (r:10 w:11) - /// Proof: Orderbook Orders (max_values: None, max_size: Some(142), added: 2617, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: System Account (r:12 w:12) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:16 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:27 w:27) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:16 w:16) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Reserves (r:10 w:10) - /// Proof: Tokens Reserves (max_values: None, max_size: Some(1276), added: 3751, mode: MaxEncodedLen) - /// Storage: Orderbook NextOrderId (r:1 w:1) - /// Proof: Orderbook NextOrderId (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::Orders` (r:10 w:11) + /// Proof: `Orderbook::Orders` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:12 w:12) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:27 w:27) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:16 w:16) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Reserves` (r:10 w:10) + /// Proof: `Tokens::Reserves` (`max_values`: None, `max_size`: Some(1276), added: 3751, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::NextOrderId` (r:1 w:1) + /// Proof: `Orderbook::NextOrderId` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 16]`. /// The range of component `o` is `[0, 10]`. fn buy(n: u32, o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `3097 + n * (198 ±0) + o * (607 ±0)` - // Estimated: `162435 + o * (11573 ±0) + n * (7816 ±0)` - // Minimum execution time: 862_753 nanoseconds. - Weight::from_parts(972_983_000, 162435) - // Standard Error: 1_585_660 - .saturating_add(Weight::from_parts(55_371_618, 0).saturating_mul(n.into())) - // Standard Error: 2_600_574 - .saturating_add(Weight::from_parts(639_976_872, 0).saturating_mul(o.into())) + // Measured: `1249 + n * (166 ±0) + o * (497 ±0)` + // Estimated: `148211 + n * (2598 ±1) + o * (3751 ±0)` + // Minimum execution time: 1_142_494 nanoseconds. + Weight::from_parts(1_189_864_000, 148211) + // Standard Error: 1_897_660 + .saturating_add(Weight::from_parts(53_552_640, 0).saturating_mul(n.into())) + // Standard Error: 3_112_272 + .saturating_add(Weight::from_parts(857_125_320, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(o.into()))) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(o.into()))) - .saturating_add(Weight::from_parts(0, 11573).saturating_mul(o.into())) - .saturating_add(Weight::from_parts(0, 7816).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 3751).saturating_mul(o.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:10 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:21 w:21) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Orderbook Orders (r:10 w:11) - /// Proof: Orderbook Orders (max_values: None, max_size: Some(142), added: 2617, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: System Account (r:12 w:12) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:10 w:10) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:10 w:10) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: Orderbook NextOrderId (r:1 w:1) - /// Proof: Orderbook NextOrderId (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Tokens Reserves (r:1 w:1) - /// Proof: Tokens Reserves (max_values: None, max_size: Some(1276), added: 3751, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:21 w:21) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::Orders` (r:10 w:11) + /// Proof: `Orderbook::Orders` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:12 w:12) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:10 w:10) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:10 w:10) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::NextOrderId` (r:1 w:1) + /// Proof: `Orderbook::NextOrderId` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Reserves` (r:1 w:1) + /// Proof: `Tokens::Reserves` (`max_values`: None, `max_size`: Some(1276), added: 3751, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 10]`. /// The range of component `o` is `[0, 10]`. fn sell(n: u32, o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `3238 + n * (196 ±0) + o * (418 ±0)` - // Estimated: `162462 + n * (7816 ±0) + o * (11546 ±0)` - // Minimum execution time: 718_572 nanoseconds. - Weight::from_parts(797_512_000, 162462) - // Standard Error: 2_580_820 - .saturating_add(Weight::from_parts(76_885_200, 0).saturating_mul(n.into())) - // Standard Error: 2_652_710 - .saturating_add(Weight::from_parts(541_861_257, 0).saturating_mul(o.into())) + // Measured: `1325 + n * (164 ±0) + o * (339 ±0)` + // Estimated: `148211 + n * (2598 ±2) + o * (3724 ±0)` + // Minimum execution time: 952_124 nanoseconds. + Weight::from_parts(1_009_864_000, 148211) + // Standard Error: 3_101_578 + .saturating_add(Weight::from_parts(83_265_420, 0).saturating_mul(n.into())) + // Standard Error: 3_187_974 + .saturating_add(Weight::from_parts(690_772_212, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(o.into()))) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(o.into()))) - .saturating_add(Weight::from_parts(0, 7816).saturating_mul(n.into())) - .saturating_add(Weight::from_parts(0, 11546).saturating_mul(o.into())) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 3724).saturating_mul(o.into())) } } diff --git a/zrml/liquidity-mining/src/tests.rs b/zrml/liquidity-mining/src/tests.rs index 1ec6f0387..55b2aa4f3 100644 --- a/zrml/liquidity-mining/src/tests.rs +++ b/zrml/liquidity-mining/src/tests.rs @@ -32,8 +32,8 @@ use frame_support::{ use frame_system::RawOrigin; use sp_runtime::DispatchError; use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, ScoringRule, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, + MarketStatus, MarketType, ScoringRule, }; use zrml_market_commons::Markets; @@ -204,7 +204,7 @@ fn create_default_market(market_id: u128, period: Range) { market_id, Market { market_id: Default::default(), - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: 0, diff --git a/zrml/liquidity-mining/src/weights.rs b/zrml/liquidity-mining/src/weights.rs index 07dc1385b..d643d61dc 100644 --- a/zrml/liquidity-mining/src/weights.rs +++ b/zrml/liquidity-mining/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_liquidity_mining //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-24`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -55,13 +55,13 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_liquidity_mining (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: LiquidityMining PerBlockIncentive (r:0 w:1) - /// Proof: LiquidityMining PerBlockIncentive (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: `LiquidityMining::PerBlockIncentive` (r:0 w:1) + /// Proof: `LiquidityMining::PerBlockIncentive` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) fn set_per_block_distribution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_170 nanoseconds. - Weight::from_parts(6_020_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 5_180 nanoseconds. + Weight::from_parts(6_820_000, 0).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/market-commons/src/lib.rs b/zrml/market-commons/src/lib.rs index 73deadb4a..cce65a670 100644 --- a/zrml/market-commons/src/lib.rs +++ b/zrml/market-commons/src/lib.rs @@ -43,7 +43,7 @@ mod pallet { Blake2_128Concat, Parameter, }; use frame_system::pallet_prelude::BlockNumberFor; - use parity_scale_codec::{FullCodec, HasCompact, MaxEncodedLen}; + use parity_scale_codec::{FullCodec, MaxEncodedLen}; use sp_runtime::{ traits::{ AtLeast32Bit, AtLeast32BitUnsigned, MaybeSerializeDeserialize, Member, Saturating, @@ -53,25 +53,18 @@ mod pallet { use zeitgeist_primitives::{ math::checked_ops_res::CheckedAddRes, traits::MarketBuilderTrait, - types::{ - BaseAsset, Deadlines, EarlyClose, Market, MarketBonds, MarketPeriod, PoolId, Report, - }, + types::{Asset, Deadlines, EarlyClose, Market, MarketBonds, MarketPeriod, PoolId, Report}, }; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(11); pub(crate) type AccountIdOf = ::AccountId; + pub(crate) type AssetOf = Asset>; pub(crate) type BalanceOf = ::Balance; pub(crate) type MarketIdOf = ::MarketId; - pub(crate) type MarketOf = Market< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAsset, - MarketIdOf, - >; + pub(crate) type MarketOf = + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; pub(crate) type MomentOf = <::Timestamp as frame_support::traits::Time>::Moment; pub(crate) type DeadlinesOf = Deadlines>; pub(crate) type EarlyCloseOf = EarlyClose, MomentOf>; @@ -97,7 +90,6 @@ mod pallet { type MarketId: AtLeast32Bit + Copy + Default - + HasCompact + MaxEncodedLen + MaybeSerializeDeserialize + Member @@ -208,7 +200,6 @@ mod pallet { Self::Balance, Self::BlockNumber, Self::Moment, - BaseAsset, Self::MarketId, >, { diff --git a/zrml/market-commons/src/migrations.rs b/zrml/market-commons/src/migrations.rs index 6fc68013b..7bcc6e2e5 100644 --- a/zrml/market-commons/src/migrations.rs +++ b/zrml/market-commons/src/migrations.rs @@ -15,377 +15,3 @@ // // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . - -use crate::{AccountIdOf, BalanceOf, Config, MomentOf, Pallet as MarketCommons}; -use alloc::vec::Vec; -use core::marker::PhantomData; -use frame_support::{ - traits::{Get, OnRuntimeUpgrade, StorageVersion}, - weights::Weight, -}; -use frame_system::pallet_prelude::BlockNumberFor; -use log; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::{Perbill, RuntimeDebug, Saturating}; -use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, EarlyClose, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, OutcomeReport, Report, ScoringRule, -}; - -#[cfg(feature = "try-runtime")] -use { - crate::MarketIdOf, - alloc::{collections::BTreeMap, format}, - frame_support::migration::storage_key_iter, - sp_runtime::DispatchError, -}; - -#[cfg(any(feature = "try-runtime", feature = "test"))] -use frame_support::Blake2_128Concat; - -#[cfg(any(feature = "try-runtime", test))] -const MARKET_COMMONS: &[u8] = b"MarketCommons"; -#[cfg(any(feature = "try-runtime", test))] -const MARKETS: &[u8] = b"Markets"; - -#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct OldMarket { - pub base_asset: A, - pub creator: AI, - pub creation: MarketCreation, - pub creator_fee: Perbill, - pub oracle: AI, - pub metadata: Vec, - pub market_type: MarketType, - pub period: MarketPeriod, - pub deadlines: Deadlines, - pub scoring_rule: OldScoringRule, - pub status: MarketStatus, - pub report: Option>, - pub resolved_outcome: Option, - pub dispute_mechanism: Option, - pub bonds: MarketBonds, - pub early_close: Option>, -} - -type OldMarketOf = - OldMarket, BalanceOf, BlockNumberFor, MomentOf, BaseAsset>; - -#[derive(TypeInfo, Clone, Copy, Encode, Eq, Decode, MaxEncodedLen, PartialEq, RuntimeDebug)] -pub enum OldScoringRule { - Lmsr, - Orderbook, - Parimutuel, -} - -const MARKET_COMMONS_REQUIRED_STORAGE_VERSION: u16 = 10; -const MARKET_COMMONS_NEXT_STORAGE_VERSION: u16 = 11; - -#[cfg(feature = "try-runtime")] -#[frame_support::storage_alias] -pub(crate) type Markets = - StorageMap, Blake2_128Concat, MarketIdOf, OldMarketOf>; - -pub struct MigrateScoringRuleAmmCdaHybridAndMarketId(PhantomData); - -/// Migrates AMM and CDA markets to the new combined scoring rule and adds the market's ID to the -/// struct. -impl OnRuntimeUpgrade for MigrateScoringRuleAmmCdaHybridAndMarketId -where - T: Config, -{ - 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!( - "MigrateScoringRuleAmmCdaHybridAndMarketId: market-commons version is {:?}, but \ - {:?} is required", - market_commons_version, - MARKET_COMMONS_REQUIRED_STORAGE_VERSION, - ); - return total_weight; - } - log::info!("MigrateScoringRuleAmmCdaHybridAndMarketId: Starting..."); - - let mut translated = 0u64; - crate::Markets::::translate::, _>(|market_id, old_market| { - translated.saturating_inc(); - let scoring_rule = match old_market.scoring_rule { - OldScoringRule::Lmsr => ScoringRule::AmmCdaHybrid, - OldScoringRule::Orderbook => ScoringRule::AmmCdaHybrid, - OldScoringRule::Parimutuel => ScoringRule::Parimutuel, - }; - let new_market = Market { - market_id, - base_asset: old_market.base_asset, - 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, - deadlines: old_market.deadlines, - scoring_rule, - status: old_market.status, - report: old_market.report, - resolved_outcome: old_market.resolved_outcome, - dispute_mechanism: old_market.dispute_mechanism, - bonds: old_market.bonds, - early_close: old_market.early_close, - }; - Some(new_market) - }); - log::info!("MigrateScoringRuleAmmCdaHybridAndMarketId: Upgraded {} markets.", translated); - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(translated, translated)); - - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION).put::>(); - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - log::info!("MigrateScoringRuleAmmCdaHybridAndMarketId: Done!"); - total_weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, DispatchError> { - let old_markets = storage_key_iter::, OldMarketOf, Blake2_128Concat>( - MARKET_COMMONS, - MARKETS, - ) - .collect::>(); - let markets = Markets::::iter_keys().count(); - let decodable_markets = Markets::::iter_values().count(); - if markets == decodable_markets { - log::info!("All {} markets could successfully be decoded.", markets); - } else { - log::error!( - "Can only decode {} of {} markets - others will be dropped.", - decodable_markets, - markets - ); - } - - Ok(old_markets.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(previous_state: Vec) -> Result<(), DispatchError> { - let old_markets: BTreeMap, OldMarketOf> = - Decode::decode(&mut &previous_state[..]).unwrap(); - let old_market_count = old_markets.len(); - let new_market_count = crate::Markets::::iter().count(); - assert_eq!(old_market_count, new_market_count); - for (market_id, new_market) in crate::Markets::::iter() { - let old_market = old_markets - .get(&market_id) - .expect(&format!("Market {:?} not found", market_id)[..]); - assert_eq!(market_id, new_market.market_id); - assert_eq!(old_market.base_asset, new_market.base_asset); - assert_eq!(old_market.creator, new_market.creator); - assert_eq!(old_market.creation, new_market.creation); - assert_eq!(old_market.creator_fee, new_market.creator_fee); - assert_eq!(old_market.oracle, new_market.oracle); - assert_eq!(old_market.metadata, new_market.metadata); - assert_eq!(old_market.market_type, new_market.market_type); - assert_eq!(old_market.period, new_market.period); - assert_eq!(old_market.deadlines, new_market.deadlines); - assert_eq!(old_market.status, new_market.status); - assert_eq!(old_market.report, new_market.report); - assert_eq!(old_market.resolved_outcome, new_market.resolved_outcome); - assert_eq!(old_market.dispute_mechanism, new_market.dispute_mechanism); - assert_eq!(old_market.bonds, new_market.bonds); - assert_eq!(old_market.early_close, new_market.early_close); - } - log::info!( - "MigrateScoringRuleAmmCdaHybridAndMarketId: Post-upgrade market count is {}!", - new_market_count - ); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - mock::{ExtBuilder, Runtime}, - MarketOf, - }; - use alloc::fmt::Debug; - use frame_support::{migration::put_storage_value, Blake2_128Concat, StorageHasher}; - use parity_scale_codec::Encode; - use sp_io::storage::root as storage_root; - use sp_runtime::{Perbill, StateVersion}; - use test_case::test_case; - use zeitgeist_primitives::types::{BaseAssetClass, Bond, EarlyCloseState, MarketId}; - - #[test] - fn on_runtime_upgrade_increments_the_storage_version() { - ExtBuilder::default().build().execute_with(|| { - set_up_version(); - MigrateScoringRuleAmmCdaHybridAndMarketId::::on_runtime_upgrade(); - assert_eq!( - StorageVersion::get::>(), - MARKET_COMMONS_NEXT_STORAGE_VERSION - ); - }); - } - - #[test_case(OldScoringRule::Orderbook, ScoringRule::AmmCdaHybrid)] - #[test_case(OldScoringRule::Lmsr, ScoringRule::AmmCdaHybrid)] - #[test_case(OldScoringRule::Parimutuel, ScoringRule::Parimutuel)] - fn on_runtime_upgrade_works_as_expected( - old_scoring_rule: OldScoringRule, - new_scoring_rule: ScoringRule, - ) { - ExtBuilder::default().build().execute_with(|| { - set_up_version(); - let (old_markets, new_markets) = - construct_old_new_tuple(old_scoring_rule, new_scoring_rule); - populate_test_data::>( - MARKET_COMMONS, - MARKETS, - old_markets, - ); - MigrateScoringRuleAmmCdaHybridAndMarketId::::on_runtime_upgrade(); - assert_eq!(crate::Markets::::get(0).unwrap(), new_markets[0]); - assert_eq!(crate::Markets::::get(1).unwrap(), new_markets[1]); - assert_eq!(crate::Markets::::get(2).unwrap(), new_markets[2]); - }); - } - - #[test] - fn on_runtime_upgrade_is_noop_if_versions_are_not_correct() { - ExtBuilder::default().build().execute_with(|| { - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION) - .put::>(); - let market = Market { - market_id: 7, - base_asset: BaseAssetClass::Ztg, - creator: 1, - creation: MarketCreation::Permissionless, - creator_fee: Perbill::from_rational(2u32, 3u32), - oracle: 4, - metadata: vec![0x05; 50], - market_type: MarketType::Categorical(999), - period: MarketPeriod::, MomentOf>::Block(6..7), - deadlines: Deadlines { grace_period: 7, oracle_duration: 8, dispute_duration: 9 }, - scoring_rule: ScoringRule::AmmCdaHybrid, - status: MarketStatus::Active, - report: Some(Report { at: 13, by: 14, outcome: OutcomeReport::Categorical(10) }), - resolved_outcome: None, - dispute_mechanism: Some(MarketDisputeMechanism::Court), - bonds: MarketBonds { - creation: Some(Bond::new(11, 12)), - oracle: None, - outsider: None, - dispute: None, - close_dispute: None, - close_request: None, - }, - early_close: None, - }; - crate::Markets::::insert(333, market); - let tmp = storage_root(StateVersion::V1); - MigrateScoringRuleAmmCdaHybridAndMarketId::::on_runtime_upgrade(); - assert_eq!(tmp, storage_root(StateVersion::V1)); - }); - } - - fn set_up_version() { - StorageVersion::new(MARKET_COMMONS_REQUIRED_STORAGE_VERSION) - .put::>(); - } - - fn construct_old_new_tuple( - old_scoring_rule: OldScoringRule, - new_scoring_rule: ScoringRule, - ) -> (Vec>, Vec>) { - let base_asset = BaseAsset::Ztg; - let creation = MarketCreation::Advised; - let creator_fee = Perbill::from_rational(2u32, 3u32); - let oracle = 4; - let metadata = vec![5; 50]; - let market_type = MarketType::Scalar(6..=7); - let period = MarketPeriod::Block(8..9); - let deadlines = Deadlines { grace_period: 10, oracle_duration: 11, dispute_duration: 12 }; - let status = MarketStatus::Resolved; - let report = Some(Report { at: 13, by: 14, outcome: OutcomeReport::Categorical(15) }); - let resolved_outcome = Some(OutcomeReport::Categorical(16)); - let dispute_mechanism = Some(MarketDisputeMechanism::Court); - let bonds = MarketBonds { - creation: Some(Bond { who: 17, value: 18, is_settled: true }), - oracle: Some(Bond { who: 19, value: 20, is_settled: true }), - outsider: Some(Bond { who: 21, value: 22, is_settled: true }), - dispute: Some(Bond { who: 23, value: 24, is_settled: true }), - close_request: Some(Bond { who: 25, value: 26, is_settled: true }), - close_dispute: Some(Bond { who: 27, value: 28, is_settled: true }), - }; - let early_close = Some(EarlyClose { - old: MarketPeriod::Block(29..30), - new: MarketPeriod::Block(31..32), - state: EarlyCloseState::Disputed, - }); - let sentinels = (0..3).map(|i| 10 - i); - let old_markets = sentinels - .clone() - .map(|sentinel| OldMarket { - base_asset, - creator: sentinel, - creation: creation.clone(), - creator_fee, - oracle, - metadata: metadata.clone(), - market_type: market_type.clone(), - period: period.clone(), - deadlines, - scoring_rule: old_scoring_rule, - status, - report: report.clone(), - resolved_outcome: resolved_outcome.clone(), - dispute_mechanism: dispute_mechanism.clone(), - bonds: bonds.clone(), - early_close: early_close.clone(), - }) - .collect(); - let new_markets = sentinels - .enumerate() - .map(|(index, sentinel)| Market { - market_id: index as u128, - base_asset, - creator: sentinel, - creation: creation.clone(), - creator_fee, - oracle, - metadata: metadata.clone(), - market_type: market_type.clone(), - period: period.clone(), - deadlines, - scoring_rule: new_scoring_rule, - status, - report: report.clone(), - resolved_outcome: resolved_outcome.clone(), - dispute_mechanism: dispute_mechanism.clone(), - bonds: bonds.clone(), - early_close: early_close.clone(), - }) - .collect(); - (old_markets, new_markets) - } - - #[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 = K::try_from(key).unwrap().using_encoded(H::hash).as_ref().to_vec(); - put_storage_value::(pallet, prefix, &storage_hash, (*value).clone()); - } - } -} diff --git a/zrml/market-commons/src/tests.rs b/zrml/market-commons/src/tests.rs index a7d26af88..a2ba2d317 100644 --- a/zrml/market-commons/src/tests.rs +++ b/zrml/market-commons/src/tests.rs @@ -28,7 +28,7 @@ use sp_runtime::{DispatchError, Perbill}; use zeitgeist_primitives::{ traits::{MarketBuilderTrait, MarketCommonsPalletApi}, types::{ - BaseAsset, Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, + Asset, Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, ScoringRule, }, }; @@ -37,7 +37,7 @@ use zeitgeist_primitives::{ fn create_market_builder(oracle: AccountIdOf) -> MarketBuilder { let mut market_builder = MarketBuilder::new(); market_builder - .base_asset(BaseAsset::Ztg) + .base_asset(Asset::Ztg) .creation(MarketCreation::Permissionless) .creator_fee(Perbill::zero()) .creator(0) diff --git a/zrml/market-commons/src/types/market_builder.rs b/zrml/market-commons/src/types/market_builder.rs index 537cc9eb7..cc7e57fd8 100644 --- a/zrml/market-commons/src/types/market_builder.rs +++ b/zrml/market-commons/src/types/market_builder.rs @@ -16,8 +16,8 @@ // along with Zeitgeist. If not, see . use crate::{ - AccountIdOf, BalanceOf, Config, DeadlinesOf, EarlyCloseOf, Error, MarketBondsOf, MarketIdOf, - MarketOf, MarketPeriodOf, MomentOf, ReportOf, + AccountIdOf, AssetOf, BalanceOf, Config, DeadlinesOf, EarlyCloseOf, Error, MarketBondsOf, + MarketIdOf, MarketOf, MarketPeriodOf, MomentOf, ReportOf, }; use alloc::vec::Vec; use frame_system::pallet_prelude::BlockNumberFor; @@ -25,8 +25,8 @@ use sp_runtime::{DispatchError, Perbill}; use zeitgeist_primitives::{ traits::MarketBuilderTrait, types::{ - BaseAsset, Market, MarketCreation, MarketDisputeMechanism, MarketStatus, MarketType, - OutcomeReport, ScoringRule, + Market, MarketCreation, MarketDisputeMechanism, MarketStatus, MarketType, OutcomeReport, + ScoringRule, }, }; @@ -37,7 +37,7 @@ where T: Config, { market_id: Option>, - base_asset: Option, + base_asset: Option>, creator: Option>, creation: Option, creator_fee: Option, @@ -113,14 +113,8 @@ where } impl - MarketBuilderTrait< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAsset, - MarketIdOf, - > for MarketBuilder + MarketBuilderTrait, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf> + for MarketBuilder where T: Config, { @@ -148,7 +142,7 @@ where impl_builder_methods! { market_id: MarketIdOf, - base_asset: BaseAsset, + base_asset: AssetOf, creator: AccountIdOf, creation: MarketCreation, creator_fee: Perbill, diff --git a/zrml/neo-swaps/Cargo.toml b/zrml/neo-swaps/Cargo.toml index 334cb6173..b4c3eca3b 100644 --- a/zrml/neo-swaps/Cargo.toml +++ b/zrml/neo-swaps/Cargo.toml @@ -20,7 +20,6 @@ env_logger = { workspace = true, optional = true } orml-asset-registry = { workspace = true, optional = true } orml-currencies = { workspace = true, optional = true } orml-tokens = { workspace = true, optional = true } -pallet-assets = { workspace = true, optional = true } pallet-balances = { workspace = true, optional = true } pallet-insecure-randomness-collective-flip = { workspace = true, optional = true } pallet-timestamp = { workspace = true, optional = true } @@ -31,7 +30,6 @@ sp-api = { workspace = true, optional = true } sp-io = { workspace = true, optional = true } xcm = { workspace = true, optional = true } xcm-builder = { workspace = true, optional = true } -zrml-asset-router = { workspace = true, optional = true } zrml-authorized = { workspace = true, optional = true } zrml-court = { workspace = true, optional = true } zrml-global-disputes = { workspace = true, optional = true } @@ -62,13 +60,11 @@ mock = [ "orml-asset-registry/default", "orml-currencies/default", "orml-tokens/default", - "pallet-assets/default", "pallet-balances/default", "pallet-timestamp/default", "sp-api/default", "sp-io/default", "zrml-court/std", - "zrml-asset-router/std", "zrml-authorized/std", "zrml-liquidity-mining/std", "zrml-simple-disputes/std", @@ -84,10 +80,8 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-assets?/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", - "zrml-prediction-markets/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", ] std = [ "frame-benchmarking?/std", diff --git a/zrml/neo-swaps/src/benchmarking.rs b/zrml/neo-swaps/src/benchmarking.rs index 89d896f36..22c0d58b2 100644 --- a/zrml/neo-swaps/src/benchmarking.rs +++ b/zrml/neo-swaps/src/benchmarking.rs @@ -176,7 +176,7 @@ fn create_market( ) -> MarketIdOf { let market = Market { market_id: 0u8.into(), - base_asset: base_asset.try_into().unwrap(), + base_asset, creation: MarketCreation::Permissionless, creator_fee: Perbill::zero(), creator: caller.clone(), diff --git a/zrml/neo-swaps/src/lib.rs b/zrml/neo-swaps/src/lib.rs index 8b2e5bad0..07d3d3566 100644 --- a/zrml/neo-swaps/src/lib.rs +++ b/zrml/neo-swaps/src/lib.rs @@ -890,14 +890,14 @@ mod pallet { let pool_account_id = Self::pool_account_id(&market_id); let mut reserves = BTreeMap::new(); for (&amount_in, &asset) in amounts_in.iter().zip(market.outcome_assets().iter()) { - T::MultiCurrency::transfer(asset.into(), &who, &pool_account_id, amount_in)?; - let _ = reserves.insert(asset.into(), amount_in); + T::MultiCurrency::transfer(asset, &who, &pool_account_id, amount_in)?; + let _ = reserves.insert(asset, amount_in); } let collateral = market.base_asset; let pool = Pool { account_id: pool_account_id.clone(), reserves: reserves.clone().try_into().map_err(|_| Error::::Unexpected)?, - collateral: collateral.into(), + collateral, liquidity_parameter, liquidity_shares_manager: LiquidityTree::new(who.clone(), amount)?, swap_fee, @@ -908,7 +908,7 @@ mod pallet { pool.collateral, &who, &pool.account_id, - T::MultiCurrency::minimum_balance(collateral.into()), + T::MultiCurrency::minimum_balance(collateral), )?; Pools::::insert(market_id, pool); Self::deposit_event(Event::::PoolDeployed { @@ -916,7 +916,7 @@ mod pallet { market_id, account_id: pool_account_id, reserves, - collateral: collateral.into(), + collateral, liquidity_parameter, pool_shares_amount: amount, swap_fee, diff --git a/zrml/neo-swaps/src/macros.rs b/zrml/neo-swaps/src/macros.rs index c8ea923a6..0c7bbb986 100644 --- a/zrml/neo-swaps/src/macros.rs +++ b/zrml/neo-swaps/src/macros.rs @@ -50,7 +50,6 @@ macro_rules! create_b_tree_map { /// their expected stake. /// - `total_fees`: The sum of all fees (both lazy and distributed) in the pool's liquidity tree. #[macro_export] -#[cfg(test)] macro_rules! assert_pool_state { ( $market_id:expr, @@ -107,7 +106,6 @@ macro_rules! assert_pool_state { /// Asserts that `account` has the specified `balances` of `assets`. #[macro_export] -#[cfg(test)] macro_rules! assert_balances { ($account:expr, $assets:expr, $balances:expr $(,)?) => { assert_eq!( @@ -116,7 +114,7 @@ macro_rules! assert_balances { "assert_balances: Assets and balances length mismatch" ); for (&asset, &expected_balance) in $assets.iter().zip($balances.iter()) { - let actual_balance = AssetManager::free_balance(asset.try_into().unwrap(), &$account); + let actual_balance = AssetManager::free_balance(asset, &$account); assert_eq!( actual_balance, expected_balance, "assert_balances: Balance mismatch for asset {:?}", @@ -128,7 +126,6 @@ macro_rules! assert_balances { /// Asserts that `account` has the specified `balance` of `asset`. #[macro_export] -#[cfg(test)] macro_rules! assert_balance { ($account:expr, $asset:expr, $balance:expr $(,)?) => { assert_balances!($account, [$asset], [$balance]); @@ -137,7 +134,6 @@ macro_rules! assert_balance { /// Asserts that `abs(left - right) < precision`. #[macro_export] -#[cfg(test)] macro_rules! assert_approx { ($left:expr, $right:expr, $precision:expr $(,)?) => { match (&$left, &$right, &$precision) { diff --git a/zrml/neo-swaps/src/mock.rs b/zrml/neo-swaps/src/mock.rs index 35f3f52fb..f066a31cd 100644 --- a/zrml/neo-swaps/src/mock.rs +++ b/zrml/neo-swaps/src/mock.rs @@ -28,53 +28,47 @@ use crate::{consts::*, AssetOf, MarketIdOf}; use core::marker::PhantomData; use frame_support::{ construct_runtime, ord_parameter_types, parameter_types, - traits::{AsEnsureOriginWithArg, Contains, Everything, NeverEnsureOrigin}, + traits::{Contains, Everything, NeverEnsureOrigin}, }; -use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSigned, EnsureSignedBy}; +use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSignedBy}; use orml_traits::MultiCurrency; -use parity_scale_codec::Compact; use sp_runtime::{ traits::{BlakeTwo256, ConstU32, Get, IdentityLookup, Zero}, BuildStorage, DispatchResult, Perbill, Percent, SaturatedConversion, }; +#[cfg(feature = "parachain")] +use zeitgeist_primitives::types::Asset; use zeitgeist_primitives::{ constants::{ base_multiples::*, mock::{ - AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AssetsAccountDeposit, - AssetsApprovalDeposit, AssetsDeposit, AssetsMetadataDepositBase, - AssetsMetadataDepositPerByte, AssetsStringLimit, AuthorizedPalletId, BlockHashCount, - BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, + AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AuthorizedPalletId, + BlockHashCount, BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, CloseEarlyProtectionBlockPeriod, CloseEarlyProtectionTimeFramePeriod, CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, - DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, - ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, LockId, MaxAppeals, - MaxApprovals, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, MaxDisputeDuration, - MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, - MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOwners, - MaxRejectReasonLen, MaxReserves, MaxSelectedDraws, MaxYearlyInflation, MinCategories, - MinDisputeDuration, MinJurorStake, MinOracleDuration, MinOutcomeVoteAmount, - MinimumPeriod, NeoMaxSwapFee, NeoSwapsPalletId, OutcomeBond, OutcomeFactor, - OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, SimpleDisputesPalletId, - TreasuryPalletId, VotePeriod, VotingOutcomeFee, BASE, CENT, + ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, + GlobalDisputeLockId, GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, + LockId, MaxAppeals, MaxApprovals, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, + MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, + MaxGracePeriod, MaxLiquidityTreeDepth, MaxLocks, MaxMarketLifetime, MaxOracleDuration, + MaxOwners, MaxRejectReasonLen, MaxReserves, MaxSelectedDraws, MaxYearlyInflation, + MinCategories, MinDisputeDuration, MinJurorStake, MinOracleDuration, + MinOutcomeVoteAmount, MinimumPeriod, NeoMaxSwapFee, NeoSwapsPalletId, OutcomeBond, + OutcomeFactor, OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, + SimpleDisputesPalletId, TreasuryPalletId, VotePeriod, VotingOutcomeFee, BASE, CENT, }, }, math::fixed::FixedMul, traits::{DeployPoolApi, DistributeFees}, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, CampaignAsset, - CampaignAssetId, Currencies, CustomAsset, CustomAssetId, Hash, MarketAsset, MarketId, - Moment, + AccountIdTest, Amount, Balance, BasicCurrencyAdapter, CurrencyId, Hash, MarketId, Moment, }, }; use zrml_neo_swaps::BalanceOf; #[cfg(feature = "parachain")] use { - orml_traits::asset_registry::AssetProcessor, - parity_scale_codec::Encode, - sp_runtime::DispatchError, - zeitgeist_primitives::types::{CustomMetadata, XcmAsset}, + orml_traits::asset_registry::AssetProcessor, parity_scale_codec::Encode, + sp_runtime::DispatchError, zeitgeist_primitives::types::CustomMetadata, }; pub const ALICE: AccountIdTest = 0; @@ -88,7 +82,7 @@ pub const SUDO: AccountIdTest = 123456; pub const EXTERNAL_FEES: Balance = CENT; #[cfg(feature = "parachain")] -pub const FOREIGN_ASSET: Assets = Assets::ForeignAsset(1); +pub const FOREIGN_ASSET: Asset = Asset::ForeignAsset(1); parameter_types! { pub const FeeAccount: AccountIdTest = FEE_ACCOUNT; @@ -166,24 +160,16 @@ impl Contains for DustRemovalWhitelist { } } -pub(super) type CustomAssetsInstance = pallet_assets::Instance1; -pub(super) type CampaignAssetsInstance = pallet_assets::Instance2; -pub(super) type MarketAssetsInstance = pallet_assets::Instance3; - construct_runtime!( pub enum Runtime { NeoSwaps: zrml_neo_swaps, AssetManager: orml_currencies, #[cfg(feature = "parachain")] AssetRegistry: orml_asset_registry, - AssetRouter: zrml_asset_router, Authorized: zrml_authorized, Balances: pallet_balances, - CampaignAssets: pallet_assets::, Court: zrml_court, - CustomAssets: pallet_assets::, LiquidityMining: zrml_liquidity_mining, - MarketAssets: pallet_assets::, MarketCommons: zrml_market_commons, PredictionMarkets: zrml_prediction_markets, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, @@ -208,130 +194,12 @@ impl crate::Config for Runtime { type WeightInfo = zrml_neo_swaps::weights::WeightInfo; } -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - impl pallet_insecure_randomness_collective_flip::Config for Runtime {} impl zrml_prediction_markets::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; type ApproveOrigin = EnsureSignedBy; - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; #[cfg(feature = "parachain")] type AssetRegistry = AssetRegistry; type Authorized = Authorized; @@ -362,7 +230,6 @@ impl zrml_prediction_markets::Config for Runtime { type MinCategories = MinCategories; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; - type OnStateTransition = (); type OracleBond = OracleBond; type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; @@ -439,7 +306,7 @@ impl frame_system::Config for Runtime { type Hashing = BlakeTwo256; type Lookup = IdentityLookup; type Nonce = u64; - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); type RuntimeOrigin = RuntimeOrigin; @@ -452,7 +319,7 @@ impl frame_system::Config for Runtime { impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = (); } @@ -460,7 +327,7 @@ impl orml_currencies::Config for Runtime { impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = DustRemovalWhitelist; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -557,9 +424,9 @@ cfg_if::cfg_if!( >; pub struct NoopAssetProcessor {} - impl AssetProcessor for NoopAssetProcessor { - fn pre_register(id: Option, asset_metadata: AssetMetadata) - -> Result<(XcmAsset, AssetMetadata), DispatchError> { + impl AssetProcessor for NoopAssetProcessor { + fn pre_register(id: Option, asset_metadata: AssetMetadata) + -> Result<(CurrencyId, AssetMetadata), DispatchError> { Ok((id.unwrap(), asset_metadata)) } } @@ -567,7 +434,7 @@ cfg_if::cfg_if!( impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CustomMetadata = CustomMetadata; - type AssetId = XcmAsset; + type AssetId = CurrencyId; type AuthorityOrigin = EnsureRoot; type AssetProcessor = NoopAssetProcessor; type Balance = Balance; @@ -602,7 +469,7 @@ impl ExtBuilder { #[cfg(feature = "parachain")] { orml_tokens::GenesisConfig:: { - balances: vec![(ALICE, FOREIGN_ASSET.try_into().unwrap(), 100_000_000_001 * _1)], + balances: vec![(ALICE, FOREIGN_ASSET, 100_000_000_001 * _1)], } .assimilate_storage(&mut t) .unwrap(); @@ -612,7 +479,7 @@ impl ExtBuilder { }; orml_asset_registry::GenesisConfig:: { assets: vec![( - FOREIGN_ASSET.try_into().unwrap(), + FOREIGN_ASSET, AssetMetadata { decimals: 18, name: "MKL".as_bytes().to_vec().try_into().unwrap(), @@ -623,7 +490,7 @@ impl ExtBuilder { } .encode(), )], - last_asset_id: FOREIGN_ASSET.try_into().unwrap(), + last_asset_id: FOREIGN_ASSET, } .assimilate_storage(&mut t) .unwrap(); diff --git a/zrml/neo-swaps/src/tests/buy.rs b/zrml/neo-swaps/src/tests/buy.rs index 9ecd703bb..4267fca21 100644 --- a/zrml/neo-swaps/src/tests/buy.rs +++ b/zrml/neo-swaps/src/tests/buy.rs @@ -16,6 +16,8 @@ // along with Zeitgeist. If not, see . use super::*; +#[cfg(not(feature = "parachain"))] +use sp_runtime::{DispatchError, TokenError}; use test_case::test_case; // Example taken from diff --git a/zrml/neo-swaps/src/tests/deploy_pool.rs b/zrml/neo-swaps/src/tests/deploy_pool.rs index df7b8202a..8d7f4fdec 100644 --- a/zrml/neo-swaps/src/tests/deploy_pool.rs +++ b/zrml/neo-swaps/src/tests/deploy_pool.rs @@ -90,7 +90,6 @@ fn deploy_pool_works_with_scalar_marktes() { ExtBuilder::default().build().execute_with(|| { let alice_before = AssetManager::free_balance(BASE_ASSET, &ALICE); let amount = _100; - let expected_amounts = [amount, 101755598229]; let spot_prices = vec![_1_6, _5_6 + 1]; let swap_fee = CENT; let market_id: MarketId = 0; @@ -98,6 +97,14 @@ fn deploy_pool_works_with_scalar_marktes() { Asset::ScalarOutcome(market_id, ScalarPosition::Long), Asset::ScalarOutcome(market_id, ScalarPosition::Short), ]; + // Deploy some funds in the pool account to ensure that rogue funds don't screw up price + // calculatings. + let rogue_funds = _100; + assert_ok!(AssetManager::deposit( + assets[0], + &Pallet::::pool_account_id(&market_id), + rogue_funds + )); let _ = create_market_and_deploy_pool( ALICE, BASE_ASSET, @@ -107,31 +114,8 @@ fn deploy_pool_works_with_scalar_marktes() { swap_fee, ); let pool = Pools::::get(market_id).unwrap(); - let mut reserves = BTreeMap::new(); - reserves.insert(assets[0], expected_amounts[0]); - reserves.insert(assets[1], expected_amounts[1]); - System::assert_last_event( - Event::PoolDeployed { - who: ALICE, - market_id, - account_id: pool.account_id, - reserves, - collateral: pool.collateral, - liquidity_parameter: pool.liquidity_parameter, - pool_shares_amount: amount, - swap_fee, - } - .into(), - ); - // Deploy some funds in the pool account to ensure that rogue funds don't screw up price - // calculatings. - let rogue_funds = _100; - assert_ok!(AssetManager::deposit( - assets[0], - &Pallet::::pool_account_id(&market_id), - rogue_funds - )); let expected_liquidity = 558110626551; + let expected_amounts = [amount, 101755598229]; let buffer = AssetManager::minimum_balance(pool.collateral); assert_eq!(pool.assets(), assets); assert_approx!(pool.liquidity_parameter, expected_liquidity, 1_000); @@ -161,6 +145,22 @@ fn deploy_pool_works_with_scalar_marktes() { let price_sum = pool.assets().iter().map(|&a| pool.calculate_spot_price(a).unwrap()).sum::(); assert_eq!(price_sum, _1); + let mut reserves = BTreeMap::new(); + reserves.insert(assets[0], expected_amounts[0]); + reserves.insert(assets[1], expected_amounts[1]); + System::assert_last_event( + Event::PoolDeployed { + who: ALICE, + market_id, + account_id: pool.account_id, + reserves, + collateral: pool.collateral, + liquidity_parameter: pool.liquidity_parameter, + pool_shares_amount: amount, + swap_fee, + } + .into(), + ); }); } @@ -429,7 +429,7 @@ fn deploy_pool_fails_on_insufficient_funds() { vec![_3_4, _1_4], CENT ), - DispatchError::Arithmetic(ArithmeticError::Underflow) + orml_tokens::Error::::BalanceTooLow ); }); } diff --git a/zrml/neo-swaps/src/tests/join.rs b/zrml/neo-swaps/src/tests/join.rs index 866c0b8e3..1e6bc0183 100644 --- a/zrml/neo-swaps/src/tests/join.rs +++ b/zrml/neo-swaps/src/tests/join.rs @@ -208,7 +208,6 @@ fn join_fails_on_insufficient_funds() { vec![_1_2, _1_2], CENT, ); - assert_noop!( NeoSwaps::join( RuntimeOrigin::signed(ALICE), @@ -216,7 +215,7 @@ fn join_fails_on_insufficient_funds() { _100, vec![u128::MAX, u128::MAX] ), - DispatchError::Arithmetic(ArithmeticError::Underflow) + orml_tokens::Error::::BalanceTooLow ); }); } diff --git a/zrml/neo-swaps/src/tests/mod.rs b/zrml/neo-swaps/src/tests/mod.rs index dc172faaf..8dc8eb78d 100644 --- a/zrml/neo-swaps/src/tests/mod.rs +++ b/zrml/neo-swaps/src/tests/mod.rs @@ -29,25 +29,25 @@ mod withdraw_fees; use crate::{consts::*, mock::*, traits::*, *}; use frame_support::{assert_noop, assert_ok}; use orml_traits::MultiCurrency; -use sp_runtime::{ArithmeticError, DispatchError, Perbill, TokenError}; +use sp_runtime::Perbill; use zeitgeist_primitives::{ constants::{base_multiples::*, CENT}, math::fixed::{FixedDiv, FixedMul}, types::{ - AccountIdTest, Asset, Assets, Deadlines, MarketCreation, MarketId, MarketPeriod, - MarketStatus, MarketType, MultiHash, ScalarPosition, ScoringRule, + AccountIdTest, Asset, Deadlines, MarketCreation, MarketId, MarketPeriod, MarketStatus, + MarketType, MultiHash, ScalarPosition, ScoringRule, }, }; use zrml_market_commons::{MarketCommonsPalletApi, Markets}; #[cfg(not(feature = "parachain"))] -const BASE_ASSET: Assets = Assets::Ztg; +const BASE_ASSET: Asset = Asset::Ztg; #[cfg(feature = "parachain")] -const BASE_ASSET: Assets = FOREIGN_ASSET; +const BASE_ASSET: Asset = FOREIGN_ASSET; fn create_market( creator: AccountIdTest, - base_asset: Assets, + base_asset: Asset, market_type: MarketType, scoring_rule: ScoringRule, ) -> MarketId { @@ -56,7 +56,7 @@ fn create_market( metadata[1] = 0x30; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(creator), - base_asset.try_into().unwrap(), + base_asset, Perbill::zero(), EVE, MarketPeriod::Block(0..2), @@ -76,7 +76,7 @@ fn create_market( fn create_market_and_deploy_pool( creator: AccountIdOf, - base_asset: Assets, + base_asset: Asset, market_type: MarketType, amount: BalanceOf, spot_prices: Vec>, @@ -104,7 +104,7 @@ fn deposit_complete_set( amount: BalanceOf, ) { let market = MarketCommons::market(&market_id).unwrap(); - assert_ok!(AssetManager::deposit(market.base_asset.into(), &account, amount)); + assert_ok!(AssetManager::deposit(market.base_asset, &account, amount)); assert_ok!(::CompleteSetOperations::buy_complete_set( RuntimeOrigin::signed(account), market_id, diff --git a/zrml/neo-swaps/src/tests/sell.rs b/zrml/neo-swaps/src/tests/sell.rs index b4a688b33..5c1b9dd60 100644 --- a/zrml/neo-swaps/src/tests/sell.rs +++ b/zrml/neo-swaps/src/tests/sell.rs @@ -352,7 +352,7 @@ fn sell_fails_on_insufficient_funds() { amount_in, u128::MAX, ), - DispatchError::Token(TokenError::FundsUnavailable), + orml_tokens::Error::::BalanceTooLow, ); }); } diff --git a/zrml/neo-swaps/src/types/max_assets.rs b/zrml/neo-swaps/src/types/max_assets.rs index 3a2595770..823147c7b 100644 --- a/zrml/neo-swaps/src/types/max_assets.rs +++ b/zrml/neo-swaps/src/types/max_assets.rs @@ -1,4 +1,4 @@ -// Copyright 2024 Forecasting Technologies LTD. +// Copyright 2023-2024 Forecasting Technologies LTD. // // This file is part of Zeitgeist. // diff --git a/zrml/neo-swaps/src/weights.rs b/zrml/neo-swaps/src/weights.rs index c03925ef2..97c8413c4 100644 --- a/zrml/neo-swaps/src/weights.rs +++ b/zrml/neo-swaps/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_neo_swaps //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -62,196 +62,182 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_neo_swaps (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:129 w:129) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:128 w:128) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:129 w:129) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:128 w:128) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn buy(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2779 + n * (195 ±0)` - // Estimated: `160807 + n * (7816 ±0)` - // Minimum execution time: 428_751 nanoseconds. - Weight::from_parts(509_169_321, 160807) - // Standard Error: 101_370 - .saturating_add(Weight::from_parts(22_542_800, 0).saturating_mul(n.into())) + // Measured: `1283 + n * (163 ±0)` + // Estimated: `148211 + n * (2598 ±0)` + // Minimum execution time: 585_102 nanoseconds. + Weight::from_parts(580_456_240, 148211) + // Standard Error: 101_265 + .saturating_add(Weight::from_parts(27_359_358, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7816).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(n.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:129 w:129) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:128 w:128) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:129 w:129) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:3 w:3) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:128 w:128) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn sell(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2941 + n * (195 ±0)` - // Estimated: `160807 + n * (7816 ±0)` - // Minimum execution time: 326_051 nanoseconds. - Weight::from_parts(337_913_110, 160807) - // Standard Error: 142_558 - .saturating_add(Weight::from_parts(32_232_119, 0).saturating_mul(n.into())) + // Measured: `1414 + n * (163 ±0)` + // Estimated: `148211 + n * (2598 ±0)` + // Minimum execution time: 468_861 nanoseconds. + Weight::from_parts(414_696_511, 148211) + // Standard Error: 95_356 + .saturating_add(Weight::from_parts(38_051_885, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(5)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7816).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(n.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:256 w:256) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:256 w:256) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn join_in_place(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `140908 + n * (261 ±0)` - // Estimated: `152995 + n * (7896 ±0)` - // Minimum execution time: 589_352 nanoseconds. - Weight::from_parts(858_161_799, 152995) - // Standard Error: 235_846 - .saturating_add(Weight::from_parts(44_925_839, 0).saturating_mul(n.into())) + // Measured: `139311 + n * (197 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 595_362 nanoseconds. + Weight::from_parts(440_618_005, 148211) + // Standard Error: 273_538 + .saturating_add(Weight::from_parts(47_025_592, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:256 w:256) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:256 w:256) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn join_reassigned(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `140704 + n * (261 ±0)` - // Estimated: `152995 + n * (7896 ±0)` - // Minimum execution time: 740_802 nanoseconds. - Weight::from_parts(942_736_689, 152995) - // Standard Error: 226_172 - .saturating_add(Weight::from_parts(45_144_685, 0).saturating_mul(n.into())) + // Measured: `139107 + n * (197 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 622_432 nanoseconds. + Weight::from_parts(473_601_406, 148211) + // Standard Error: 298_264 + .saturating_add(Weight::from_parts(47_682_394, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:256 w:256) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:256 w:256) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn join_leaf(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `140709 + n * (261 ±0)` - // Estimated: `152995 + n * (7896 ±0)` - // Minimum execution time: 1_033_663 nanoseconds. - Weight::from_parts(1_158_427_570, 152995) - // Standard Error: 290_258 - .saturating_add(Weight::from_parts(46_834_860, 0).saturating_mul(n.into())) + // Measured: `138611 + n * (197 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 582_132 nanoseconds. + Weight::from_parts(546_913_207, 148211) + // Standard Error: 277_416 + .saturating_add(Weight::from_parts(46_923_622, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:256 w:256) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:256 w:256) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn exit(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `140805 + n * (261 ±0)` - // Estimated: `152995 + n * (7896 ±0)` - // Minimum execution time: 1_059_013 nanoseconds. - Weight::from_parts(1_416_870_118, 152995) - // Standard Error: 282_123 - .saturating_add(Weight::from_parts(43_510_065, 0).saturating_mul(n.into())) + // Measured: `139208 + n * (197 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 623_772 nanoseconds. + Weight::from_parts(514_882_760, 148211) + // Standard Error: 282_318 + .saturating_add(Weight::from_parts(45_943_935, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) } - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn withdraw_fees() -> Weight { // Proof Size summary in bytes: - // Measured: `139317` - // Estimated: `152435` - // Minimum execution time: 908_593 nanoseconds. - Weight::from_parts(1_062_393_000, 152435) + // Measured: `137756` + // Estimated: `148211` + // Minimum execution time: 595_752 nanoseconds. + Weight::from_parts(668_402_000, 148211) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:128 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:256 w:256) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:256 w:256) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `n` is `[2, 128]`. fn deploy_pool(n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2155 + n * (113 ±0)` - // Estimated: `152995 + n * (7896 ±0)` - // Minimum execution time: 219_501 nanoseconds. - Weight::from_parts(170_782_454, 152995) - // Standard Error: 183_769 - .saturating_add(Weight::from_parts(45_425_037, 0).saturating_mul(n.into())) + // Measured: `611 + n * (81 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 205_881 nanoseconds. + Weight::from_parts(123_014_022, 148211) + // Standard Error: 170_483 + .saturating_add(Weight::from_parts(55_591_115, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) } } diff --git a/zrml/orderbook/Cargo.toml b/zrml/orderbook/Cargo.toml index acb38ba4c..3c6855bb5 100644 --- a/zrml/orderbook/Cargo.toml +++ b/zrml/orderbook/Cargo.toml @@ -8,43 +8,37 @@ orml-traits = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } sp-runtime = { workspace = true } -zeitgeist-macros = { workspace = true } zeitgeist-primitives = { workspace = true } # Mock env_logger = { workspace = true, optional = true } orml-currencies = { workspace = true, optional = true } orml-tokens = { workspace = true, optional = true } -pallet-assets = { workspace = true, optional = true } pallet-balances = { workspace = true, optional = true } pallet-timestamp = { workspace = true, optional = true } sp-io = { workspace = true, optional = true } -zrml-asset-router = { workspace = true, optional = true } zrml-market-commons = { workspace = true, optional = true } [dev-dependencies] test-case = { workspace = true } -zrml-orderbook = { workspace = true, features = ["default", "mock"] } +zrml-orderbook = { workspace = true, features = ["mock", "default"] } [features] default = ["std"] mock = [ - "env_logger/default", - "orml-currencies/default", "orml-tokens/default", - "pallet-assets/default", "pallet-balances/default", "pallet-timestamp/default", + "zrml-market-commons/default", + "orml-currencies/default", "sp-io/default", "zeitgeist-primitives/mock", - "zrml-asset-router", - "zrml-market-commons/default", + "env_logger/default", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-assets?/runtime-benchmarks", ] std = [ "frame-benchmarking?/std", diff --git a/zrml/orderbook/src/benchmarks.rs b/zrml/orderbook/src/benchmarks.rs index 920a3f2e3..039f70420 100644 --- a/zrml/orderbook/src/benchmarks.rs +++ b/zrml/orderbook/src/benchmarks.rs @@ -37,7 +37,7 @@ fn generate_funded_account( asset: AssetOf, ) -> Result { let acc = if let Some(s) = seed { account("AssetHolder", 0, s) } else { whitelisted_caller() }; - T::AssetManager::deposit(asset, &acc, BASE.saturating_mul(1_000).saturated_into())?; + T::AssetManager::deposit(asset, &acc, BASE.saturating_mul(1_100).saturated_into())?; Ok(acc) } @@ -48,7 +48,7 @@ fn order_common_parameters( &'static str, > { let market = market_mock::(); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let acc = generate_funded_account::(seed, maker_asset)?; let maker_amount: BalanceOf = BASE.saturating_mul(1_000).saturated_into(); let taker_amount: BalanceOf = BASE.saturating_mul(1_000).saturated_into(); @@ -84,7 +84,7 @@ benchmarks! { let taker_asset = Asset::CategoricalOutcome::>(market_id, 0); let (_, _, order_id) = place_default_order::(Some(0), taker_asset)?; let caller = generate_funded_account::(None, taker_asset)?; - let maker_asset = T::MarketCommons::market(&market_id).unwrap().base_asset.into(); + let maker_asset = T::MarketCommons::market(&market_id).unwrap().base_asset; let caller = generate_funded_account::(None, maker_asset)?; }: fill_order(RawOrigin::Signed(caller), order_id, None) diff --git a/zrml/orderbook/src/lib.rs b/zrml/orderbook/src/lib.rs index 29e3a3094..0a4512d52 100644 --- a/zrml/orderbook/src/lib.rs +++ b/zrml/orderbook/src/lib.rs @@ -22,7 +22,7 @@ extern crate alloc; use crate::weights::*; -use alloc::vec; +use alloc::{vec, vec::Vec}; use core::marker::PhantomData; use frame_support::{ ensure, @@ -36,18 +36,18 @@ use frame_system::{ ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}, }; -use orml_traits::{ - BalanceStatus, MultiCurrency, MultiReservableCurrency, NamedMultiReservableCurrency, -}; +use orml_traits::{BalanceStatus, MultiCurrency, NamedMultiReservableCurrency}; pub use pallet::*; -use sp_runtime::traits::{AccountIdConversion, Get, Zero}; -use zeitgeist_macros::unreachable_non_terminating; +use sp_runtime::traits::{Get, Zero}; use zeitgeist_primitives::{ hybrid_router_api_types::{ApiError, ExternalFee, OrderbookSoftFail, OrderbookTrade}, - math::checked_ops_res::{CheckedAddRes, CheckedSubRes}, + math::{ + checked_ops_res::{CheckedAddRes, CheckedSubRes}, + fixed::FixedMulDiv, + }, orderbook::{Order, OrderId}, traits::{DistributeFees, HybridRouterOrderbookApi, MarketCommonsPalletApi}, - types::{Asset, BaseAsset, MarketStatus, ScoringRule}, + types::{Asset, Market, MarketStatus, MarketType, ScalarPosition, ScoringRule}, }; #[cfg(feature = "runtime-benchmarks")] @@ -100,16 +100,19 @@ mod pallet { /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub(crate) type AccountIdOf = ::AccountId; pub(crate) type AssetOf = Asset>; pub(crate) type BalanceOf = <::AssetManager as MultiCurrency< ::AccountId, >>::Balance; + pub(crate) type ExternalFeeOf = ExternalFee, BalanceOf>; pub(crate) type MarketIdOf = <::MarketCommons as MarketCommonsPalletApi>::MarketId; - pub(crate) type AccountIdOf = ::AccountId; + pub(crate) type MarketOf = + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; + pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; pub(crate) type OrderOf = Order, BalanceOf, MarketIdOf>; pub(crate) type OrderbookTradeOf = OrderbookTrade, BalanceOf>; - pub(crate) type ExternalFeeOf = ExternalFee, BalanceOf>; #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -245,6 +248,30 @@ mod pallet { } impl Pallet { + /// The reserve ID of the order book pallet. + #[inline] + pub fn reserve_id() -> [u8; 8] { + T::PalletId::get().0 + } + + pub fn outcome_assets(market_id: MarketIdOf, market: &MarketOf) -> Vec> { + match market.market_type { + MarketType::Categorical(categories) => { + let mut assets = Vec::new(); + for i in 0..categories { + assets.push(Asset::CategoricalOutcome(market_id, i)); + } + assets + } + MarketType::Scalar(_) => { + vec![ + Asset::ScalarOutcome(market_id, ScalarPosition::Long), + Asset::ScalarOutcome(market_id, ScalarPosition::Short), + ] + } + } + } + /// Reduces the reserved maker and requested taker amount /// by the amount the maker and taker actually filled. fn decrease_order_amounts( @@ -257,16 +284,20 @@ mod pallet { Ok(()) } - /// The order account for a specific order id. - #[inline] - pub(crate) fn order_account(order_id: OrderId) -> AccountIdOf { - T::PalletId::get().into_sub_account_truncating(order_id) - } - - /// The reserve ID of the order book pallet. - #[inline] - pub(crate) fn reserve_id() -> [u8; 8] { - T::PalletId::get().0 + /// Calculates the amount that the taker is going to get from the maker's amount. + fn get_taker_fill( + order_data: &OrderOf, + maker_fill: BalanceOf, + ) -> Result, DispatchError> { + // the maker_full_fill is the maximum amount of what the maker wants to have + let maker_full_fill = order_data.taker_amount; + // the taker_full_fill is the maximum amount of what the taker wants to have + let taker_full_fill = order_data.maker_amount; + // rounding down: the taker will always get a little bit less than what they asked for. + // This ensures that the reserve of the maker + // is always enough to repatriate successfully! + // `maker_full_fill` is ensured to be never zero in `ensure_ratio_quotient_valid` + maker_fill.bmul_bdiv_floor(taker_full_fill, maker_full_fill) } fn ensure_ratio_quotient_valid(order_data: &OrderOf) -> DispatchResult { @@ -285,29 +316,24 @@ mod pallet { let maker = &order_data.maker; ensure!(who == *maker, Error::::NotOrderCreator); - let order_account = Self::order_account(order_id); - let asset = order_data.maker_asset; - let amount = order_data.maker_amount; - - if !T::AssetManager::reserved_balance_named(&Self::reserve_id(), asset, maker).is_zero() - { - let missing = - T::AssetManager::unreserve_named(&Self::reserve_id(), asset, maker, amount); - - unreachable_non_terminating!( - missing.is_zero(), - LOG_TARGET, - "Could not unreserve all of the amount. reserve_id: {:?}, asset: {:?} who: \ - {:?}, amount: {:?}, missing: {:?}", - Self::reserve_id(), - asset, - maker, - amount, - missing, - ); - } else { - T::AssetManager::transfer(asset, &order_account, maker, amount)?; - } + + let missing = T::AssetManager::unreserve_named( + &Self::reserve_id(), + order_data.maker_asset, + maker, + order_data.maker_amount, + ); + + debug_assert!( + missing.is_zero(), + "Could not unreserve all of the amount. reserve_id: {:?}, asset: {:?} who: {:?}, \ + amount: {:?}, missing: {:?}", + Self::reserve_id(), + order_data.maker_asset, + maker, + order_data.maker_amount, + missing, + ); >::remove(order_id); @@ -325,30 +351,25 @@ mod pallet { /// Returns the adjusted maker fill and the external fee. fn charge_external_fees( order_data: &OrderOf, - base_asset: BaseAsset, + base_asset: AssetOf, maker_fill: BalanceOf, taker: &AccountIdOf, taker_fill: BalanceOf, ) -> Result<(BalanceOf, ExternalFeeOf), DispatchError> { - let maker_asset_is_base_asset = order_data.maker_asset == base_asset.into(); - let base_asset_fill = if maker_asset_is_base_asset { + let maker_asset_is_base = order_data.maker_asset == base_asset; + let base_asset_fill = if maker_asset_is_base { taker_fill } else { - unreachable_non_terminating!( - order_data.taker_asset == base_asset.into(), - LOG_TARGET, - "Order {:?} does not contain a base asset", - order_data - ); + debug_assert!(order_data.taker_asset == base_asset); maker_fill }; let fee_amount = T::ExternalFees::distribute( order_data.market_id, - base_asset.into(), + base_asset, taker, base_asset_fill, ); - if maker_asset_is_base_asset { + if maker_asset_is_base { Ok((maker_fill, ExternalFeeOf:: { account: taker.clone(), amount: fee_amount })) } else { Ok(( @@ -366,12 +387,6 @@ mod pallet { ) -> Result, DispatchError> { let mut order_data = >::get(order_id).ok_or(Error::::OrderDoesNotExist)?; let market = T::MarketCommons::market(&order_data.market_id)?; - unreachable_non_terminating!( - market.scoring_rule == ScoringRule::AmmCdaHybrid, - LOG_TARGET, - "The call to place_order already ensured the scoring rule amm and order book \ - hybrid.", - ); ensure!(market.status == MarketStatus::Active, Error::::MarketIsNotActive); let base_asset = market.base_asset; @@ -386,41 +401,18 @@ mod pallet { let maker_asset = order_data.maker_asset; let taker_asset = order_data.taker_asset; - // the reserve of the maker should always be enough - // to repatriate successfully, e.g. taker gets a little bit less - // it should always ensure that the maker's request (maker_fill) is fully filled - let (taker_fill, _maker_fill) = - order_data.taker_and_maker_fill_from_taker_amount(maker_fill)?; - let order_account = Self::order_account(order_id); - - if !T::AssetManager::reserved_balance_named(&Self::reserve_id(), maker_asset, &maker) - .is_zero() - { - let missing = T::AssetManager::repatriate_reserved_named( - &Self::reserve_id(), - maker_asset, - &maker, - &taker, - taker_fill, - BalanceStatus::Free, - )?; - - unreachable_non_terminating!( - missing.is_zero(), - LOG_TARGET, - "Could not repatriate all of the amount. reserve_id: {:?}, asset: {:?} who: \ - {:?}, amount: {:?}, missing: {:?}", - Self::reserve_id(), - maker_asset, - maker, - taker_fill, - missing, - ); - } else { - T::AssetManager::transfer(maker_asset, &order_account, &taker, taker_fill)?; - } + let taker_fill = Self::get_taker_fill(&order_data, maker_fill)?; // if base asset: fund the full amount, but charge base asset fees from taker later + T::AssetManager::repatriate_reserved_named( + &Self::reserve_id(), + maker_asset, + &maker, + &taker, + taker_fill, + BalanceStatus::Free, + )?; + // always charge fees from the base asset and not the outcome asset let (maybe_adjusted_maker_fill, external_fee) = Self::charge_external_fees( &order_data, @@ -481,19 +473,17 @@ mod pallet { market.scoring_rule == ScoringRule::AmmCdaHybrid, Error::::InvalidScoringRule ); + let base_asset = market.base_asset; - let outcome_asset = if maker_asset == base_asset.into() { + let outcome_asset = if maker_asset == base_asset { taker_asset } else { - ensure!(taker_asset == base_asset.into(), Error::::MarketBaseAssetNotPresent); + ensure!(taker_asset == base_asset, Error::::MarketBaseAssetNotPresent); maker_asset }; - - let outcome_asset_converted = - outcome_asset.try_into().map_err(|_| Error::::InvalidOutcomeAsset)?; let market_assets = market.outcome_assets(); market_assets - .binary_search(&outcome_asset_converted) + .binary_search(&outcome_asset) .map_err(|_| Error::::InvalidOutcomeAsset)?; ensure!( @@ -509,18 +499,7 @@ mod pallet { let next_order_id = order_id.checked_add_res(&1)?; // fees are always only charged in the base asset in fill_order - // reserving the maker_asset is preferred (depends on other pallet support) - if T::AssetManager::can_reserve(maker_asset, &who, maker_amount) { - T::AssetManager::reserve_named( - &Self::reserve_id(), - maker_asset, - &who, - maker_amount, - )?; - } else { - let order_account = Self::order_account(order_id); - T::AssetManager::transfer(maker_asset, &who, &order_account, maker_amount)?; - } + T::AssetManager::reserve_named(&Self::reserve_id(), maker_asset, &who, maker_amount)?; let order = Order { market_id, diff --git a/zrml/orderbook/src/mock.rs b/zrml/orderbook/src/mock.rs index 70b670927..d33f1bff7 100644 --- a/zrml/orderbook/src/mock.rs +++ b/zrml/orderbook/src/mock.rs @@ -18,34 +18,24 @@ #![cfg(feature = "mock")] -use crate as orderbook; +use crate as zrml_orderbook; use crate::{AssetOf, BalanceOf, MarketIdOf}; use core::marker::PhantomData; -use frame_support::{ - construct_runtime, - pallet_prelude::Get, - parameter_types, - traits::{AsEnsureOriginWithArg, Everything}, -}; -use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSigned}; +use frame_support::{construct_runtime, pallet_prelude::Get, parameter_types, traits::Everything}; +use frame_system::mocking::MockBlock; use orml_traits::MultiCurrency; -use parity_scale_codec::Compact; use sp_runtime::{ - traits::{BlakeTwo256, ConstU32, IdentityLookup, Zero}, + traits::{BlakeTwo256, IdentityLookup, Zero}, BuildStorage, Perbill, SaturatedConversion, }; use zeitgeist_primitives::{ constants::mock::{ - AssetsAccountDeposit, AssetsApprovalDeposit, AssetsDeposit, AssetsMetadataDepositBase, - AssetsMetadataDepositPerByte, AssetsStringLimit, BlockHashCount, DestroyAccountWeight, - DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, ExistentialDeposits, - GetNativeCurrencyId, MaxLocks, MaxReserves, MinimumPeriod, OrderbookPalletId, BASE, CENT, + BlockHashCount, ExistentialDeposit, ExistentialDeposits, GetNativeCurrencyId, MaxLocks, + MaxReserves, MinimumPeriod, OrderbookPalletId, BASE, CENT, }, traits::DistributeFees, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, CampaignAsset, - CampaignAssetId, Currencies, CustomAsset, CustomAssetId, Hash, MarketAsset, MarketId, - Moment, + AccountIdTest, Amount, Balance, BasicCurrencyAdapter, CurrencyId, Hash, MarketId, Moment, }, }; @@ -59,10 +49,6 @@ parameter_types! { pub const FeeAccount: AccountIdTest = MARKET_CREATOR; } -type CustomAssetsInstance = pallet_assets::Instance1; -type CampaignAssetsInstance = pallet_assets::Instance2; -type MarketAssetsInstance = pallet_assets::Instance3; - pub fn fee_percentage() -> Perbill { Perbill::from_rational(EXTERNAL_FEES, BASE) } @@ -102,17 +88,13 @@ where construct_runtime!( pub enum Runtime { - AssetManager: orml_currencies, - AssetRouter: zrml_asset_router, Balances: pallet_balances, - CampaignAssets: pallet_assets::, - CustomAssets: pallet_assets::, - MarketAssets: pallet_assets::, MarketCommons: zrml_market_commons, - Orderbook: orderbook, + Orderbook: zrml_orderbook, System: frame_system, - Timestamp: pallet_timestamp, Tokens: orml_tokens, + AssetManager: orml_currencies, + Timestamp: pallet_timestamp, } ); @@ -122,7 +104,7 @@ impl crate::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; type PalletId = OrderbookPalletId; - type WeightInfo = orderbook::weights::WeightInfo; + type WeightInfo = zrml_orderbook::weights::WeightInfo; } impl frame_system::Config for Runtime { @@ -153,7 +135,7 @@ impl frame_system::Config for Runtime { impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = (); } @@ -161,7 +143,7 @@ impl orml_currencies::Config for Runtime { impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -172,106 +154,6 @@ impl orml_tokens::Config for Runtime { type WeightInfo = (); } -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; @@ -295,22 +177,6 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } -impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - impl zrml_market_commons::Config for Runtime { type Balance = Balance; type MarketId = MarketId; diff --git a/zrml/orderbook/src/tests.rs b/zrml/orderbook/src/tests.rs index 5061b7c16..d37b70c77 100644 --- a/zrml/orderbook/src/tests.rs +++ b/zrml/orderbook/src/tests.rs @@ -17,15 +17,16 @@ // along with Zeitgeist. If not, see . use crate::{mock::*, utils::market_mock, Error, Event, Order, Orders}; -use frame_support::{assert_noop, assert_ok, traits::fungibles::Create}; +use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error as AError; use orml_traits::{MultiCurrency, MultiReservableCurrency}; -use sp_runtime::{DispatchError, Perbill, Perquintill, TokenError}; +use pallet_balances::Error as BError; +use sp_runtime::{Perbill, Perquintill}; use test_case::test_case; use zeitgeist_primitives::{ constants::BASE, hybrid_router_api_types::ExternalFee, - types::{Asset, BaseAsset, MarketStatus, MarketType, ScalarPosition, ScoringRule}, + types::{Asset, MarketStatus, MarketType, ScalarPosition, ScoringRule}, }; use zrml_market_commons::{Error as MError, MarketCommonsPalletApi, Markets}; @@ -44,7 +45,7 @@ fn place_order_fails_with_wrong_scoring_rule(scoring_rule: ScoringRule) { Orderbook::place_order( RuntimeOrigin::signed(ALICE), market_id, - market.base_asset.into(), + market.base_asset, 10 * BASE, Asset::CategoricalOutcome(market_id, 2), 25 * BASE, @@ -73,7 +74,7 @@ fn place_order_fails_if_market_status_not_active(status: MarketStatus) { Orderbook::place_order( RuntimeOrigin::signed(ALICE), market_id, - market.base_asset.into(), + market.base_asset, 10 * BASE, Asset::CategoricalOutcome(0, 2), 25 * BASE, @@ -94,7 +95,7 @@ fn fill_order_fails_if_market_status_not_active(status: MarketStatus) { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -127,7 +128,7 @@ fn fill_order_fails_if_amount_too_high_for_order() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -156,7 +157,7 @@ fn fill_order_fails_if_amount_is_below_minimum_balance() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -189,7 +190,7 @@ fn place_order_fails_if_amount_is_below_minimum_balance() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); assert_noop!( @@ -225,7 +226,7 @@ fn fill_order_fails_if_balance_too_low() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -258,7 +259,7 @@ fn fill_order_fails_if_partial_fill_near_full_fill_not_allowed() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -273,7 +274,7 @@ fn fill_order_fails_if_partial_fill_near_full_fill_not_allowed() { taker_amount, )); - assert_ok!(AssetManager::deposit(taker_asset, &BOB, taker_amount)); + AssetManager::deposit(taker_asset, &BOB, taker_amount).unwrap(); assert_noop!( Orderbook::fill_order( @@ -293,7 +294,7 @@ fn fill_order_removes_order() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -323,7 +324,7 @@ fn fill_order_partially_fills_order() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let order_id = 0u128; @@ -369,37 +370,6 @@ fn fill_order_partially_fills_order() { }); } -#[test] -fn fill_order_does_work_with_reserves_after_funding_order_account() { - ExtBuilder::default().build().execute_with(|| { - let market_id = 0u128; - let mut market = market_mock::(); - market.base_asset = BaseAsset::Ztg; - Markets::::insert(market_id, market.clone()); - - let maker_asset = market.base_asset.into(); - let taker_asset = Asset::CategoricalOutcome(0, 2); - let taker_amount = 10 * BASE; - let maker_amount = 250 * BASE; - - assert_ok!(AssetManager::deposit(maker_asset, &ALICE, maker_amount)); - assert_ok!(AssetManager::deposit(taker_asset, &BOB, taker_amount)); - assert_ok!(Orderbook::place_order( - RuntimeOrigin::signed(ALICE), - market_id, - maker_asset, - maker_amount, - taker_asset, - taker_amount, - )); - - let reserved_funds = AssetManager::reserved_balance(maker_asset, &ALICE); - assert_eq!(reserved_funds, maker_amount); - assert_ok!(AssetManager::deposit(maker_asset, &Orderbook::order_account(0), BASE)); - assert_ok!(Orderbook::fill_order(RuntimeOrigin::signed(BOB), 0, None)); - }); -} - #[test] fn place_order_fails_if_market_base_asset_not_present() { ExtBuilder::default().build().execute_with(|| { @@ -433,7 +403,7 @@ fn place_order_fails_if_invalid_outcome_asset() { assert_eq!(market.market_type, MarketType::Categorical(64u16)); let maker_asset = Asset::ScalarOutcome(0, ScalarPosition::Long); - let taker_asset = market.base_asset.into(); + let taker_asset = market.base_asset; assert_noop!( Orderbook::place_order( @@ -479,7 +449,7 @@ fn place_order_fails_if_maker_has_insufficient_funds() { Markets::::insert(market_id, market.clone()); let maker = ALICE; - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let alice_free_maker_amount = AssetManager::free_balance(maker_asset, &maker); @@ -494,7 +464,7 @@ fn place_order_fails_if_maker_has_insufficient_funds() { taker_asset, 25 * BASE, ), - DispatchError::Token(TokenError::FundsUnavailable) + BError::::InsufficientBalance, ); }); } @@ -515,16 +485,11 @@ fn it_fails_order_does_not_exist() { }); } -#[test_case(true; "with_reservable_asset")] -#[test_case(false; "with_non_reservable_asset")] -fn it_places_orders(reservable_maker_asset: bool) { +#[test] +fn it_places_orders() { ExtBuilder::default().build().execute_with(|| { let market_id = 0u128; - let mut market = market_mock::(); - if !reservable_maker_asset { - market.base_asset = BaseAsset::CampaignAsset(0); - assert_ok!(AssetRouter::create(market.base_asset.into(), ALICE, true, 1)); - } + let market = market_mock::(); Markets::::insert(market_id, market.clone()); let taker_asset_0 = Asset::CategoricalOutcome(0, 2); @@ -532,24 +497,18 @@ fn it_places_orders(reservable_maker_asset: bool) { let taker_amount = 10 * BASE; let maker_amount = 250 * BASE; - assert_ok!(AssetManager::deposit(market.base_asset.into(), &ALICE, maker_amount)); + assert_ok!(AssetManager::deposit(market.base_asset, &ALICE, maker_amount)); assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(ALICE), market_id, - market.base_asset.into(), + market.base_asset, maker_amount, taker_asset_0, taker_amount, )); - let reserved_funds = if reservable_maker_asset { - AssetManager::reserved_balance(market.base_asset.into(), &ALICE) - } else { - let order_account = Orderbook::order_account(0); - assert_eq!(AssetManager::free_balance(market.base_asset.into(), &BOB), 0); - AssetManager::free_balance(market.base_asset.into(), &order_account) - }; + let reserved_funds = AssetManager::reserved_balance(market.base_asset, &ALICE); assert_eq!(reserved_funds, maker_amount); let maker_asset = Asset::CategoricalOutcome(0, 1); @@ -563,7 +522,7 @@ fn it_places_orders(reservable_maker_asset: bool) { market_id, maker_asset, maker_amount, - market.base_asset.into(), + market.base_asset, taker_amount, )); @@ -580,7 +539,7 @@ fn it_fills_order_fully_maker_outcome_asset() { Markets::::insert(market_id, market.clone()); let maker_asset = Asset::CategoricalOutcome(0, 1); - let taker_asset = market.base_asset.into(); + let taker_asset = market.base_asset; let maker_amount = 100 * BASE; let taker_amount = 500 * BASE; @@ -633,33 +592,26 @@ fn it_fills_order_fully_maker_outcome_asset() { assert_eq!(alice_maker_asset_free, INITIAL_BALANCE); assert_eq!(alice_taker_asset_free, maker_amount); - let bob_taker_asset_free = AssetManager::free_balance(market.base_asset.into(), &BOB); + let bob_taker_asset_free = AssetManager::free_balance(market.base_asset, &BOB); let bob_maker_asset_free = AssetManager::free_balance(maker_asset, &BOB); assert_eq!(bob_taker_asset_free, INITIAL_BALANCE + taker_amount - taker_fees); assert_eq!(bob_maker_asset_free, 0); }); } -#[test_case(true; "with_reservable_asset")] -#[test_case(false; "with_non_reservable_asset")] -fn it_fills_order_fully_maker_base_asset(reservable_maker_asset: bool) { +#[test] +fn it_fills_order_fully_maker_base_asset() { ExtBuilder::default().build().execute_with(|| { let market_id = 0u128; - let mut market = market_mock::(); - let taker_amount = 10 * BASE; - let maker_amount = 50 * BASE; - - if !reservable_maker_asset { - market.base_asset = BaseAsset::CampaignAsset(0); - assert_ok!(AssetRouter::create(market.base_asset.into(), BOB, true, 1)); - assert_ok!(AssetManager::deposit(market.base_asset.into(), &BOB, maker_amount)); - } - + let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 1); + let taker_amount = 10 * BASE; + let maker_amount = 50 * BASE; + assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(BOB), market_id, @@ -669,14 +621,8 @@ fn it_fills_order_fully_maker_base_asset(reservable_maker_asset: bool) { taker_amount, )); - let reserved_funds = if reservable_maker_asset { - AssetManager::reserved_balance(market.base_asset.into(), &BOB) - } else { - let order_account = Orderbook::order_account(0); - assert_eq!(AssetManager::free_balance(market.base_asset.into(), &BOB), 0); - AssetManager::free_balance(market.base_asset.into(), &order_account) - }; - assert_eq!(reserved_funds, maker_amount); + let reserved_bob = AssetManager::reserved_balance(maker_asset, &BOB); + assert_eq!(reserved_bob, maker_amount); let order_id = 0u128; assert_ok!(AssetManager::deposit(taker_asset, &ALICE, taker_amount)); @@ -706,48 +652,31 @@ fn it_fills_order_fully_maker_base_asset(reservable_maker_asset: bool) { let alice_taker_asset_free = AssetManager::free_balance(taker_asset, &ALICE); let maker_fees = calculate_fee::(maker_amount); let maker_amount_minus_fees = maker_amount - maker_fees; - - if reservable_maker_asset { - assert_eq!(alice_maker_asset_free, INITIAL_BALANCE + maker_amount_minus_fees); - } else { - assert_eq!(alice_maker_asset_free, maker_amount_minus_fees); - } - + assert_eq!(alice_maker_asset_free, INITIAL_BALANCE + maker_amount_minus_fees); assert_eq!(alice_taker_asset_free, 0); let bob_bal = AssetManager::free_balance(maker_asset, &BOB); let bob_shares = AssetManager::free_balance(taker_asset, &BOB); - - if reservable_maker_asset { - assert_eq!(bob_bal, INITIAL_BALANCE - maker_amount); - } else { - assert_eq!(bob_bal, 0); - } - + assert_eq!(bob_bal, INITIAL_BALANCE - maker_amount); assert_eq!(bob_shares, taker_amount); }); } -#[test_case(true; "with_reservable_asset")] -#[test_case(false; "with_non_reservable_asset")] -fn it_fills_order_partially_maker_base_asset(reservable_maker_asset: bool) { +#[test] +fn it_fills_order_partially_maker_base_asset() { ExtBuilder::default().build().execute_with(|| { let market_id = 0u128; - let mut market = market_mock::(); - let maker_amount = 500 * BASE; - let taker_amount = 100 * BASE; - - if !reservable_maker_asset { - market.base_asset = BaseAsset::CampaignAsset(0); - assert_ok!(AssetRouter::create(market.base_asset.into(), BOB, true, 1)); - } - + let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 1); + let maker_amount = 500 * BASE; + let taker_amount = 100 * BASE; + assert_ok!(AssetManager::deposit(maker_asset, &BOB, maker_amount)); + assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(BOB), market_id, @@ -757,14 +686,8 @@ fn it_fills_order_partially_maker_base_asset(reservable_maker_asset: bool) { taker_amount, )); - let reserved_funds = if reservable_maker_asset { - AssetManager::reserved_balance(market.base_asset.into(), &BOB) - } else { - let order_account = Orderbook::order_account(0); - assert_eq!(AssetManager::free_balance(market.base_asset.into(), &BOB), 0); - AssetManager::free_balance(market.base_asset.into(), &order_account) - }; - assert_eq!(reserved_funds, maker_amount); + let reserved_bob = AssetManager::reserved_balance(maker_asset, &BOB); + assert_eq!(reserved_bob, maker_amount); let order_id = 0u128; assert_ok!(AssetManager::deposit(taker_asset, &ALICE, taker_amount)); @@ -824,34 +747,16 @@ fn it_fills_order_partially_maker_base_asset(reservable_maker_asset: bool) { Perquintill::from_rational(alice_portion, taker_amount).mul_floor(maker_amount); let filled_maker_amount_minus_fees = filled_maker_amount - calculate_fee::(filled_maker_amount); - - if reservable_maker_asset { - assert_eq!(alice_maker_asset_free, INITIAL_BALANCE + filled_maker_amount_minus_fees); - } else { - assert_eq!(alice_maker_asset_free, filled_maker_amount_minus_fees); - } - + assert_eq!(alice_maker_asset_free, INITIAL_BALANCE + filled_maker_amount_minus_fees); assert_eq!(alice_taker_asset_free, alice_taker_asset_free_left); let bob_maker_asset_free = AssetManager::free_balance(maker_asset, &BOB); let bob_taker_asset_free = AssetManager::free_balance(taker_asset, &BOB); - - if reservable_maker_asset { - assert_eq!(bob_maker_asset_free, INITIAL_BALANCE); - } else { - assert_eq!(bob_maker_asset_free, 0); - } - + assert_eq!(bob_maker_asset_free, INITIAL_BALANCE); assert_eq!(bob_taker_asset_free, alice_portion); - if reservable_maker_asset { - let reserved_bob = AssetManager::reserved_balance(maker_asset, &BOB); - assert_eq!(reserved_bob, unfilled_maker_amount); - } else { - let order_account = Orderbook::order_account(0); - let remaining = AssetManager::free_balance(maker_asset, &order_account); - assert_eq!(remaining, unfilled_maker_amount); - } + let reserved_bob = AssetManager::reserved_balance(maker_asset, &BOB); + assert_eq!(reserved_bob, unfilled_maker_amount); }); } @@ -863,7 +768,7 @@ fn it_fills_order_partially_maker_outcome_asset() { Markets::::insert(market_id, market.clone()); let maker_asset = Asset::CategoricalOutcome(0, 1); - let taker_asset = market.base_asset.into(); + let taker_asset = market.base_asset; let maker_amount = 100 * BASE; let taker_amount = 500 * BASE; @@ -885,7 +790,7 @@ fn it_fills_order_partially_maker_outcome_asset() { let order_id = 0u128; let market_creator_free_balance_before = - AssetManager::free_balance(market.base_asset.into(), &MARKET_CREATOR); + AssetManager::free_balance(market.base_asset, &MARKET_CREATOR); // instead of buying 500 of the base asset, Alice buys 70 shares let alice_portion = 70 * BASE; @@ -893,7 +798,7 @@ fn it_fills_order_partially_maker_outcome_asset() { assert_ok!(Orderbook::fill_order(RuntimeOrigin::signed(ALICE), order_id, portion,)); let market_creator_free_balance_after = - AssetManager::free_balance(market.base_asset.into(), &MARKET_CREATOR); + AssetManager::free_balance(market.base_asset, &MARKET_CREATOR); let external_fee_amount = calculate_fee::(70 * BASE); assert_eq!( market_creator_free_balance_after - market_creator_free_balance_before, @@ -955,25 +860,19 @@ fn it_fills_order_partially_maker_outcome_asset() { }); } -#[test_case(true; "with_reservable_asset")] -#[test_case(false; "with_non_reservable_asset")] -fn it_removes_order(reservable_maker_asset: bool) { +#[test] +fn it_removes_order() { ExtBuilder::default().build().execute_with(|| { let market_id = 0u128; - let mut market = market_mock::(); - let taker_amount = 25 * BASE; - let maker_amount = 10 * BASE; - - if !reservable_maker_asset { - market.base_asset = BaseAsset::CampaignAsset(0); - assert_ok!(AssetRouter::create(market.base_asset.into(), ALICE, true, 1)); - assert_ok!(AssetManager::deposit(market.base_asset.into(), &ALICE, maker_amount)); - } - + let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); + let taker_amount = 25 * BASE; + let maker_amount = 10 * BASE; + assert_ok!(Orderbook::place_order( RuntimeOrigin::signed(ALICE), market_id, @@ -983,13 +882,7 @@ fn it_removes_order(reservable_maker_asset: bool) { taker_amount, )); - let reserved_funds = if reservable_maker_asset { - AssetManager::reserved_balance(market.base_asset.into(), &ALICE) - } else { - let order_account = Orderbook::order_account(0); - assert_eq!(AssetManager::free_balance(market.base_asset.into(), &BOB), 0); - AssetManager::free_balance(market.base_asset.into(), &order_account) - }; + let reserved_funds = AssetManager::reserved_balance(market.base_asset, &ALICE); assert_eq!(reserved_funds, maker_amount); let order_id = 0u128; @@ -999,16 +892,12 @@ fn it_removes_order(reservable_maker_asset: bool) { Order { market_id, maker: ALICE, maker_asset, maker_amount, taker_asset, taker_amount } ); + let reserved_funds = AssetManager::reserved_balance(market.base_asset, &ALICE); + assert_eq!(reserved_funds, maker_amount); + assert_ok!(Orderbook::remove_order(RuntimeOrigin::signed(ALICE), order_id)); - let reserved_funds = if reservable_maker_asset { - AssetManager::reserved_balance(market.base_asset.into(), &ALICE) - } else { - let order_account = Orderbook::order_account(0); - let alice_balance = AssetManager::free_balance(market.base_asset.into(), &ALICE); - assert_eq!(alice_balance, maker_amount); - AssetManager::free_balance(market.base_asset.into(), &order_account) - }; + let reserved_funds = AssetManager::reserved_balance(market.base_asset, &ALICE); assert_eq!(reserved_funds, 0); assert!(Orders::::get(order_id).is_none()); @@ -1022,7 +911,7 @@ fn remove_order_emits_event() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let taker_amount = 25 * BASE; @@ -1052,7 +941,7 @@ fn remove_order_fails_if_not_order_creator() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let taker_amount = 25 * BASE; @@ -1076,39 +965,6 @@ fn remove_order_fails_if_not_order_creator() { }); } -#[test] -fn remove_order_does_work_with_reserves_after_funding_order_account() { - ExtBuilder::default().build().execute_with(|| { - let market_id = 0u128; - let mut market = market_mock::(); - market.base_asset = BaseAsset::Ztg; - Markets::::insert(market_id, market.clone()); - - let maker_asset = market.base_asset.into(); - let taker_asset = Asset::CategoricalOutcome(0, 2); - let taker_amount = 10 * BASE; - let maker_amount = 250 * BASE; - - assert_ok!(AssetManager::deposit(maker_asset, &ALICE, maker_amount)); - assert_ok!(AssetManager::deposit(taker_asset, &BOB, taker_amount)); - assert_ok!(Orderbook::place_order( - RuntimeOrigin::signed(ALICE), - market_id, - maker_asset, - maker_amount, - taker_asset, - taker_amount, - )); - - let mut reserved_funds = AssetManager::reserved_balance(maker_asset, &ALICE); - assert_eq!(reserved_funds, maker_amount); - assert_ok!(AssetManager::deposit(maker_asset, &Orderbook::order_account(0), BASE)); - assert_ok!(Orderbook::remove_order(RuntimeOrigin::signed(ALICE), 0)); - reserved_funds = AssetManager::reserved_balance(maker_asset, &ALICE); - assert_eq!(reserved_funds, 0); - }); -} - #[test] fn place_order_emits_event() { ExtBuilder::default().build().execute_with(|| { @@ -1116,7 +972,7 @@ fn place_order_emits_event() { let market = market_mock::(); Markets::::insert(market_id, market.clone()); - let maker_asset = market.base_asset.into(); + let maker_asset = market.base_asset; let taker_asset = Asset::CategoricalOutcome(0, 2); let taker_amount = 25 * BASE; diff --git a/zrml/orderbook/src/utils.rs b/zrml/orderbook/src/utils.rs index e378d7aac..8cf9b37ce 100644 --- a/zrml/orderbook/src/utils.rs +++ b/zrml/orderbook/src/utils.rs @@ -21,18 +21,15 @@ use crate::*; use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::AccountIdConversion; use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, Market, MarketCreation, MarketDisputeMechanism, MarketPeriod, - MarketStatus, MarketType, ScoringRule, + Asset, Deadlines, Market, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, + MarketType, ScoringRule, }; -type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; - type MarketOf = Market< ::AccountId, BalanceOf, BlockNumberFor, MomentOf, - BaseAsset, MarketIdOf, >; @@ -42,7 +39,7 @@ where { Market { market_id: Default::default(), - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: T::PalletId::get().into_account_truncating(), diff --git a/zrml/orderbook/src/weights.rs b/zrml/orderbook/src/weights.rs index be82826e6..a7d39b51d 100644 --- a/zrml/orderbook/src/weights.rs +++ b/zrml/orderbook/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_orderbook //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -57,57 +57,53 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_orderbook (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: Orderbook Orders (r:1 w:1) - /// Proof: Orderbook Orders (max_values: None, max_size: Some(142), added: 2617, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `Orderbook::Orders` (r:1 w:1) + /// Proof: `Orderbook::Orders` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn remove_order() -> Weight { // Proof Size summary in bytes: - // Measured: `283` - // Estimated: `6341` - // Minimum execution time: 45_181 nanoseconds. - Weight::from_parts(55_640_000, 6341) + // Measured: `251` + // Estimated: `4714` + // Minimum execution time: 62_030 nanoseconds. + Weight::from_parts(71_670_000, 4714) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Orderbook Orders (r:1 w:1) - /// Proof: Orderbook Orders (max_values: None, max_size: Some(142), added: 2617, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:1 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) + /// Storage: `Orderbook::Orders` (r:1 w:1) + /// Proof: `Orderbook::Orders` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) fn fill_order() -> Weight { // Proof Size summary in bytes: - // Measured: `1206` - // Estimated: `20011` - // Minimum execution time: 130_771 nanoseconds. - Weight::from_parts(159_941_000, 20011) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `970` + // Estimated: `6186` + // Minimum execution time: 150_301 nanoseconds. + Weight::from_parts(155_560_000, 6186) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:1 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Orderbook NextOrderId (r:1 w:1) - /// Proof: Orderbook NextOrderId (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: Orderbook Orders (r:0 w:1) - /// Proof: Orderbook Orders (max_values: None, max_size: Some(142), added: 2617, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::NextOrderId` (r:1 w:1) + /// Proof: `Orderbook::NextOrderId` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `Orderbook::Orders` (r:0 w:1) + /// Proof: `Orderbook::Orders` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `MaxEncodedLen`) fn place_order() -> Weight { // Proof Size summary in bytes: - // Measured: `426` - // Estimated: `10102` - // Minimum execution time: 71_630 nanoseconds. - Weight::from_parts(72_740_000, 10102) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `318` + // Estimated: `4714` + // Minimum execution time: 70_520 nanoseconds. + Weight::from_parts(72_130_000, 4714) + .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/zrml/parimutuel/Cargo.toml b/zrml/parimutuel/Cargo.toml index eab897897..bdc45496f 100644 --- a/zrml/parimutuel/Cargo.toml +++ b/zrml/parimutuel/Cargo.toml @@ -4,11 +4,9 @@ frame-support = { workspace = true } frame-system = { workspace = true } log = { workspace = true } orml-traits = { workspace = true } -pallet-assets = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } sp-runtime = { workspace = true } -zeitgeist-macros = { workspace = true } zeitgeist-primitives = { workspace = true } zrml-market-commons = { workspace = true } @@ -20,7 +18,6 @@ pallet-balances = { workspace = true, features = ["default", "insecure_zero_ed"] pallet-timestamp = { workspace = true, features = ["default"] } sp-io = { workspace = true, features = ["default"] } zeitgeist-primitives = { workspace = true, features = ["mock", "default"] } -zrml-asset-router = { workspace = true, features = ["default"] } test-case = { workspace = true } @@ -30,14 +27,12 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", ] std = [ "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "orml-traits/std", - "pallet-assets/std", "parity-scale-codec/std", "sp-runtime/std", "zeitgeist-primitives/std", diff --git a/zrml/parimutuel/src/benchmarking.rs b/zrml/parimutuel/src/benchmarking.rs index 097d7ebc6..40b2c1290 100644 --- a/zrml/parimutuel/src/benchmarking.rs +++ b/zrml/parimutuel/src/benchmarking.rs @@ -22,18 +22,13 @@ #![cfg(feature = "runtime-benchmarks")] use crate::{utils::*, Pallet as Parimutuel, *}; +use alloc::vec; use frame_benchmarking::v2::*; -use frame_support::{ - assert_ok, - traits::{fungibles::Inspect, Get}, -}; +use frame_support::{assert_ok, traits::Get}; use frame_system::RawOrigin; use orml_traits::MultiCurrency; use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; -use zeitgeist_primitives::{ - traits::MarketTransitionApi, - types::{MarketStatus, MarketType, OutcomeReport}, -}; +use zeitgeist_primitives::types::{Asset, MarketStatus, MarketType, OutcomeReport}; use zrml_market_commons::MarketCommonsPalletApi; fn setup_market(market_type: MarketType) -> MarketIdOf { @@ -48,19 +43,19 @@ fn setup_market(market_type: MarketType) -> MarketIdOf { fn buy_asset( market_id: MarketIdOf, - asset: ParimutuelShareOf, + asset: AssetOf, buyer: &T::AccountId, amount: BalanceOf, ) { let market = T::MarketCommons::market(&market_id).unwrap(); - T::AssetManager::deposit(market.base_asset.into(), buyer, amount).unwrap(); + T::AssetManager::deposit(market.base_asset, buyer, amount).unwrap(); Parimutuel::::buy(RawOrigin::Signed(buyer.clone()).into(), asset, amount).unwrap(); } #[benchmarks] mod benchmarks { use super::*; - use alloc::vec; + // use alloc::vec; #[benchmark] fn buy() { @@ -69,10 +64,10 @@ mod benchmarks { let market_id = setup_market::(MarketType::Categorical(64u16)); let amount = T::MinBetSize::get().saturating_mul(10u128.saturated_into::>()); - let asset = ParimutuelShareOf::::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let market = T::MarketCommons::market(&market_id).unwrap(); - T::AssetManager::deposit(market.base_asset.into(), &buyer, amount).unwrap(); + T::AssetManager::deposit(market.base_asset, &buyer, amount).unwrap(); #[extrinsic_call] buy(RawOrigin::Signed(buyer), asset, amount); @@ -82,16 +77,15 @@ mod benchmarks { fn claim_rewards() { // max category index is worst case let market_id = setup_market::(MarketType::Categorical(64u16)); - assert_ok!(Parimutuel::::on_activation(&market_id).result); let winner = whitelisted_caller(); - let winner_asset = ParimutuelShareOf::::Share(market_id, 0u16); + let winner_asset = Asset::ParimutuelShare(market_id, 0u16); let winner_amount = T::MinBetSize::get().saturating_mul(20u128.saturated_into::>()); buy_asset::(market_id, winner_asset, &winner, winner_amount); let loser = whitelisted_caller(); - let loser_asset = ParimutuelShareOf::::Share(market_id, 1u16); + let loser_asset = Asset::ParimutuelShare(market_id, 1u16); let loser_amount = T::MinBetSize::get().saturating_mul(10u128.saturated_into::>()); buy_asset::(market_id, loser_asset, &loser, loser_amount); @@ -110,18 +104,17 @@ mod benchmarks { fn claim_refunds() { // max category index is worst case let market_id = setup_market::(MarketType::Categorical(64u16)); - assert_ok!(Parimutuel::::on_activation(&market_id).result); let loser_0 = whitelisted_caller(); let loser_0_index = 0u16; - let loser_0_asset = ParimutuelShareOf::::Share(market_id, loser_0_index); + let loser_0_asset = Asset::ParimutuelShare(market_id, loser_0_index); let loser_0_amount = T::MinBetSize::get().saturating_mul(20u128.saturated_into::>()); buy_asset::(market_id, loser_0_asset, &loser_0, loser_0_amount); let loser_1 = whitelisted_caller(); let loser_1_index = 1u16; - let loser_1_asset = ParimutuelShareOf::::Share(market_id, loser_1_index); + let loser_1_asset = Asset::ParimutuelShare(market_id, loser_1_index); let loser_1_amount = T::MinBetSize::get().saturating_mul(10u128.saturated_into::>()); buy_asset::(market_id, loser_1_asset, &loser_1, loser_1_amount); @@ -132,8 +125,8 @@ mod benchmarks { let resolved_outcome = OutcomeReport::Categorical(resolved_index); assert_ne!(resolved_index, loser_0_index); assert_ne!(resolved_index, loser_1_index); - let resolved_asset = ParimutuelShareOf::::Share(market_id, resolved_index); - let resolved_issuance_asset = T::AssetManager::total_issuance(resolved_asset.into()); + let resolved_asset = Asset::ParimutuelShare(market_id, resolved_index); + let resolved_issuance_asset = T::AssetManager::total_issuance(resolved_asset); assert!(resolved_issuance_asset.is_zero()); market.resolved_outcome = Some(resolved_outcome); Ok(()) @@ -143,55 +136,6 @@ mod benchmarks { claim_refunds(RawOrigin::Signed(loser_0), loser_0_asset); } - #[benchmark] - fn on_activation() { - let market_id = setup_market::(MarketType::Categorical(64u16)); - - #[block] - { - Parimutuel::::on_activation(&market_id); - } - - for asset_idx in 0..64 { - let asset = ParimutuelShareOf::::Share(Zero::zero(), asset_idx).into(); - assert!(T::AssetCreator::asset_exists(asset)); - } - } - - #[benchmark] - fn on_resolution() { - let market_id = setup_market::(MarketType::Categorical(64u16)); - assert_ok!(Parimutuel::::on_activation(&market_id).result); - - for asset_idx in 0..64 { - let asset = ParimutuelShareOf::::Share(Zero::zero(), asset_idx).into(); - assert!(T::AssetCreator::asset_exists(asset)); - } - - assert_ok!(T::MarketCommons::mutate_market(&market_id, |market| { - market.status = MarketStatus::Resolved; - let resolved_outcome = OutcomeReport::Categorical(0u16); - market.resolved_outcome = Some(resolved_outcome); - Ok(()) - })); - - #[block] - { - Parimutuel::::on_resolution(&market_id); - } - - #[cfg(test)] - { - use frame_support::{pallet_prelude::Weight, traits::OnIdle}; - - crate::mock::AssetRouter::on_idle(Zero::zero(), Weight::MAX); - for asset_idx in 0..64 { - let asset = ParimutuelShareOf::::Share(Zero::zero(), asset_idx).into(); - assert!(!T::AssetCreator::asset_exists(asset)); - } - } - } - impl_benchmark_test_suite!( Parimutuel, crate::mock::ExtBuilder::default().build(), diff --git a/zrml/parimutuel/src/lib.rs b/zrml/parimutuel/src/lib.rs index 824a92f35..b1855e061 100644 --- a/zrml/parimutuel/src/lib.rs +++ b/zrml/parimutuel/src/lib.rs @@ -31,16 +31,12 @@ pub use pallet::*; #[frame_support::pallet] mod pallet { use crate::weights::WeightInfoZeitgeist; - use alloc::collections::BTreeMap; use core::marker::PhantomData; use frame_support::{ ensure, pallet_prelude::{Decode, Encode, TypeInfo}, require_transactional, - traits::{ - fungibles::{Create, Inspect}, - Get, IsType, StorageVersion, - }, + traits::{Get, IsType, StorageVersion}, PalletId, }; use frame_system::{ @@ -48,36 +44,25 @@ mod pallet { pallet_prelude::{BlockNumberFor, OriginFor}, }; use orml_traits::MultiCurrency; - use pallet_assets::ManagedDestroy; use sp_runtime::{ traits::{AccountIdConversion, CheckedSub, Zero}, DispatchError, DispatchResult, RuntimeDebug, }; - use zeitgeist_macros::unreachable_non_terminating; use zeitgeist_primitives::{ math::fixed::FixedMulDiv, - traits::{DistributeFees, MarketTransitionApi}, - types::{ - Asset, BaseAsset, Market, MarketAssetClass, MarketStatus, MarketType, OutcomeReport, - ParimutuelAssetClass, ResultWithWeightInfo, ScoringRule, - }, + traits::DistributeFees, + types::{Asset, Market, MarketStatus, MarketType, OutcomeReport, ScoringRule}, }; use zrml_market_commons::MarketCommonsPalletApi; #[pallet::config] pub trait Config: frame_system::Config { - /// The module handling the creation of market assets. - type AssetCreator: Create, Balance = BalanceOf>; - /// The api to handle different asset classes. type AssetManager: MultiCurrency>; - /// The module handling the destruction of market assets. - type AssetDestroyer: ManagedDestroy, Balance = BalanceOf>; - /// The way how fees are taken from the market base asset. type ExternalFees: DistributeFees< - Asset = AssetOf, + Asset = Asset>, AccountId = AccountIdOf, Balance = BalanceOf, MarketId = MarketIdOf, @@ -108,21 +93,14 @@ mod pallet { const LOG_TARGET: &str = "runtime::zrml-parimutuel"; pub(crate) type AssetOf = Asset>; - pub(crate) type ParimutuelShareOf = ParimutuelAssetClass>; pub(crate) type AccountIdOf = ::AccountId; pub(crate) type BalanceOf = <::AssetManager as MultiCurrency>>::Balance; pub(crate) type MarketIdOf = <::MarketCommons as MarketCommonsPalletApi>::MarketId; pub(crate) type MomentOf = <::MarketCommons as MarketCommonsPalletApi>::Moment; - pub(crate) type MarketOf = Market< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAsset, - MarketIdOf, - >; + pub(crate) type MarketOf = + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -164,51 +142,38 @@ mod pallet { /// There was no buyer for the winning outcome or all winners already claimed their rewards. /// Use the `refund` extrinsic to get the initial bet back, /// in case there was no buyer for the winning outcome. - #[codec(index = 0)] NoRewardShareOutstanding, /// The market is not active. - #[codec(index = 1)] MarketIsNotActive, /// The specified amount is below the minimum bet size. - #[codec(index = 2)] AmountBelowMinimumBetSize, + /// The specified asset is not a parimutuel share. + NotParimutuelOutcome, /// The specified asset was not found in the market assets. - #[codec(index = 4)] InvalidOutcomeAsset, /// The scoring rule is not parimutuel. - #[codec(index = 5)] InvalidScoringRule, /// The specified amount can not be transferred. - #[codec(index = 6)] InsufficientBalance, /// The market is not resolved yet. - #[codec(index = 7)] MarketIsNotResolvedYet, /// An unexpected error occured. This should never happen! /// There was an internal coding mistake. - #[codec(index = 8)] Unexpected, /// There is no resolved outcome present for the market. - #[codec(index = 9)] NoResolvedOutcome, /// The refund is not allowed. - #[codec(index = 10)] RefundNotAllowed, /// There is no balance to refund. - #[codec(index = 11)] RefundableBalanceIsZero, /// There is no reward, because there are no winning shares. - #[codec(index = 12)] NoWinningShares, /// Only categorical markets are allowed for parimutuels. - #[codec(index = 13)] NotCategorical, /// There is no reward to distribute. - #[codec(index = 14)] NoRewardToDistribute, /// Action cannot be completed because an unexpected error has occurred. This should be /// reported to protocol maintainers. - #[codec(index = 15)] InconsistentState(InconsistentStateError), } @@ -238,7 +203,7 @@ mod pallet { #[frame_support::transactional] pub fn buy( origin: OriginFor, - asset: ParimutuelShareOf, + asset: Asset>, #[pallet::compact] amount: BalanceOf, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -273,10 +238,7 @@ mod pallet { #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::claim_refunds())] #[frame_support::transactional] - pub fn claim_refunds( - origin: OriginFor, - refund_asset: ParimutuelShareOf, - ) -> DispatchResult { + pub fn claim_refunds(origin: OriginFor, refund_asset: AssetOf) -> DispatchResult { let who = ensure_signed(origin)?; Self::do_claim_refunds(who, refund_asset)?; @@ -331,36 +293,29 @@ mod pallet { Ok(()) } - pub fn market_assets_contains( - market: &MarketOf, - asset: &ParimutuelShareOf, - ) -> DispatchResult { - let index = match asset { - ParimutuelShareOf::::Share(_, idx) => *idx, - }; - - match market.market_type { - MarketType::Categorical(categories) => { - ensure!(index < categories, Error::::InvalidOutcomeAsset); - Ok(()) + pub fn market_assets_contains(market: &MarketOf, asset: &AssetOf) -> DispatchResult { + if let Asset::ParimutuelShare(_, i) = asset { + match market.market_type { + MarketType::Categorical(categories) => { + ensure!(*i < categories, Error::::InvalidOutcomeAsset); + return Ok(()); + } + MarketType::Scalar(_) => return Err(Error::::NotCategorical.into()), } - MarketType::Scalar(_) => Err(Error::::NotCategorical.into()), } + Err(Error::::NotParimutuelOutcome.into()) } #[require_transactional] - fn do_buy( - who: T::AccountId, - asset: ParimutuelShareOf, - amount: BalanceOf, - ) -> DispatchResult { + fn do_buy(who: T::AccountId, asset: AssetOf, amount: BalanceOf) -> DispatchResult { let market_id = match asset { - ParimutuelShareOf::::Share(market_id, _) => market_id, + Asset::ParimutuelShare(market_id, _) => market_id, + _ => return Err(Error::::NotParimutuelOutcome.into()), }; let market = T::MarketCommons::market(&market_id)?; let base_asset = market.base_asset; ensure!( - T::AssetManager::ensure_can_withdraw(base_asset.into(), &who, amount).is_ok(), + T::AssetManager::ensure_can_withdraw(base_asset, &who, amount).is_ok(), Error::::InsufficientBalance ); ensure!(market.status == MarketStatus::Active, Error::::MarketIsNotActive); @@ -371,23 +326,23 @@ mod pallet { ); Self::market_assets_contains(&market, &asset)?; - let external_fees = - T::ExternalFees::distribute(market_id, base_asset.into(), &who, amount); + let external_fees = T::ExternalFees::distribute(market_id, base_asset, &who, amount); let amount_minus_fees = amount.checked_sub(&external_fees).ok_or(Error::::Unexpected)?; ensure!( amount_minus_fees >= T::MinBetSize::get(), Error::::AmountBelowMinimumBetSize ); + let pot_account = Self::pot_account(market_id); - T::AssetManager::transfer(base_asset.into(), &who, &pot_account, amount_minus_fees)?; - T::AssetManager::deposit(asset.into(), &who, amount_minus_fees)?; + T::AssetManager::transfer(market.base_asset, &who, &pot_account, amount_minus_fees)?; + T::AssetManager::deposit(asset, &who, amount_minus_fees)?; Self::deposit_event(Event::OutcomeBought { market_id, buyer: who, - asset: asset.into(), + asset, amount_minus_fees, fees: external_fees, }); @@ -443,7 +398,7 @@ mod pallet { } let pot_account = Self::pot_account(market_id); - let pot_total = T::AssetManager::free_balance(market.base_asset.into(), &pot_account); + let pot_total = T::AssetManager::free_balance(market.base_asset, &pot_account); let payoff = pot_total.bmul_bdiv(winning_balance, outcome_total)?; Self::check_values(winning_balance, pot_total, outcome_total, payoff)?; @@ -452,27 +407,10 @@ mod pallet { T::AssetManager::withdraw(winning_asset, &who, withdrawn_asset_balance)?; - let remaining_bal = - T::AssetManager::free_balance(market.base_asset.into(), &pot_account); + let remaining_bal = T::AssetManager::free_balance(market.base_asset, &pot_account); let base_asset_payoff = payoff.min(remaining_bal); - T::AssetManager::transfer( - market.base_asset.into(), - &pot_account, - &who, - base_asset_payoff, - )?; - - if outcome_total == winning_balance { - let destroy_result = T::AssetDestroyer::managed_destroy(winning_asset, None); - unreachable_non_terminating!( - destroy_result.is_ok(), - LOG_TARGET, - "Can't destroy winning outcome asset {:?}: {:?}", - winning_asset, - destroy_result.err() - ); - } + T::AssetManager::transfer(market.base_asset, &pot_account, &who, base_asset_payoff)?; Self::deposit_event(Event::RewardsClaimed { market_id, @@ -486,12 +424,10 @@ mod pallet { } #[require_transactional] - fn do_claim_refunds( - who: T::AccountId, - refund_asset: ParimutuelShareOf, - ) -> DispatchResult { + fn do_claim_refunds(who: T::AccountId, refund_asset: AssetOf) -> DispatchResult { let market_id = match refund_asset { - ParimutuelShareOf::::Share(market_id, _) => market_id, + Asset::ParimutuelShare(market_id, _) => market_id, + _ => return Err(Error::::NotParimutuelOutcome.into()), }; let market = T::MarketCommons::market(&market_id)?; Self::ensure_parimutuel_market_resolved(&market)?; @@ -500,10 +436,9 @@ mod pallet { let outcome_total = T::AssetManager::total_issuance(winning_asset); ensure!(outcome_total == >::zero(), Error::::RefundNotAllowed); - let refund_asset_general: AssetOf = refund_asset.into(); - let refund_balance = T::AssetManager::free_balance(refund_asset_general, &who); + let refund_balance = T::AssetManager::free_balance(refund_asset, &who); ensure!(!refund_balance.is_zero(), Error::::RefundableBalanceIsZero); - if refund_asset_general == winning_asset { + if refund_asset == winning_asset { log::debug!( target: LOG_TARGET, "Since we were checking the total issuance of the winning asset to be zero, if \ @@ -513,10 +448,10 @@ mod pallet { debug_assert!(false); } - T::AssetManager::withdraw(refund_asset_general, &who, refund_balance)?; + T::AssetManager::withdraw(refund_asset, &who, refund_balance)?; let pot_account = Self::pot_account(market_id); - let pot_total = T::AssetManager::free_balance(market.base_asset.into(), &pot_account); + let pot_total = T::AssetManager::free_balance(market.base_asset, &pot_account); if pot_total < refund_balance { log::debug!( target: LOG_TARGET, @@ -526,128 +461,16 @@ mod pallet { } let refund_balance = refund_balance.min(pot_total); - T::AssetManager::transfer( - market.base_asset.into(), - &pot_account, - &who, - refund_balance, - )?; - - if T::AssetCreator::total_issuance(refund_asset_general).is_zero() { - let destroy_result = T::AssetDestroyer::managed_destroy(refund_asset_general, None); - unreachable_non_terminating!( - destroy_result.is_ok(), - LOG_TARGET, - "Can't destroy losing outcome asset {:?}: {:?}", - refund_asset_general, - destroy_result - ); - } + T::AssetManager::transfer(market.base_asset, &pot_account, &who, refund_balance)?; Self::deposit_event(Event::BalanceRefunded { market_id, - asset: refund_asset_general, + asset: refund_asset, refunded_balance: refund_balance, sender: who.clone(), }); Ok(()) } - - fn get_assets_to_destroy( - market: &MarketOf, - filter: F, - ) -> BTreeMap, Option> - where - F: Copy + FnOnce(MarketAssetClass>) -> bool, - { - BTreeMap::, Option>::from_iter( - market - .outcome_assets() - .into_iter() - .filter(|asset| filter(*asset)) - .map(|asset| (AssetOf::::from(asset), None)), - ) - } - } - - impl MarketTransitionApi> for Pallet { - fn on_activation(market_id: &MarketIdOf) -> ResultWithWeightInfo { - let market_result = T::MarketCommons::market(market_id); - - let market = match market_result { - Ok(market) if market.scoring_rule == ScoringRule::Parimutuel => market, - Err(e) => { - return ResultWithWeightInfo::new(Err(e), T::DbWeight::get().reads(1)); - } - _ => { - return ResultWithWeightInfo::new(Ok(()), T::DbWeight::get().reads(1)); - } - }; - - for outcome in market.outcome_assets() { - let admin = Self::pot_account(*market_id); - let is_sufficient = true; - let min_balance = 1u8; - if let Err(e) = T::AssetCreator::create( - outcome.into(), - admin, - is_sufficient, - min_balance.into(), - ) { - return ResultWithWeightInfo::new(Err(e), T::WeightInfo::on_activation()); - } - } - - ResultWithWeightInfo::new(Ok(()), T::WeightInfo::on_activation()) - } - - fn on_resolution(market_id: &MarketIdOf) -> ResultWithWeightInfo { - let market_result = T::MarketCommons::market(market_id); - - let market = match market_result { - Ok(market) if market.scoring_rule == ScoringRule::Parimutuel => market, - Err(e) => { - return ResultWithWeightInfo::new(Err(e), T::DbWeight::get().reads(1)); - } - _ => { - return ResultWithWeightInfo::new(Ok(()), T::DbWeight::get().reads(1)); - } - }; - - let winning_asset_option = market.resolved_outcome_into_asset(); - let winning_asset = if let Some(winning_asset) = winning_asset_option { - winning_asset - } else { - unreachable_non_terminating!( - winning_asset_option.is_some(), - LOG_TARGET, - "Resolved market with id {:?} does not have a resolved outcome", - market_id, - ); - return ResultWithWeightInfo::new(Ok(()), T::DbWeight::get().reads(1)); - }; - - let outcome_total = T::AssetManager::total_issuance(winning_asset.into()); - let assets_to_destroy = if outcome_total.is_zero() { - Self::get_assets_to_destroy(&market, |asset| { - T::AssetCreator::total_issuance(asset.into()).is_zero() - }) - } else { - Self::get_assets_to_destroy(&market, |asset| asset != winning_asset) - }; - - let destroy_result = - T::AssetDestroyer::managed_destroy_multi(assets_to_destroy.clone()); - unreachable_non_terminating!( - destroy_result.is_ok(), - LOG_TARGET, - "Can't destroy losing outcome assets {:?}: {:?}", - assets_to_destroy, - destroy_result - ); - - ResultWithWeightInfo::new(Ok(()), T::WeightInfo::on_resolution()) - } } } diff --git a/zrml/parimutuel/src/mock.rs b/zrml/parimutuel/src/mock.rs index 44403f38b..756f0cd38 100644 --- a/zrml/parimutuel/src/mock.rs +++ b/zrml/parimutuel/src/mock.rs @@ -23,31 +23,21 @@ use crate as zrml_parimutuel; use crate::{AssetOf, BalanceOf, MarketIdOf}; use alloc::{vec, vec::Vec}; use core::marker::PhantomData; -use frame_support::{ - construct_runtime, - pallet_prelude::{ConstU32, Get}, - parameter_types, - traits::{AsEnsureOriginWithArg, Everything}, -}; -use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSigned}; +use frame_support::{construct_runtime, pallet_prelude::Get, parameter_types, traits::Everything}; +use frame_system::mocking::MockBlock; use orml_traits::MultiCurrency; -use parity_scale_codec::Compact; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, SaturatedConversion, }; use zeitgeist_primitives::{ constants::mock::{ - AssetsAccountDeposit, AssetsApprovalDeposit, AssetsDeposit, AssetsMetadataDepositBase, - AssetsMetadataDepositPerByte, AssetsStringLimit, BlockHashCount, DestroyAccountWeight, - DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposits, GetNativeCurrencyId, - MaxLocks, MaxReserves, MinBetSize, MinimumPeriod, ParimutuelPalletId, BASE, CENT, + BlockHashCount, ExistentialDeposits, GetNativeCurrencyId, MaxLocks, MaxReserves, + MinBetSize, MinimumPeriod, ParimutuelPalletId, BASE, CENT, }, traits::DistributeFees, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, CampaignAsset, - CampaignAssetId, Currencies, CustomAsset, CustomAssetId, Hash, MarketAsset, MarketId, - Moment, + AccountIdTest, Amount, Balance, BasicCurrencyAdapter, CurrencyId, Hash, MarketId, Moment, }, }; @@ -100,18 +90,10 @@ where } } -type CustomAssetsInstance = pallet_assets::Instance1; -type CampaignAssetsInstance = pallet_assets::Instance2; -type MarketAssetsInstance = pallet_assets::Instance3; - construct_runtime!( pub enum Runtime { AssetManager: orml_currencies, - AssetRouter: zrml_asset_router, Balances: pallet_balances, - CampaignAssets: pallet_assets::, - CustomAssets: pallet_assets::, - MarketAssets: pallet_assets::, MarketCommons: zrml_market_commons, Parimutuel: zrml_parimutuel, System: frame_system, @@ -121,12 +103,10 @@ construct_runtime!( ); impl crate::Config for Runtime { - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; - type AssetManager = AssetManager; type ExternalFees = ExternalFees; type RuntimeEvent = RuntimeEvent; type MarketCommons = MarketCommons; + type AssetManager = AssetManager; type MinBetSize = MinBetSize; type PalletId = ParimutuelPalletId; type WeightInfo = crate::weights::WeightInfo; @@ -158,106 +138,6 @@ impl frame_system::Config for Runtime { type OnSetCode = (); } -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - impl pallet_balances::Config for Runtime { type AccountStore = System; type Balance = Balance; @@ -274,9 +154,22 @@ impl pallet_balances::Config for Runtime { type WeightInfo = (); } +impl zrml_market_commons::Config for Runtime { + type Balance = Balance; + type MarketId = MarketId; + type Timestamp = Timestamp; +} + +impl pallet_timestamp::Config for Runtime { + type MinimumPeriod = MinimumPeriod; + type Moment = Moment; + type OnTimestampSet = (); + type WeightInfo = (); +} + impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = (); } @@ -284,7 +177,7 @@ impl orml_currencies::Config for Runtime { impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -295,35 +188,6 @@ impl orml_tokens::Config for Runtime { type WeightInfo = (); } -impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - -impl zrml_market_commons::Config for Runtime { - type Balance = Balance; - type MarketId = MarketId; - type Timestamp = Timestamp; -} - -impl pallet_timestamp::Config for Runtime { - type MinimumPeriod = MinimumPeriod; - type Moment = Moment; - type OnTimestampSet = (); - type WeightInfo = (); -} - pub struct ExtBuilder { balances: Vec<(AccountIdTest, Balance)>, } diff --git a/zrml/parimutuel/src/tests/buy.rs b/zrml/parimutuel/src/tests/buy.rs index 782767b8c..fcee01f23 100644 --- a/zrml/parimutuel/src/tests/buy.rs +++ b/zrml/parimutuel/src/tests/buy.rs @@ -15,12 +15,14 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . +#![cfg(test)] + use crate::{mock::*, utils::*, *}; use core::ops::RangeInclusive; use frame_support::{assert_noop, assert_ok}; use orml_traits::MultiCurrency; use test_case::test_case; -use zeitgeist_primitives::types::{MarketStatus, MarketType, ParimutuelAsset, ScoringRule}; +use zeitgeist_primitives::types::{Asset, MarketStatus, MarketType, ScoringRule}; use zrml_market_commons::{Error as MError, Markets}; #[test] @@ -31,7 +33,7 @@ fn buy_emits_event() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount)); @@ -40,14 +42,7 @@ fn buy_emits_event() { assert_eq!(amount, amount_minus_fees + fees); System::assert_last_event( - Event::OutcomeBought { - market_id, - buyer: ALICE, - asset: asset.into(), - amount_minus_fees, - fees, - } - .into(), + Event::OutcomeBought { market_id, buyer: ALICE, asset, amount_minus_fees, fees }.into(), ); }); } @@ -62,12 +57,12 @@ fn buy_balances_change_correctly() { let base_asset = market.base_asset; - let free_alice_before = AssetManager::free_balance(base_asset.into(), &ALICE); - let free_creator_before = AssetManager::free_balance(base_asset.into(), &market.creator); + let free_alice_before = AssetManager::free_balance(base_asset, &ALICE); + let free_creator_before = AssetManager::free_balance(base_asset, &market.creator); let free_pot_before = - AssetManager::free_balance(base_asset.into(), &Parimutuel::pot_account(market_id)); + AssetManager::free_balance(base_asset, &Parimutuel::pot_account(market_id)); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount)); @@ -75,23 +70,37 @@ fn buy_balances_change_correctly() { let fees = 1000000000; assert_eq!(amount, amount_minus_fees + fees); + assert_eq!(AssetManager::free_balance(base_asset, &ALICE), free_alice_before - amount); assert_eq!( - AssetManager::free_balance(base_asset.into(), &ALICE), - free_alice_before - amount - ); - assert_eq!( - AssetManager::free_balance(base_asset.into(), &Parimutuel::pot_account(market_id)) + AssetManager::free_balance(base_asset, &Parimutuel::pot_account(market_id)) - free_pot_before, amount_minus_fees ); - assert_eq!(AssetManager::free_balance(asset.into(), &ALICE), amount_minus_fees); + assert_eq!(AssetManager::free_balance(asset, &ALICE), amount_minus_fees); assert_eq!( - AssetManager::free_balance(base_asset.into(), &market.creator) - free_creator_before, + AssetManager::free_balance(base_asset, &market.creator) - free_creator_before, fees ); }); } +#[test] +fn buy_fails_if_asset_not_parimutuel_share() { + ExtBuilder::default().build().execute_with(|| { + let market_id = 0; + let mut market = market_mock::(MARKET_CREATOR); + market.status = MarketStatus::Active; + Markets::::insert(market_id, market.clone()); + + let asset = Asset::CategoricalOutcome(market_id, 0u16); + let amount = ::MinBetSize::get(); + assert_noop!( + Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), + Error::::NotParimutuelOutcome + ); + }); +} + #[test_case(ScoringRule::AmmCdaHybrid; "amm_cda_hybrid")] fn buy_fails_if_invalid_scoring_rule(scoring_rule: ScoringRule) { ExtBuilder::default().build().execute_with(|| { @@ -102,7 +111,7 @@ fn buy_fails_if_invalid_scoring_rule(scoring_rule: ScoringRule) { Markets::::insert(market_id, market.clone()); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); assert_noop!( Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), @@ -124,7 +133,7 @@ fn buy_fails_if_market_status_is_not_active(status: MarketStatus) { Markets::::insert(market_id, market.clone()); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); assert_noop!( Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), @@ -143,7 +152,7 @@ fn buy_fails_if_market_type_is_scalar() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get() + ::MinBetSize::get(); assert_noop!( @@ -161,10 +170,10 @@ fn buy_fails_if_insufficient_balance() { market.status = MarketStatus::Active; Markets::::insert(market_id, market.clone()); - let free_alice = AssetManager::free_balance(market.base_asset.into(), &ALICE); - AssetManager::slash(market.base_asset.into(), &ALICE, free_alice); + let free_alice = AssetManager::free_balance(market.base_asset, &ALICE); + AssetManager::slash(market.base_asset, &ALICE, free_alice); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); assert_noop!( Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), @@ -181,7 +190,7 @@ fn buy_fails_if_below_minimum_bet_size() { market.status = MarketStatus::Active; Markets::::insert(market_id, market.clone()); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get() - 1; assert_noop!( Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), @@ -195,7 +204,7 @@ fn buy_fails_if_market_does_not_exist() { ExtBuilder::default().build().execute_with(|| { let market_id = 0; - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = ::MinBetSize::get(); assert_noop!( Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount), diff --git a/zrml/parimutuel/src/tests/claim.rs b/zrml/parimutuel/src/tests/claim.rs index 3ac7d390f..972473596 100644 --- a/zrml/parimutuel/src/tests/claim.rs +++ b/zrml/parimutuel/src/tests/claim.rs @@ -15,16 +15,15 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . +#![cfg(test)] + use crate::{mock::*, utils::*, *}; use core::ops::RangeInclusive; -use frame_support::{assert_noop, assert_ok, traits::fungibles::Create}; +use frame_support::{assert_noop, assert_ok}; use orml_traits::MultiCurrency; use sp_runtime::Percent; use test_case::test_case; -use zeitgeist_primitives::{ - traits::MarketTransitionApi, - types::{MarketStatus, MarketType, OutcomeReport, ParimutuelAsset, ScoringRule}, -}; +use zeitgeist_primitives::types::{Asset, MarketStatus, MarketType, OutcomeReport, ScoringRule}; use zrml_market_commons::{Error as MError, Markets}; #[test] @@ -35,12 +34,11 @@ fn claim_rewards_emits_event() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let winner_asset = ParimutuelAsset::Share(market_id, 0u16); - AssetRouter::create(winner_asset.into(), Default::default(), true, 1).unwrap(); + let winner_asset = Asset::ParimutuelShare(market_id, 0u16); let winner_amount = 20 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), winner_asset, winner_amount)); - let loser_asset = ParimutuelAsset::Share(market_id, 1u16); + let loser_asset = Asset::ParimutuelShare(market_id, 1u16); let loser_amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(BOB), loser_asset, loser_amount)); @@ -57,7 +55,7 @@ fn claim_rewards_emits_event() { System::assert_last_event( Event::RewardsClaimed { market_id, - asset: winner_asset.into(), + asset: winner_asset, withdrawn_asset_balance, base_asset_payoff: actual_payoff, sender: ALICE, @@ -75,15 +73,14 @@ fn claim_rewards_categorical_changes_balances_correctly() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let winner_asset = ParimutuelAsset::Share(market_id, 0u16); - AssetRouter::create(winner_asset.into(), Default::default(), true, 1).unwrap(); + let winner_asset = Asset::ParimutuelShare(market_id, 0u16); let winner_amount_0 = 20 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), winner_asset, winner_amount_0)); let winner_amount_1 = 30 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(CHARLIE), winner_asset, winner_amount_1)); - let loser_asset = ParimutuelAsset::Share(market_id, 1u16); + let loser_asset = Asset::ParimutuelShare(market_id, 1u16); let loser_amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(BOB), loser_asset, loser_amount)); @@ -106,66 +103,52 @@ fn claim_rewards_categorical_changes_balances_correctly() { assert_eq!(Percent::from_percent(60) * actual_payoff, actual_payoff_charlie); assert_eq!(actual_payoff_alice + actual_payoff_charlie, actual_payoff); - let free_winner_asset_alice_before = - AssetManager::free_balance(winner_asset.into(), &ALICE); + let free_winner_asset_alice_before = AssetManager::free_balance(winner_asset, &ALICE); let winner_amount_0_minus_fees = winner_amount_0 - Percent::from_percent(1) * winner_amount_0; assert_eq!(free_winner_asset_alice_before, winner_amount_0_minus_fees); - let free_base_asset_alice_before = - AssetManager::free_balance(market.base_asset.into(), &ALICE); - let free_base_asset_pot_before = AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id), - ); + let free_base_asset_alice_before = AssetManager::free_balance(market.base_asset, &ALICE); + let free_base_asset_pot_before = + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)); assert_eq!(free_base_asset_pot_before, total_pot_amount - total_fees); assert_ok!(Parimutuel::claim_rewards(RuntimeOrigin::signed(ALICE), market_id)); assert_eq!( - free_winner_asset_alice_before - - AssetManager::free_balance(winner_asset.into(), &ALICE), + free_winner_asset_alice_before - AssetManager::free_balance(winner_asset, &ALICE), winner_amount_0_minus_fees ); assert_eq!( - AssetManager::free_balance(market.base_asset.into(), &ALICE) - - free_base_asset_alice_before, + AssetManager::free_balance(market.base_asset, &ALICE) - free_base_asset_alice_before, actual_payoff_alice ); assert_eq!( - AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id) - ), + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)), actual_payoff_charlie ); - let free_winner_asset_charlie_before = - AssetManager::free_balance(winner_asset.into(), &CHARLIE); + let free_winner_asset_charlie_before = AssetManager::free_balance(winner_asset, &CHARLIE); let winner_amount_1_minus_fees = winner_amount_1 - Percent::from_percent(1) * winner_amount_1; assert_eq!(free_winner_asset_charlie_before, winner_amount_1_minus_fees); let free_base_asset_charlie_before = - AssetManager::free_balance(market.base_asset.into(), &CHARLIE); + AssetManager::free_balance(market.base_asset, &CHARLIE); assert_ok!(Parimutuel::claim_rewards(RuntimeOrigin::signed(CHARLIE), market_id)); assert_eq!( - free_winner_asset_charlie_before - - AssetManager::free_balance(winner_asset.into(), &CHARLIE), + free_winner_asset_charlie_before - AssetManager::free_balance(winner_asset, &CHARLIE), winner_amount_1_minus_fees ); assert_eq!( - AssetManager::free_balance(market.base_asset.into(), &CHARLIE) + AssetManager::free_balance(market.base_asset, &CHARLIE) - free_base_asset_charlie_before, actual_payoff_charlie ); assert_eq!( - AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id) - ), + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)), 0 ); }); @@ -261,11 +244,11 @@ fn claim_rewards_categorical_fails_if_no_winner() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let winner_asset = ParimutuelAsset::Share(market_id, 0u16); + let winner_asset = Asset::ParimutuelShare(market_id, 0u16); let winner_amount = 20 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), winner_asset, winner_amount)); - let loser_asset = ParimutuelAsset::Share(market_id, 1u16); + let loser_asset = Asset::ParimutuelShare(market_id, 1u16); let loser_amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(BOB), loser_asset, loser_amount)); @@ -291,11 +274,11 @@ fn claim_rewards_categorical_fails_if_no_winning_shares() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let winner_asset = ParimutuelAsset::Share(market_id, 0u16); + let winner_asset = Asset::ParimutuelShare(market_id, 0u16); let winner_amount = 20 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), winner_asset, winner_amount)); - let loser_asset = ParimutuelAsset::Share(market_id, 1u16); + let loser_asset = Asset::ParimutuelShare(market_id, 1u16); let loser_amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(BOB), loser_asset, loser_amount)); @@ -320,13 +303,12 @@ fn claim_refunds_works() { market.market_type = MarketType::Categorical(10u16); market.status = MarketStatus::Active; Markets::::insert(market_id, market); - assert_ok!(Parimutuel::on_activation(&market_id).result); - let alice_asset = ParimutuelAsset::Share(market_id, 0u16); + let alice_asset = Asset::ParimutuelShare(market_id, 0u16); let alice_amount = 20 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), alice_asset, alice_amount)); - let bob_asset = ParimutuelAsset::Share(market_id, 1u16); + let bob_asset = Asset::ParimutuelShare(market_id, 1u16); let bob_amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(BOB), bob_asset, bob_amount)); @@ -347,46 +329,33 @@ fn claim_refunds_works() { let alice_amount_minus_fees = alice_amount - alice_paid_fees; let bob_amount_minus_fees = bob_amount - bob_paid_fees; - let free_base_asset_alice_before = - AssetManager::free_balance(market.base_asset.into(), &ALICE); - let free_base_asset_bob_before = AssetManager::free_balance(market.base_asset.into(), &BOB); - let free_base_asset_pot_before = AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id), - ); + let free_base_asset_alice_before = AssetManager::free_balance(market.base_asset, &ALICE); + let free_base_asset_bob_before = AssetManager::free_balance(market.base_asset, &BOB); + let free_base_asset_pot_before = + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)); assert_ok!(Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), alice_asset)); assert_eq!( - AssetManager::free_balance(market.base_asset.into(), &ALICE) - - free_base_asset_alice_before, + AssetManager::free_balance(market.base_asset, &ALICE) - free_base_asset_alice_before, alice_amount_minus_fees ); assert_eq!( - AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id) - ), + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)), free_base_asset_pot_before - alice_amount_minus_fees ); assert_eq!( - AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id) - ), + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)), bob_amount_minus_fees ); assert_ok!(Parimutuel::claim_refunds(RuntimeOrigin::signed(BOB), bob_asset)); assert_eq!( - AssetManager::free_balance(market.base_asset.into(), &BOB) - free_base_asset_bob_before, + AssetManager::free_balance(market.base_asset, &BOB) - free_base_asset_bob_before, bob_amount_minus_fees ); assert_eq!( - AssetManager::free_balance( - market.base_asset.into(), - &Parimutuel::pot_account(market_id) - ), + AssetManager::free_balance(market.base_asset, &Parimutuel::pot_account(market_id)), 0 ); }); diff --git a/zrml/parimutuel/src/tests/mod.rs b/zrml/parimutuel/src/tests/mod.rs index 454cec9af..52de08fb9 100644 --- a/zrml/parimutuel/src/tests/mod.rs +++ b/zrml/parimutuel/src/tests/mod.rs @@ -17,7 +17,6 @@ #![cfg(test)] -mod assets; mod buy; mod claim; mod refund; diff --git a/zrml/parimutuel/src/tests/refund.rs b/zrml/parimutuel/src/tests/refund.rs index e5bd80863..09cf0c0d7 100644 --- a/zrml/parimutuel/src/tests/refund.rs +++ b/zrml/parimutuel/src/tests/refund.rs @@ -15,16 +15,35 @@ // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . +#![cfg(test)] + use crate::{mock::*, utils::*, *}; use frame_support::{assert_noop, assert_ok}; use sp_runtime::Percent; use test_case::test_case; -use zeitgeist_primitives::{ - traits::MarketTransitionApi, - types::{MarketStatus, MarketType, OutcomeReport, ParimutuelAsset, ScoringRule}, -}; +use zeitgeist_primitives::types::{Asset, MarketStatus, MarketType, OutcomeReport, ScoringRule}; use zrml_market_commons::Markets; +#[test] +fn refund_fails_if_not_parimutuel_outcome() { + ExtBuilder::default().build().execute_with(|| { + let market_id = 0; + let mut market = market_mock::(MARKET_CREATOR); + market.market_type = MarketType::Categorical(10u16); + market.resolved_outcome = Some(OutcomeReport::Categorical(0u16)); + market.status = MarketStatus::Resolved; + Markets::::insert(market_id, market); + + assert_noop!( + Parimutuel::claim_refunds( + RuntimeOrigin::signed(ALICE), + Asset::CategoricalOutcome(market_id, 0u16) + ), + Error::::NotParimutuelOutcome + ); + }); +} + #[test_case(MarketStatus::Active; "active")] #[test_case(MarketStatus::Proposed; "proposed")] #[test_case(MarketStatus::Closed; "closed")] @@ -38,7 +57,7 @@ fn refund_fails_if_market_not_resolved(status: MarketStatus) { market.status = status; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_noop!( Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset), Error::::MarketIsNotResolvedYet @@ -58,7 +77,7 @@ fn refund_fails_if_invalid_scoring_rule(scoring_rule: ScoringRule) { market.scoring_rule = scoring_rule; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_noop!( Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset), Error::::InvalidScoringRule @@ -76,7 +95,7 @@ fn refund_fails_if_invalid_outcome_asset() { market.status = MarketStatus::Resolved; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 20u16); + let asset = Asset::ParimutuelShare(market_id, 20u16); assert_noop!( Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset), Error::::InvalidOutcomeAsset @@ -94,7 +113,7 @@ fn refund_fails_if_no_resolved_outcome() { market.resolved_outcome = None; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_noop!( Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset), Error::::NoResolvedOutcome @@ -111,7 +130,7 @@ fn refund_fails_if_refund_not_allowed() { market.status = MarketStatus::Active; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount)); @@ -120,7 +139,7 @@ fn refund_fails_if_refund_not_allowed() { market.status = MarketStatus::Resolved; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_noop!( Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset), Error::::RefundNotAllowed @@ -136,9 +155,8 @@ fn refund_fails_if_refundable_balance_is_zero() { market.market_type = MarketType::Categorical(10u16); market.status = MarketStatus::Active; Markets::::insert(market_id, market); - assert_ok!(Parimutuel::on_activation(&market_id).result); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = 2 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount)); @@ -147,7 +165,7 @@ fn refund_fails_if_refundable_balance_is_zero() { market.status = MarketStatus::Resolved; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_ok!(Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset)); // already refunded above @@ -166,9 +184,8 @@ fn refund_emits_event() { market.market_type = MarketType::Categorical(10u16); market.status = MarketStatus::Active; Markets::::insert(market_id, market); - assert_ok!(Parimutuel::on_activation(&market_id).result); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); let amount = 10 * ::MinBetSize::get(); assert_ok!(Parimutuel::buy(RuntimeOrigin::signed(ALICE), asset, amount)); @@ -177,7 +194,7 @@ fn refund_emits_event() { market.status = MarketStatus::Resolved; Markets::::insert(market_id, market); - let asset = ParimutuelAsset::Share(market_id, 0u16); + let asset = Asset::ParimutuelShare(market_id, 0u16); assert_ok!(Parimutuel::claim_refunds(RuntimeOrigin::signed(ALICE), asset)); let amount_minus_fees = amount - (Percent::from_percent(1) * amount); @@ -185,7 +202,7 @@ fn refund_emits_event() { System::assert_last_event( Event::BalanceRefunded { market_id, - asset: asset.into(), + asset, refunded_balance: amount_minus_fees, sender: ALICE, } diff --git a/zrml/parimutuel/src/utils.rs b/zrml/parimutuel/src/utils.rs index b8a99edcd..35b0422f6 100644 --- a/zrml/parimutuel/src/utils.rs +++ b/zrml/parimutuel/src/utils.rs @@ -23,13 +23,13 @@ where use frame_support::traits::Get; use sp_runtime::{traits::AccountIdConversion, Perbill}; use zeitgeist_primitives::types::{ - BaseAsset, Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, + Asset, Deadlines, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, ScoringRule, }; zeitgeist_primitives::types::Market { market_id: Default::default(), - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: Perbill::zero(), creator, diff --git a/zrml/parimutuel/src/weights.rs b/zrml/parimutuel/src/weights.rs index de83ae773..a74a641f3 100644 --- a/zrml/parimutuel/src/weights.rs +++ b/zrml/parimutuel/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_parimutuel //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -52,108 +52,60 @@ pub trait WeightInfoZeitgeist { fn buy() -> Weight; fn claim_rewards() -> Weight; fn claim_refunds() -> Weight; - fn on_activation() -> Weight; - fn on_resolution() -> Weight; } /// Weight functions for zrml_parimutuel (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:1 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `1940` - // Estimated: `13590` - // Minimum execution time: 132_371 nanoseconds. - Weight::from_parts(162_240_000, 13590) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `390` + // Estimated: `4159` + // Minimum execution time: 165_850 nanoseconds. + Weight::from_parts(167_061_000, 4159) + .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:1 w:1) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:1 w:1) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn claim_rewards() -> Weight { // Proof Size summary in bytes: - // Measured: `3241` - // Estimated: `94450` - // Minimum execution time: 159_601 nanoseconds. - Weight::from_parts(222_111_000, 94450) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `790` + // Estimated: `4159` + // Minimum execution time: 142_031 nanoseconds. + Weight::from_parts(163_081_000, 4159) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:1) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:1 w:1) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn claim_refunds() -> Weight { // Proof Size summary in bytes: - // Measured: `3544` - // Estimated: `97150` - // Minimum execution time: 193_471 nanoseconds. - Weight::from_parts(222_400_000, 97150) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - fn on_activation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1203` - // Estimated: `175967` - // Minimum execution time: 592_941 nanoseconds. - Weight::from_parts(720_612_000, 175967) - .saturating_add(T::DbWeight::get().reads(65)) - .saturating_add(T::DbWeight::get().writes(64)) - } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:64 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) - fn on_resolution() -> Weight { - // Proof Size summary in bytes: - // Measured: `18393` - // Estimated: `417985` - // Minimum execution time: 1_162_074 nanoseconds. - Weight::from_parts(1_508_734_000, 417985) - .saturating_add(T::DbWeight::get().reads(131)) - .saturating_add(T::DbWeight::get().writes(65)) + // Measured: `790` + // Estimated: `6026` + // Minimum execution time: 146_230 nanoseconds. + Weight::from_parts(150_261_000, 6026) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/zrml/prediction-markets/Cargo.toml b/zrml/prediction-markets/Cargo.toml index 8579fcdb0..bbbf67b87 100644 --- a/zrml/prediction-markets/Cargo.toml +++ b/zrml/prediction-markets/Cargo.toml @@ -4,7 +4,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } log = { workspace = true } orml-traits = { workspace = true } -pallet-assets = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } serde = { workspace = true, optional = true } @@ -32,7 +31,6 @@ pallet-treasury = { workspace = true, optional = true } sp-api = { workspace = true, optional = true } sp-io = { workspace = true, optional = true } xcm = { workspace = true, optional = true } -zrml-asset-router = { workspace = true, optional = true } zrml-prediction-markets-runtime-api = { workspace = true, optional = true } [dev-dependencies] @@ -48,7 +46,6 @@ mock = [ "orml-asset-registry/default", "orml-currencies/default", "orml-tokens/default", - "pallet-assets/default", "pallet-balances/default", "pallet-insecure-randomness-collective-flip/default", "pallet-timestamp/default", @@ -57,9 +54,10 @@ mock = [ "sp-api/default", "sp-io/default", "zeitgeist-primitives/mock", - "zrml-asset-router/default", "zrml-prediction-markets-runtime-api/default", "xcm/default", + "orml-asset-registry/default", + "env_logger/default", ] parachain = [] runtime-benchmarks = [ @@ -67,7 +65,6 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "orml-asset-registry?/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "zeitgeist-primitives/mock", ] @@ -77,7 +74,6 @@ std = [ "frame-system/std", "orml-asset-registry?/std", "orml-traits/std", - "pallet-assets/std", "parity-scale-codec/std", 'scale-info/std', "serde?/std", diff --git a/zrml/prediction-markets/fuzz/pm_full_workflow.rs b/zrml/prediction-markets/fuzz/pm_full_workflow.rs index f3799a127..506b9e5cd 100644 --- a/zrml/prediction-markets/fuzz/pm_full_workflow.rs +++ b/zrml/prediction-markets/fuzz/pm_full_workflow.rs @@ -26,7 +26,7 @@ use sp_arithmetic::Perbill; use zeitgeist_primitives::{ constants::mock::MaxCreatorFee, types::{ - BaseAsset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketType, + Asset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketType, MultiHash, OutcomeReport, ScoringRule, }, }; @@ -48,7 +48,7 @@ fuzz_target!(|data: Data| { let fee = Perbill::from_parts(bounded_parts.try_into().unwrap()); let _ = PredictionMarkets::create_market( RuntimeOrigin::signed(data.create_scalar_market_origin.into()), - BaseAsset::Ztg, + Asset::Ztg, fee, data.create_scalar_market_oracle.into(), MarketPeriod::Block(data.create_scalar_market_period), diff --git a/zrml/prediction-markets/runtime-api/src/lib.rs b/zrml/prediction-markets/runtime-api/src/lib.rs index 4a488b52b..b90dcaac9 100644 --- a/zrml/prediction-markets/runtime-api/src/lib.rs +++ b/zrml/prediction-markets/runtime-api/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2023-2024 Forecasting Technologies LTD. +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -19,12 +19,12 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -use parity_scale_codec::{Codec, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Codec, MaxEncodedLen}; use zeitgeist_primitives::types::Asset; sp_api::decl_runtime_apis! { pub trait PredictionMarketsApi where - MarketId: Codec + HasCompact + MaxEncodedLen, + MarketId: Codec + MaxEncodedLen, Hash: Codec, { fn market_outcome_share_id(market_id: MarketId, outcome: u16) -> Asset; diff --git a/zrml/prediction-markets/src/benchmarks.rs b/zrml/prediction-markets/src/benchmarks.rs index 7fccef713..fa1782063 100644 --- a/zrml/prediction-markets/src/benchmarks.rs +++ b/zrml/prediction-markets/src/benchmarks.rs @@ -46,8 +46,8 @@ use zeitgeist_primitives::{ math::fixed::{BaseProvider, ZeitgeistBase}, traits::DisputeApi, types::{ - Asset, BaseAsset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, - MarketStatus, MarketType, MultiHash, OutcomeReport, ScoringRule, + Asset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, + MarketType, MultiHash, OutcomeReport, ScoringRule, }, }; use zrml_authorized::Pallet as AuthorizedPallet; @@ -95,7 +95,7 @@ fn create_market_common( let (caller, oracle, deadlines, metadata) = create_market_common_parameters::(dispute_mechanism.is_some())?; Call::::create_market { - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creator_fee, oracle, period, @@ -489,7 +489,7 @@ benchmarks! { } }: _( RawOrigin::Signed(caller), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), oracle, period, @@ -513,7 +513,7 @@ benchmarks! { let (caller, oracle, deadlines, metadata) = create_market_common_parameters::(true)?; Call::::create_market { - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creator_fee: Perbill::zero(), oracle: oracle.clone(), period: period.clone(), @@ -545,7 +545,7 @@ benchmarks! { }; }: _( RawOrigin::Signed(caller), - BaseAsset::Ztg, + Asset::Ztg, market_id, oracle, period, @@ -854,7 +854,7 @@ benchmarks! { let end: MomentOf = 1_000_000u64.saturated_into(); let (caller, oracle, _, metadata) = create_market_common_parameters::(false)?; Call::::create_market { - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creator_fee: Perbill::zero(), oracle: caller.clone(), period: MarketPeriod::Timestamp(start..end), @@ -1286,7 +1286,7 @@ benchmarks! { let m in 0..63; // Number of markets closing on the same block. let n in 2..T::MaxCategories::get() as u32; // Number of assets in the market. - let base_asset = BaseAsset::Ztg; + let base_asset = Asset::Ztg; let range_start = (5 * MILLISECS_PER_BLOCK) as u64; let range_end = (100 * MILLISECS_PER_BLOCK) as u64; let period = MarketPeriod::Timestamp(range_start..range_end); @@ -1296,7 +1296,7 @@ benchmarks! { let amount = (10u128 * BASE).saturated_into(); ::AssetManager::deposit( - base_asset.into(), + base_asset, &caller, amount, )?; diff --git a/zrml/prediction-markets/src/lib.rs b/zrml/prediction-markets/src/lib.rs index 0e825cc06..3d6896889 100644 --- a/zrml/prediction-markets/src/lib.rs +++ b/zrml/prediction-markets/src/lib.rs @@ -34,7 +34,7 @@ pub use pallet::*; #[frame_support::pallet] mod pallet { use crate::weights::*; - use alloc::{collections::BTreeMap, format, vec, vec::Vec}; + use alloc::{format, vec, vec::Vec}; use core::{cmp, marker::PhantomData}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, @@ -43,24 +43,18 @@ mod pallet { require_transactional, storage::{with_transaction, TransactionOutcome}, traits::{ - fungibles::{Create, Inspect}, - tokens::BalanceStatus, - Currency, EnsureOrigin, Get, Hooks, Imbalance, IsType, NamedReservableCurrency, - OnUnbalanced, StorageVersion, + tokens::BalanceStatus, Currency, EnsureOrigin, Get, Hooks, Imbalance, IsType, + NamedReservableCurrency, OnUnbalanced, StorageVersion, }, transactional, weights::Weight, Blake2_128Concat, BoundedVec, PalletId, Twox64Concat, }; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; - use pallet_assets::ManagedDestroy; use sp_runtime::traits::AccountIdConversion; #[cfg(feature = "parachain")] - use { - orml_traits::asset_registry::Inspect as RegistryInspect, - zeitgeist_primitives::types::{CustomMetadata, XcmAsset}, - }; + use {orml_traits::asset_registry::Inspect, zeitgeist_primitives::types::CustomMetadata}; use frame_system::pallet_prelude::BlockNumberFor; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; @@ -73,13 +67,13 @@ mod pallet { constants::MILLISECS_PER_BLOCK, traits::{ CompleteSetOperationsApi, DeployPoolApi, DisputeApi, DisputeMaxWeightApi, - DisputeResolutionApi, MarketBuilderTrait, MarketTransitionApi, + DisputeResolutionApi, MarketBuilderTrait, }, types::{ - Asset, BaseAsset, Bond, Deadlines, EarlyClose, EarlyCloseState, GlobalDisputeItem, - Market, MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, - MarketStatus, MarketType, MultiHash, OutcomeReport, Report, ResultWithWeightInfo, - ScalarPosition, ScoringRule, + Asset, Bond, Deadlines, EarlyClose, EarlyCloseState, GlobalDisputeItem, Market, + MarketBonds, MarketCreation, MarketDisputeMechanism, MarketPeriod, MarketStatus, + MarketType, MultiHash, OutcomeReport, Report, ResultWithWeightInfo, ScalarPosition, + ScoringRule, }, }; use zrml_global_disputes::{types::InitialItem, GlobalDisputesPalletApi}; @@ -94,6 +88,7 @@ mod pallet { /// the automatic market openings and closings from a chain stall. /// Currently 10 blocks is 2 minutes (assuming block time is 12 seconds). pub(crate) const MAX_RECOVERY_TIME_FRAMES: TimeFrame = 10; + pub(crate) type AccountIdOf = ::AccountId; pub(crate) type AssetOf = Asset>; pub(crate) type BalanceOf = ::Balance; @@ -103,14 +98,8 @@ mod pallet { pub(crate) type InitialItemOf = InitialItem, BalanceOf>; pub(crate) type MarketBondsOf = MarketBonds, BalanceOf>; pub(crate) type MarketIdOf = ::MarketId; - pub(crate) type MarketOf = Market< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAsset, - MarketIdOf, - >; + pub(crate) type MarketOf = + Market, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; pub(crate) type MarketPeriodOf = MarketPeriod, MomentOf>; pub(crate) type MomentOf = <::Timestamp as frame_support::traits::Time>::Moment; @@ -450,27 +439,11 @@ mod pallet { Error::::MarketEditRequestAlreadyInProgress ); m.status = new_status; - - if m.is_redeemable() { - for outcome in m.outcome_assets() { - let admin = Self::market_account(market_id); - let is_sufficient = true; - let min_balance = 1u8; - T::AssetCreator::create( - outcome.into(), - admin, - is_sufficient, - min_balance.into(), - )?; - } - } - Ok(()) })?; Self::unreserve_creation_bond(&market_id)?; - T::OnStateTransition::on_activation(&market_id).result?; Self::deposit_event(Event::MarketApproved(market_id, new_status)); // The ApproveOrigin should not pay fees for providing this service let default_weight: Option = None; @@ -604,7 +577,6 @@ mod pallet { Ok(()) })?; - T::OnStateTransition::on_dispute(&market_id).result?; Self::deposit_event(Event::MarketDisputed(market_id, MarketStatus::Disputed, who)); Ok((Some(weight)).into()) } @@ -620,7 +592,7 @@ mod pallet { #[transactional] pub fn create_market( origin: OriginFor, - base_asset: BaseAsset, + base_asset: AssetOf, creator_fee: Perbill, oracle: T::AccountId, period: MarketPeriodOf, @@ -672,7 +644,7 @@ mod pallet { #[transactional] pub fn edit_market( origin: OriginFor, - base_asset: BaseAsset, + base_asset: AssetOf, market_id: MarketIdOf, oracle: T::AccountId, period: MarketPeriodOf, @@ -760,7 +732,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(market.base_asset.into(), &market_account) + T::AssetManager::free_balance(market.base_asset, &market_account) >= winning_balance, Error::::InsufficientFundsInMarketAccount, ); @@ -814,7 +786,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(market.base_asset.into(), &market_account) + T::AssetManager::free_balance(market.base_asset, &market_account) >= long_payout.saturating_add(short_payout), Error::::InsufficientFundsInMarketAccount, ); @@ -840,25 +812,18 @@ mod pallet { // Pay out the winner. let remaining_bal = - T::AssetManager::free_balance(market.base_asset.into(), &market_account); + T::AssetManager::free_balance(market.base_asset, &market_account); let actual_payout = payout.min(remaining_bal); T::AssetManager::transfer( - market.base_asset.into(), + 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 != BalanceOf::::zero() { - if T::AssetManager::total_issuance(currency_id).is_zero() { - // Ensure managed_destroy does not error during lazy migration because - // it tried to delete an old outcome asset from orml-tokens - let _ = T::AssetDestroyer::managed_destroy(currency_id, None); - } - Self::deposit_event(Event::TokensRedeemed( market_id, currency_id, @@ -1067,7 +1032,6 @@ mod pallet { m.status = MarketStatus::Disputed; Ok(()) })?; - T::OnStateTransition::on_dispute(&market_id).result?; } // global disputes uses DisputeResolution API to control its resolution @@ -1095,7 +1059,7 @@ mod pallet { #[pallet::call_index(17)] pub fn create_market_and_deploy_pool( origin: OriginFor, - base_asset: BaseAsset, + base_asset: AssetOf, creator_fee: Perbill, oracle: T::AccountId, period: MarketPeriodOf, @@ -1548,15 +1512,8 @@ mod pallet { /// The origin that is allowed to approve / reject pending advised markets. type ApproveOrigin: EnsureOrigin; - /// The module handling the creation of market assets. - type AssetCreator: Create, Balance = BalanceOf>; - - /// The module handling the destruction of market assets. - type AssetDestroyer: ManagedDestroy, Balance = BalanceOf>; - - /// The module managing collateral and market assets. - type AssetManager: MultiCurrency, CurrencyId = AssetOf> - + NamedMultiReservableCurrency< + /// Shares of outcome assets and native currency + type AssetManager: NamedMultiReservableCurrency< Self::AccountId, Balance = BalanceOf, CurrencyId = AssetOf, @@ -1564,8 +1521,8 @@ mod pallet { >; #[cfg(feature = "parachain")] - type AssetRegistry: RegistryInspect< - AssetId = XcmAsset, + type AssetRegistry: Inspect< + AssetId = Asset>, Balance = BalanceOf, CustomMetadata = CustomMetadata, >; @@ -1726,9 +1683,6 @@ mod pallet { /// The origin that is allowed to reject pending advised markets. type RejectOrigin: EnsureOrigin; - /// Additional handler during state transitions. - type OnStateTransition: MarketTransitionApi>; - /// The base amount of currency that must be bonded to ensure the oracle reports /// in a timely manner. #[pallet::constant] @@ -2119,7 +2073,7 @@ mod pallet { #[require_transactional] fn do_create_market( who: T::AccountId, - base_asset: BaseAsset, + base_asset: AssetOf, creator_fee: Perbill, oracle: T::AccountId, period: MarketPeriodOf, @@ -2171,33 +2125,32 @@ mod pallet { let (market_id, market) = >::build_market(market_builder)?; let market_account = Self::market_account(market_id); - match market.status { - MarketStatus::Active => { - if market.is_redeemable() { - for outcome in market.outcome_assets() { - let admin = market_account.clone(); - let is_sufficient = true; - let min_balance = 1u8; - T::AssetCreator::create( - outcome.into(), - admin, - is_sufficient, - min_balance.into(), - )?; - } - } - - T::OnStateTransition::on_activation(&market_id).result? - } - MarketStatus::Proposed => T::OnStateTransition::on_proposal(&market_id).result?, - _ => (), - } let ids_amount: u32 = Self::insert_auto_close(&market_id)?; + Self::deposit_event(Event::MarketCreated(market_id, market_account, market)); + Ok((ids_amount, market_id)) } + pub fn outcome_assets(market_id: MarketIdOf, market: &MarketOf) -> Vec> { + match market.market_type { + MarketType::Categorical(categories) => { + let mut assets = Vec::new(); + for i in 0..categories { + assets.push(Asset::CategoricalOutcome(market_id, i)); + } + assets + } + MarketType::Scalar(_) => { + vec![ + Asset::ScalarOutcome(market_id, ScalarPosition::Long), + Asset::ScalarOutcome(market_id, ScalarPosition::Short), + ] + } + } + } + fn insert_auto_close(market_id: &MarketIdOf) -> Result { let market = >::market(market_id)?; @@ -2312,7 +2265,7 @@ mod pallet { let market_account = Self::market_account(market_id); ensure!( - T::AssetManager::free_balance(market.base_asset.into(), &market_account) >= amount, + T::AssetManager::free_balance(market.base_asset, &market_account) >= amount, "Market account does not have sufficient reserves.", ); @@ -2323,14 +2276,14 @@ mod pallet { // Ensures that the sender has sufficient amount of each // share in the set. ensure!( - T::AssetManager::free_balance((*asset).into(), &who) >= amount, + T::AssetManager::free_balance(*asset, &who) >= amount, Error::::InsufficientShareBalance, ); } // write last. for asset in assets.iter() { - let missing = T::AssetManager::slash((*asset).into(), &who, amount); + let missing = T::AssetManager::slash(*asset, &who, amount); debug_assert!( missing.is_zero(), "Could not slash all of the amount. asset {:?}, who: {:?}, amount: {:?}.", @@ -2340,7 +2293,7 @@ mod pallet { ); } - T::AssetManager::transfer(market.base_asset.into(), &market_account, &who, amount)?; + T::AssetManager::transfer(market.base_asset, &market_account, &who, amount)?; Self::deposit_event(Event::SoldCompleteSet(market_id, amount, who)); @@ -2356,18 +2309,18 @@ mod pallet { ensure!(amount != BalanceOf::::zero(), Error::::ZeroAmount); let market = >::market(&market_id)?; ensure!( - T::AssetManager::free_balance(market.base_asset.into(), &who) >= amount, + T::AssetManager::free_balance(market.base_asset, &who) >= amount, Error::::NotEnoughBalance ); ensure!(market.is_redeemable(), Error::::InvalidScoringRule); Self::ensure_market_is_active(&market)?; let market_account = Self::market_account(market_id); - T::AssetManager::transfer(market.base_asset.into(), &who, &market_account, amount)?; + T::AssetManager::transfer(market.base_asset, &who, &market_account, amount)?; let assets = market.outcome_assets(); for asset in assets.iter() { - T::AssetManager::deposit((*asset).into(), &who, amount)?; + T::AssetManager::deposit(*asset, &who, amount)?; } Self::deposit_event(Event::BoughtCompleteSet(market_id, amount, who)); @@ -2550,12 +2503,9 @@ mod pallet { market.status = MarketStatus::Closed; Ok(()) })?; - - let mut total_weight = T::DbWeight::get().reads_writes(1, 2); - let on_state_transition_result = T::OnStateTransition::on_closure(market_id); - on_state_transition_result.result?; - total_weight = total_weight.saturating_add(on_state_transition_result.weight); + let mut total_weight = T::DbWeight::get().reads_writes(1, 1); Self::deposit_event(Event::MarketClosed(*market_id)); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); Ok(total_weight) } @@ -2800,44 +2750,20 @@ mod pallet { // Following call should return weight consumed by it. T::LiquidityMining::distribute_market_incentives(market_id)?; - let mut updated_market = market.clone(); - + // 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. >::mutate_market(market_id, |m| { m.status = MarketStatus::Resolved; m.resolved_outcome = Some(resolved_outcome.clone()); - updated_market = m.clone(); Ok(()) })?; - let winning_outcome = updated_market.resolved_outcome_into_asset(); - if market.is_redeemable() { - if let Some(winning_outcome_inner) = winning_outcome { - // Destroy losing assets. - let assets_to_destroy = BTreeMap::, Option>::from_iter( - market - .outcome_assets() - .into_iter() - .filter(|outcome| *outcome != winning_outcome_inner) - .map(|asset| (AssetOf::::from(asset), None)), - ); - // Ensure managed_destroy_multi does not error during lazy migration because - // it tried to delete an old outcome asset from orml-tokens - let _ = T::AssetDestroyer::managed_destroy_multi(assets_to_destroy); - } - } - - let on_state_transition_result = T::OnStateTransition::on_resolution(market_id); - on_state_transition_result.result?; - total_weight = total_weight.saturating_add(on_state_transition_result.weight); - total_weight = - total_weight.saturating_add(Self::calculate_internal_resolve_weight(market)); - Self::deposit_event(Event::MarketResolved( *market_id, MarketStatus::Resolved, resolved_outcome, )); - Ok(total_weight) + Ok(total_weight.saturating_add(Self::calculate_internal_resolve_weight(market))) } /// The reserve ID of the prediction-markets pallet. @@ -2941,7 +2867,7 @@ mod pallet { fn construct_market( market_id: Option>, - base_asset: BaseAsset, + base_asset: AssetOf, creator: T::AccountId, creator_fee: Perbill, oracle: T::AccountId, @@ -2957,21 +2883,16 @@ mod pallet { bonds: MarketBondsOf, ) -> Result, DispatchError> { let valid_base_asset = match base_asset { - BaseAsset::CampaignAsset(idx) => { - T::AssetCreator::asset_exists(BaseAsset::CampaignAsset(idx).into()) - } - BaseAsset::Ztg => true, + Asset::Ztg => true, #[cfg(feature = "parachain")] - BaseAsset::ForeignAsset(id) => { - if let Some(metadata) = T::AssetRegistry::metadata(&XcmAsset::ForeignAsset(id)) - { + 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()); } } - #[cfg(not(feature = "parachain"))] - BaseAsset::ForeignAsset(_) => false, + _ => false, }; ensure!(creator_fee <= T::MaxCreatorFee::get(), Error::::FeeTooHigh); @@ -3075,7 +2996,6 @@ mod pallet { Ok(()) })?; - T::OnStateTransition::on_report(&market_id).result?; let market = >::market(&market_id)?; let block_after_dispute_duration = report.at.saturating_add(market.deadlines.dispute_duration); @@ -3102,7 +3022,6 @@ mod pallet { market.status = MarketStatus::Reported; Ok(()) })?; - T::OnStateTransition::on_report(&market_id).result?; let market = >::market(&market_id)?; Self::on_resolution(&market_id, &market)?; Ok(Some(T::WeightInfo::report_trusted_market()).into()) diff --git a/zrml/prediction-markets/src/mock.rs b/zrml/prediction-markets/src/mock.rs index 13e383350..8201292c4 100644 --- a/zrml/prediction-markets/src/mock.rs +++ b/zrml/prediction-markets/src/mock.rs @@ -24,16 +24,10 @@ use crate as prediction_markets; use frame_support::{ - construct_runtime, ord_parameter_types, - pallet_prelude::Weight, - parameter_types, - storage::unhashed::put, - traits::{ - AsEnsureOriginWithArg, Everything, NeverEnsureOrigin, OnFinalize, OnIdle, OnInitialize, - }, + construct_runtime, ord_parameter_types, parameter_types, + traits::{Everything, NeverEnsureOrigin, OnFinalize, OnInitialize}, }; -use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSigned, EnsureSignedBy}; -use parity_scale_codec::Compact; +use frame_system::{mocking::MockBlock, EnsureRoot, EnsureSignedBy}; use sp_arithmetic::per_things::Percent; use sp_runtime::{ traits::{BlakeTwo256, ConstU32, IdentityLookup}, @@ -42,44 +36,33 @@ use sp_runtime::{ use std::cell::RefCell; use zeitgeist_primitives::{ constants::mock::{ - AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AssetsAccountDeposit, - AssetsApprovalDeposit, AssetsDeposit, AssetsMetadataDepositBase, - AssetsMetadataDepositPerByte, AssetsStringLimit, AuthorizedPalletId, BlockHashCount, - BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, + AddOutcomePeriod, AggregationPeriod, AppealBond, AppealPeriod, AuthorizedPalletId, + BlockHashCount, BlocksPerYear, CloseEarlyBlockPeriod, CloseEarlyDisputeBond, CloseEarlyProtectionBlockPeriod, CloseEarlyProtectionTimeFramePeriod, CloseEarlyRequestBond, CloseEarlyTimeFramePeriod, CorrectionPeriod, CourtPalletId, - DestroyAccountWeight, DestroyApprovalWeight, DestroyFinishWeight, ExistentialDeposit, - ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, GlobalDisputeLockId, - GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, LockId, MaxAppeals, - MaxApprovals, MaxCategories, MaxCourtParticipants, MaxCreatorFee, MaxDelegations, - MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, MaxGracePeriod, - MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOwners, MaxRejectReasonLen, MaxReserves, - MaxSelectedDraws, MaxYearlyInflation, MinCategories, MinDisputeDuration, MinJurorStake, - MinOracleDuration, MinOutcomeVoteAmount, MinimumPeriod, OutcomeBond, OutcomeFactor, - OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, SimpleDisputesPalletId, - TreasuryPalletId, VotePeriod, VotingOutcomeFee, BASE, CENT, MILLISECS_PER_BLOCK, + ExistentialDeposit, ExistentialDeposits, GdVotingPeriod, GetNativeCurrencyId, + GlobalDisputeLockId, GlobalDisputesPalletId, InflationPeriod, LiquidityMiningPalletId, + LockId, MaxAppeals, MaxApprovals, MaxCategories, MaxCourtParticipants, MaxCreatorFee, + MaxDelegations, MaxDisputeDuration, MaxDisputes, MaxEditReasonLen, MaxGlobalDisputeVotes, + MaxGracePeriod, MaxLocks, MaxMarketLifetime, MaxOracleDuration, MaxOwners, + MaxRejectReasonLen, MaxReserves, MaxSelectedDraws, MaxYearlyInflation, MinCategories, + MinDisputeDuration, MinJurorStake, MinOracleDuration, MinOutcomeVoteAmount, MinimumPeriod, + OutcomeBond, OutcomeFactor, OutsiderBond, PmPalletId, RemoveKeysLimit, RequestInterval, + SimpleDisputesPalletId, TreasuryPalletId, VotePeriod, VotingOutcomeFee, BASE, CENT, + MILLISECS_PER_BLOCK, }, - traits::{DeployPoolApi, MarketTransitionApi}, + traits::DeployPoolApi, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, BlockNumber, BlockTest, - CampaignAsset, CampaignAssetClass, CampaignAssetId, Currencies, CustomAsset, CustomAssetId, - Hash, MarketAsset, MarketId, Moment, ResultWithWeightInfo, + AccountIdTest, Amount, Asset, Balance, BasicCurrencyAdapter, BlockNumber, BlockTest, + CurrencyId, Hash, MarketId, Moment, }, }; - #[cfg(feature = "parachain")] use { orml_traits::asset_registry::AssetProcessor, parity_scale_codec::Encode, - zeitgeist_primitives::types::CustomMetadata, zeitgeist_primitives::types::XcmAsset, + zeitgeist_primitives::types::CustomMetadata, }; -pub(super) const ON_PROPOSAL_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x00]; -pub(super) const ON_ACTIVATION_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x01]; -pub(super) const ON_CLOSURE_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x02]; -pub(super) const ON_REPORT_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x03]; -pub(super) const ON_DISPUTE_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x04]; -pub(super) const ON_RESOLUTION_STORAGE: [u8; 4] = [0x09, 0x09, 0x00, 0x05]; - pub const ALICE: AccountIdTest = 0; pub const BOB: AccountIdTest = 1; pub const CHARLIE: AccountIdTest = 2; @@ -109,36 +92,6 @@ pub struct DeployPoolArgs { swap_fee: Balance, } -// It just writes true to specific memory locations depending on the hook that's invoked. -pub struct StateTransitionMock; - -impl MarketTransitionApi for StateTransitionMock { - fn on_proposal(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_PROPOSAL_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_activation(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_ACTIVATION_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_closure(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_CLOSURE_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_report(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_REPORT_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_dispute(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_DISPUTE_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } - fn on_resolution(_market_id: &MarketId) -> ResultWithWeightInfo { - put(&ON_RESOLUTION_STORAGE, &true); - ResultWithWeightInfo::new(Ok(()), Weight::zero()) - } -} - thread_local! { pub static DEPLOY_POOL_CALL_DATA: RefCell> = const { RefCell::new(vec![]) }; pub static DEPLOY_POOL_RETURN_VALUE: RefCell = const { RefCell::new(Ok(())) }; @@ -213,23 +166,15 @@ parameter_types! { pub const DisputeBond: Balance = 109 * CENT; } -type CustomAssetsInstance = pallet_assets::Instance1; -type CampaignAssetsInstance = pallet_assets::Instance2; -type MarketAssetsInstance = pallet_assets::Instance3; - construct_runtime!( pub enum Runtime { #[cfg(feature = "parachain")] AssetRegistry: orml_asset_registry, - AssetRouter: zrml_asset_router, Authorized: zrml_authorized, Balances: pallet_balances, - CampaignAssets: pallet_assets::, - CustomAssets: pallet_assets::, Court: zrml_court, AssetManager: orml_currencies, LiquidityMining: zrml_liquidity_mining, - MarketAssets: pallet_assets::, MarketCommons: zrml_market_commons, PredictionMarkets: prediction_markets, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, @@ -246,9 +191,6 @@ impl crate::Config for Runtime { type AdvisoryBond = AdvisoryBond; type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage; type ApproveOrigin = EnsureSignedBy; - type AssetCreator = AssetRouter; - type AssetDestroyer = AssetRouter; - type AssetManager = AssetManager; #[cfg(feature = "parachain")] type AssetRegistry = AssetRegistry; type Authorized = Authorized; @@ -277,7 +219,6 @@ impl crate::Config for Runtime { type MinCategories = MinCategories; type MaxEditReasonLen = MaxEditReasonLen; type MaxRejectReasonLen = MaxRejectReasonLen; - type OnStateTransition = (StateTransitionMock,); type OracleBond = OracleBond; type OutsiderBond = OutsiderBond; type PalletId = PmPalletId; @@ -286,6 +227,7 @@ impl crate::Config for Runtime { type RejectOrigin = EnsureSignedBy; type RequestEditOrigin = EnsureSignedBy; type ResolveOrigin = EnsureSignedBy; + type AssetManager = AssetManager; type SimpleDisputes = SimpleDisputes; type Slash = Treasury; type ValidityBond = ValidityBond; @@ -307,7 +249,7 @@ impl frame_system::Config for Runtime { type Hashing = BlakeTwo256; type Lookup = IdentityLookup; type Nonce = u64; - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; type OnKilledAccount = (); type OnNewAccount = (); type RuntimeOrigin = RuntimeOrigin; @@ -320,7 +262,7 @@ impl frame_system::Config for Runtime { impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = GetNativeCurrencyId; - type MultiCurrency = AssetRouter; + type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; type WeightInfo = (); } @@ -334,9 +276,9 @@ cfg_if::cfg_if!( >; pub struct NoopAssetProcessor {} - impl AssetProcessor for NoopAssetProcessor { - fn pre_register(id: Option, asset_metadata: AssetMetadata) - -> Result<(XcmAsset, AssetMetadata), DispatchError> { + impl AssetProcessor for NoopAssetProcessor { + fn pre_register(id: Option, asset_metadata: AssetMetadata) + -> Result<(CurrencyId, AssetMetadata), DispatchError> { Ok((id.unwrap(), asset_metadata)) } } @@ -344,7 +286,7 @@ cfg_if::cfg_if!( impl orml_asset_registry::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CustomMetadata = CustomMetadata; - type AssetId = XcmAsset; + type AssetId = CurrencyId; type AuthorityOrigin = EnsureRoot; type AssetProcessor = NoopAssetProcessor; type Balance = Balance; @@ -357,7 +299,7 @@ cfg_if::cfg_if!( impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Currencies; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -368,6 +310,14 @@ impl orml_tokens::Config for Runtime { 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; @@ -397,122 +347,6 @@ ord_parameter_types! { pub const AuthorizedDisputeResolutionUser: AccountIdTest = ALICE; } -pallet_assets::runtime_benchmarks_enabled! { - pub struct AssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for AssetsBenchmarkHelper - where - AssetIdParameter: From, - { - fn create_asset_id_parameter(id: u32) -> AssetIdParameter { - (id as u128).into() - } - } -} - -pallet_assets::runtime_benchmarks_enabled! { - use zeitgeist_primitives::types::CategoryIndex; - - pub struct MarketAssetsBenchmarkHelper; - - impl pallet_assets::BenchmarkHelper - for MarketAssetsBenchmarkHelper - { - fn create_asset_id_parameter(id: u32) -> MarketAsset { - MarketAsset::CategoricalOutcome(0, id as CategoryIndex) - } - } -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CampaignAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = CustomAsset; - type AssetIdParameter = Compact; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = AssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl pallet_assets::Config for Runtime { - type ApprovalDeposit = AssetsApprovalDeposit; - type AssetAccountDeposit = AssetsAccountDeposit; - type AssetDeposit = AssetsDeposit; - type AssetId = MarketAsset; - type AssetIdParameter = MarketAsset; - type Balance = Balance; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = MarketAssetsBenchmarkHelper; - type CallbackHandle = (); - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type Extra = (); - type ForceOrigin = EnsureRoot; - type Freezer = (); - type Destroyer = AssetRouter; - type MetadataDepositBase = AssetsMetadataDepositBase; - type MetadataDepositPerByte = AssetsMetadataDepositPerByte; - type RemoveItemsLimit = ConstU32<50>; - type RuntimeEvent = RuntimeEvent; - type StringLimit = AssetsStringLimit; - type WeightInfo = (); -} - -impl zrml_asset_router::Config for Runtime { - type AssetType = Assets; - type Balance = Balance; - type CurrencyType = Currencies; - type Currencies = Tokens; - type CampaignAssetType = CampaignAsset; - type CampaignAssets = CampaignAssets; - type CustomAssetType = CustomAsset; - type CustomAssets = CustomAssets; - type DestroyAccountWeight = DestroyAccountWeight; - type DestroyApprovalWeight = DestroyApprovalWeight; - type DestroyFinishWeight = DestroyFinishWeight; - type MarketAssetType = MarketAsset; - type MarketAssets = MarketAssets; -} - impl zrml_authorized::Config for Runtime { type AuthorizedDisputeResolutionOrigin = EnsureSignedBy; @@ -643,18 +477,6 @@ impl ExtBuilder { // see the logs in tests when using `RUST_LOG=debug cargo test -- --nocapture` let _ = env_logger::builder().is_test(true).try_init(); - pallet_assets::GenesisConfig:: { - assets: vec![(CampaignAssetClass(100), ALICE, true, 1)], - metadata: vec![], - accounts: self - .balances - .iter() - .map(|(account, balance)| (CampaignAssetClass(100), *account, *balance)) - .collect(), - } - .assimilate_storage(&mut t) - .unwrap(); - pallet_balances::GenesisConfig:: { balances: self.balances } .assimilate_storage(&mut t) .unwrap(); @@ -663,7 +485,7 @@ impl ExtBuilder { { orml_tokens::GenesisConfig:: { balances: (0..69) - .map(|idx| (idx, Currencies::ForeignAsset(100), INITIAL_BALANCE)) + .map(|idx| (idx, Asset::ForeignAsset(100), INITIAL_BALANCE)) .collect(), } .assimilate_storage(&mut t) @@ -677,7 +499,7 @@ impl ExtBuilder { orml_asset_registry::GenesisConfig:: { assets: vec![ ( - XcmAsset::ForeignAsset(100), + Asset::ForeignAsset(100), AssetMetadata { decimals: 18, name: "ACALA USD".as_bytes().to_vec().try_into().unwrap(), @@ -689,7 +511,7 @@ impl ExtBuilder { .encode(), ), ( - XcmAsset::ForeignAsset(420), + Asset::ForeignAsset(420), AssetMetadata { decimals: 18, name: "FANCY_TOKEN".as_bytes().to_vec().try_into().unwrap(), @@ -701,7 +523,7 @@ impl ExtBuilder { .encode(), ), ], - last_asset_id: XcmAsset::ForeignAsset(420), + last_asset_id: Asset::ForeignAsset(420), } .assimilate_storage(&mut t) .unwrap(); @@ -724,7 +546,6 @@ pub fn run_to_block(n: BlockNumber) { PredictionMarkets::on_initialize(System::block_number()); Court::on_initialize(System::block_number()); Balances::on_initialize(System::block_number()); - AssetRouter::on_idle(System::block_number(), Weight::MAX); } } @@ -743,8 +564,8 @@ type Block = MockBlock; sp_api::mock_impl_runtime_apis! { impl zrml_prediction_markets_runtime_api::PredictionMarketsApi, MarketId, Hash> for Runtime { - fn market_outcome_share_id(_: MarketId, _: u16) -> Assets { - Assets::PoolShare(1) + fn market_outcome_share_id(_: MarketId, _: u16) -> Asset { + Asset::PoolShare(1) } } } diff --git a/zrml/prediction-markets/src/tests/admin_move_market_to_closed.rs b/zrml/prediction-markets/src/tests/admin_move_market_to_closed.rs index 90896a335..5417f1e6a 100644 --- a/zrml/prediction-markets/src/tests/admin_move_market_to_closed.rs +++ b/zrml/prediction-markets/src/tests/admin_move_market_to_closed.rs @@ -28,7 +28,7 @@ fn admin_move_market_to_closed_successfully_closes_market_and_sets_end_blocknumb let now = frame_system::Pallet::::block_number(); let end = 42; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, now..end, ScoringRule::AmmCdaHybrid, @@ -59,7 +59,7 @@ fn admin_move_market_to_closed_successfully_closes_market_and_sets_end_timestamp let end = start + 42u64 * (MILLISECS_PER_BLOCK as u64); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(start..end), @@ -114,7 +114,7 @@ fn admin_move_market_to_closed_fails_if_market_does_not_exist() { fn admin_move_market_to_closed_fails_if_market_is_not_active(market_status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -140,7 +140,7 @@ fn admin_move_market_to_closed_correctly_clears_auto_close_blocks() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Block(22..66), @@ -153,7 +153,7 @@ fn admin_move_market_to_closed_correctly_clears_auto_close_blocks() { )); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Block(33..66), diff --git a/zrml/prediction-markets/src/tests/admin_move_market_to_resolved.rs b/zrml/prediction-markets/src/tests/admin_move_market_to_resolved.rs index 9835169eb..6a6f9759e 100644 --- a/zrml/prediction-markets/src/tests/admin_move_market_to_resolved.rs +++ b/zrml/prediction-markets/src/tests/admin_move_market_to_resolved.rs @@ -24,7 +24,7 @@ use zeitgeist_primitives::types::OutcomeReport; #[test] fn admin_move_market_to_resolved_resolves_reported_market() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let end = 33; simple_create_categorical_market( base_asset, @@ -83,21 +83,18 @@ fn admin_move_market_to_resolved_resolves_reported_market() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn admin_move_market_to_resolved_resolves_disputed_market() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let end = 33; simple_create_categorical_market( base_asset, @@ -159,11 +156,11 @@ fn admin_move_market_to_resolved_resolves_disputed_market() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -175,7 +172,7 @@ fn admin_move_market_to_resolved_fails_if_market_is_not_reported_or_disputed( ) { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..33, ScoringRule::AmmCdaHybrid, diff --git a/zrml/prediction-markets/src/tests/approve_market.rs b/zrml/prediction-markets/src/tests/approve_market.rs index 6eabd8566..6405e59db 100644 --- a/zrml/prediction-markets/src/tests/approve_market.rs +++ b/zrml/prediction-markets/src/tests/approve_market.rs @@ -30,7 +30,7 @@ use sp_runtime::DispatchError; fn fails_if_market_status_is_not_proposed(market_status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -54,7 +54,7 @@ fn fails_if_market_status_is_not_proposed(market_status: MarketStatus) { fn it_allows_advisory_origin_to_approve_markets() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -84,7 +84,7 @@ fn market_with_edit_request_cannot_be_approved() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -113,7 +113,7 @@ fn market_with_edit_request_cannot_be_approved() { #[test] fn approve_market_correctly_unreserves_advisory_bond() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), @@ -141,31 +141,10 @@ fn approve_market_correctly_unreserves_advisory_bond() { assert!(market.bonds.creation.unwrap().is_settled); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); - }); -} - -#[test] -fn does_trigger_market_transition_api() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - simple_create_categorical_market( - BaseAsset::Ztg, - MarketCreation::Advised, - 1..2, - ScoringRule::AmmCdaHybrid, - ); - assert_ok!(PredictionMarkets::approve_market( - RuntimeOrigin::signed(ApproveOrigin::get()), - 0 - )); - assert!(StateTransitionMock::on_activation_triggered()); + test(Asset::ForeignAsset(100)); }); } diff --git a/zrml/prediction-markets/src/tests/buy_complete_set.rs b/zrml/prediction-markets/src/tests/buy_complete_set.rs index 68b551cd1..71f51caa0 100644 --- a/zrml/prediction-markets/src/tests/buy_complete_set.rs +++ b/zrml/prediction-markets/src/tests/buy_complete_set.rs @@ -21,7 +21,7 @@ use test_case::test_case; #[test] fn buy_complete_set_works() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Permissionless, @@ -42,27 +42,24 @@ fn buy_complete_set_works() { let assets = market.outcome_assets(); for asset in assets.iter() { - let bal = AssetManager::free_balance((*asset).into(), &who); + let bal = Tokens::free_balance(*asset, &who); assert_eq!(bal, amount); } - let bal = AssetManager::free_balance(base_asset.into(), &who); + let bal = AssetManager::free_balance(base_asset, &who); assert_eq!(bal, 1_000 * BASE - amount); let market_account = PredictionMarkets::market_account(market_id); - let market_bal = AssetManager::free_balance(base_asset.into(), &market_account); + let market_bal = AssetManager::free_balance(base_asset, &market_account); assert_eq!(market_bal, amount); System::assert_last_event(Event::BoughtCompleteSet(market_id, amount, who).into()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -70,7 +67,7 @@ fn buy_complete_set_works() { fn buy_complete_fails_on_zero_amount() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -84,7 +81,7 @@ fn buy_complete_fails_on_zero_amount() { #[test] fn buy_complete_set_fails_on_insufficient_balance() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Permissionless, @@ -97,14 +94,11 @@ fn buy_complete_set_fails_on_insufficient_balance() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -116,7 +110,7 @@ fn buy_complete_set_fails_on_insufficient_balance() { fn buy_complete_set_fails_if_market_is_not_active(status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -137,7 +131,7 @@ fn buy_complete_set_fails_if_market_is_not_active(status: MarketStatus) { fn buy_complete_set_fails_if_market_has_wrong_scoring_rule(scoring_rule: ScoringRule) { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, scoring_rule, diff --git a/zrml/prediction-markets/src/tests/close_market.rs b/zrml/prediction-markets/src/tests/close_trusted_market.rs similarity index 91% rename from zrml/prediction-markets/src/tests/close_market.rs rename to zrml/prediction-markets/src/tests/close_trusted_market.rs index 2fc116d0a..bdd5537b8 100644 --- a/zrml/prediction-markets/src/tests/close_market.rs +++ b/zrml/prediction-markets/src/tests/close_trusted_market.rs @@ -30,7 +30,7 @@ fn close_trusted_market_works() { let market_creator = ALICE; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(market_creator), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -80,7 +80,7 @@ fn fails_if_caller_is_not_market_creator() { let market_creator = ALICE; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(market_creator), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -110,7 +110,7 @@ fn close_trusted_market_fails_if_not_trusted() { let market_creator = ALICE; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(market_creator), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -156,7 +156,7 @@ fn close_trusted_market_fails_if_invalid_market_state(status: MarketStatus) { let market_creator = ALICE; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(market_creator), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -197,18 +197,3 @@ fn fails_if_market_is_not_found() { ); }); } - -#[test] -fn does_trigger_market_transition_api_permissionless() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - simple_create_categorical_market( - BaseAsset::Ztg, - MarketCreation::Permissionless, - 1..2, - ScoringRule::AmmCdaHybrid, - ); - assert_ok!(PredictionMarkets::close_market(&0)); - assert!(StateTransitionMock::on_closure_triggered()); - }); -} diff --git a/zrml/prediction-markets/src/tests/create_market.rs b/zrml/prediction-markets/src/tests/create_market.rs index bb2baf79d..2dd3c407c 100644 --- a/zrml/prediction-markets/src/tests/create_market.rs +++ b/zrml/prediction-markets/src/tests/create_market.rs @@ -44,7 +44,7 @@ fn fails_if_user_cannot_afford_bonds_advised( assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(creator), - BaseAsset::Ztg, + Asset::Ztg, ::MaxCreatorFee::get(), BOB, MarketPeriod::Block(123..456), @@ -67,7 +67,7 @@ fn fails_on_fee_too_high() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, ::MaxCreatorFee::get() + one_billionth, BOB, MarketPeriod::Block(123..456), @@ -93,7 +93,7 @@ fn fails_on_invalid_multihash() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, ::MaxCreatorFee::get(), BOB, MarketPeriod::Block(123..456), @@ -116,7 +116,7 @@ fn create_scalar_market_fails_on_invalid_range(range: RangeInclusive) { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -143,7 +143,7 @@ fn create_market_fails_on_min_dispute_period() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -170,7 +170,7 @@ fn create_market_fails_on_min_oracle_duration() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -197,7 +197,7 @@ fn create_market_fails_on_max_dispute_period() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -224,7 +224,7 @@ fn create_market_fails_on_max_grace_period() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -251,7 +251,7 @@ fn create_market_fails_on_max_oracle_duration() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -283,7 +283,7 @@ fn create_market_with_foreign_assets() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(420), + Asset::ForeignAsset(420), Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -300,7 +300,7 @@ fn create_market_with_foreign_assets() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(50), + Asset::ForeignAsset(50), Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -316,7 +316,7 @@ fn create_market_with_foreign_assets() { // As per Mock asset_registry genesis ForeignAsset(100) has allow_as_base_asset set to true. assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(100), + Asset::ForeignAsset(100), Perbill::zero(), BOB, MarketPeriod::Block(123..456), @@ -328,7 +328,7 @@ fn create_market_with_foreign_assets() { ScoringRule::AmmCdaHybrid, )); let market = MarketCommons::market(&0).unwrap(); - assert_eq!(market.base_asset, BaseAsset::ForeignAsset(100)); + assert_eq!(market.base_asset, Asset::ForeignAsset(100)); }); } @@ -338,7 +338,7 @@ fn it_does_not_create_market_with_too_few_categories() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..100), @@ -360,7 +360,7 @@ fn it_does_not_create_market_with_too_many_categories() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..100), @@ -389,7 +389,7 @@ fn create_categorical_market_fails_if_market_period_is_invalid( assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, period, @@ -413,7 +413,7 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end_block), @@ -431,7 +431,7 @@ fn create_categorical_market_fails_if_end_is_not_far_enough_ahead() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..end_time), @@ -460,7 +460,7 @@ fn create_market_succeeds_if_market_duration_is_maximal_in_blocks() { ); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(start..end), @@ -488,7 +488,7 @@ fn create_market_suceeds_if_market_duration_is_maximal_in_moments() { ); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(start..end), @@ -516,7 +516,7 @@ fn create_market_fails_if_market_duration_is_too_long_in_blocks() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(start..end), @@ -547,7 +547,7 @@ fn create_market_fails_if_market_duration_is_too_long_in_moments() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(start..end), @@ -611,7 +611,7 @@ fn create_market_sets_the_correct_market_parameters_and_reserves_the_correct_amo let creator_fee = Perbill::from_parts(1); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(creator), - BaseAsset::Ztg, + Asset::Ztg, creator_fee, oracle, period.clone(), @@ -646,7 +646,7 @@ fn create_market_fails_on_trusted_market_with_non_zero_dispute_period() { assert_noop!( PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(1..2), @@ -670,7 +670,7 @@ fn create_market_fails_on_trusted_market_with_non_zero_dispute_period() { fn create_categorical_market_deposits_the_correct_event() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 1..2, ScoringRule::AmmCdaHybrid, @@ -686,7 +686,7 @@ fn create_categorical_market_deposits_the_correct_event() { fn create_scalar_market_deposits_the_correct_event() { ExtBuilder::default().build().execute_with(|| { simple_create_scalar_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 1..2, ScoringRule::AmmCdaHybrid, @@ -697,31 +697,3 @@ fn create_scalar_market_deposits_the_correct_event() { System::assert_last_event(Event::MarketCreated(0, market_account, market).into()); }); } - -#[test] -fn does_trigger_market_transition_api() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - simple_create_categorical_market( - BaseAsset::Ztg, - MarketCreation::Advised, - 1..2, - ScoringRule::AmmCdaHybrid, - ); - assert!(StateTransitionMock::on_proposal_triggered()); - }); -} - -#[test] -fn does_trigger_market_transition_api_permissionless() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - simple_create_categorical_market( - BaseAsset::Ztg, - MarketCreation::Permissionless, - 1..2, - ScoringRule::AmmCdaHybrid, - ); - assert!(StateTransitionMock::on_activation_triggered()); - }); -} diff --git a/zrml/prediction-markets/src/tests/create_market_and_deploy_pool.rs b/zrml/prediction-markets/src/tests/create_market_and_deploy_pool.rs index a87cb2dc5..82087b6e2 100644 --- a/zrml/prediction-markets/src/tests/create_market_and_deploy_pool.rs +++ b/zrml/prediction-markets/src/tests/create_market_and_deploy_pool.rs @@ -45,7 +45,7 @@ fn create_market_and_deploy_pool_works() { let market_id = 0; assert_ok!(PredictionMarkets::create_market_and_deploy_pool( RuntimeOrigin::signed(creator), - BaseAsset::Ztg, + Asset::Ztg, creator_fee, oracle, period.clone(), diff --git a/zrml/prediction-markets/src/tests/dispute.rs b/zrml/prediction-markets/src/tests/dispute.rs index b762eb548..20627b9c4 100644 --- a/zrml/prediction-markets/src/tests/dispute.rs +++ b/zrml/prediction-markets/src/tests/dispute.rs @@ -31,7 +31,7 @@ fn it_allows_to_dispute_the_outcome_of_a_market() { ExtBuilder::default().build().execute_with(|| { let end = 2; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -76,7 +76,7 @@ fn dispute_fails_disputed_already() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -117,7 +117,7 @@ fn dispute_fails_if_market_not_reported() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -152,7 +152,7 @@ fn dispute_reserves_dispute_bond() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -198,7 +198,7 @@ fn dispute_updates_market() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -245,7 +245,7 @@ fn dispute_emits_event() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -287,7 +287,7 @@ fn dispute_fails_unless_reported_or_disputed_market(status: MarketStatus) { ExtBuilder::default().build().execute_with(|| { // Creates a permissionless market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -304,34 +304,3 @@ fn dispute_fails_unless_reported_or_disputed_market(status: MarketStatus) { ); }); } - -#[test] -fn does_trigger_market_transition_api() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - let end = 2; - simple_create_categorical_market( - BaseAsset::Ztg, - MarketCreation::Permissionless, - 0..end, - ScoringRule::AmmCdaHybrid, - ); - - // Run to the end of the trading phase. - let market = MarketCommons::market(&0).unwrap(); - let grace_period = end + market.deadlines.grace_period; - run_to_block(grace_period + 1); - - assert_ok!(PredictionMarkets::report( - RuntimeOrigin::signed(BOB), - 0, - OutcomeReport::Categorical(1) - )); - - let dispute_at = grace_period + 2; - run_to_block(dispute_at); - - assert_ok!(PredictionMarkets::dispute(RuntimeOrigin::signed(CHARLIE), 0)); - assert!(StateTransitionMock::on_dispute_triggered()); - }); -} diff --git a/zrml/prediction-markets/src/tests/dispute_early_close.rs b/zrml/prediction-markets/src/tests/dispute_early_close.rs index d5f75802f..9043c44e9 100644 --- a/zrml/prediction-markets/src/tests/dispute_early_close.rs +++ b/zrml/prediction-markets/src/tests/dispute_early_close.rs @@ -30,7 +30,7 @@ fn dispute_early_close_emits_event() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -55,7 +55,7 @@ fn dispute_early_close_from_market_creator_works() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -129,7 +129,7 @@ fn dispute_early_close_fails_if_scheduled_as_sudo() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -162,7 +162,7 @@ fn dispute_early_close_fails_if_already_disputed() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -200,7 +200,7 @@ fn dispute_early_close_fails_if_already_rejected() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -243,7 +243,7 @@ fn settles_early_close_bonds_with_resolution_in_state_disputed() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -306,7 +306,7 @@ fn settles_early_close_bonds_with_resolution_in_state_scheduled_as_market_creato let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -354,7 +354,7 @@ fn schedule_early_close_disputed_sudo_schedule_and_settle_bonds() { let old_period = MarketPeriod::Block(0..end); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, old_period.clone(), diff --git a/zrml/prediction-markets/src/tests/edit_market.rs b/zrml/prediction-markets/src/tests/edit_market.rs index a1d5d3e93..553289ab7 100644 --- a/zrml/prediction-markets/src/tests/edit_market.rs +++ b/zrml/prediction-markets/src/tests/edit_market.rs @@ -29,7 +29,7 @@ use crate::MarketIdsForEdit; fn only_creator_can_edit_market() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -54,7 +54,7 @@ fn only_creator_can_edit_market() { assert_noop!( PredictionMarkets::edit_market( RuntimeOrigin::signed(BOB), - BaseAsset::Ztg, + Asset::Ztg, 0, CHARLIE, MarketPeriod::Block(0..2), @@ -73,7 +73,7 @@ fn only_creator_can_edit_market() { fn edit_cycle_for_proposed_markets() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 2..4, ScoringRule::AmmCdaHybrid, @@ -97,7 +97,7 @@ fn edit_cycle_for_proposed_markets() { // After this edit its changed to ALICE assert_ok!(PredictionMarkets::edit_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, 0, CHARLIE, MarketPeriod::Block(2..4), @@ -122,7 +122,7 @@ fn edit_market_with_foreign_asset() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -148,7 +148,7 @@ fn edit_market_with_foreign_asset() { assert_noop!( PredictionMarkets::edit_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(50), + Asset::ForeignAsset(50), 0, CHARLIE, MarketPeriod::Block(0..2), @@ -164,7 +164,7 @@ fn edit_market_with_foreign_asset() { assert_noop!( PredictionMarkets::edit_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(420), + Asset::ForeignAsset(420), 0, CHARLIE, MarketPeriod::Block(0..2), @@ -179,7 +179,7 @@ fn edit_market_with_foreign_asset() { // As per Mock asset_registry genesis ForeignAsset(100) has allow_as_base_asset set to true. assert_ok!(PredictionMarkets::edit_market( RuntimeOrigin::signed(ALICE), - BaseAsset::ForeignAsset(100), + Asset::ForeignAsset(100), 0, CHARLIE, MarketPeriod::Block(0..2), @@ -190,6 +190,6 @@ fn edit_market_with_foreign_asset() { ScoringRule::AmmCdaHybrid )); let market = MarketCommons::market(&0).unwrap(); - assert_eq!(market.base_asset, BaseAsset::ForeignAsset(100)); + assert_eq!(market.base_asset, Asset::ForeignAsset(100)); }); } diff --git a/zrml/prediction-markets/src/tests/integration.rs b/zrml/prediction-markets/src/tests/integration.rs index 4ea7749ff..48e1a0db3 100644 --- a/zrml/prediction-markets/src/tests/integration.rs +++ b/zrml/prediction-markets/src/tests/integration.rs @@ -33,7 +33,7 @@ use zrml_global_disputes::{ #[test] fn it_appeals_a_court_market_to_global_dispute() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let mut free_before = BTreeMap::new(); let jurors = 1000..(1000 + ::MaxSelectedDraws::get() as u128); @@ -128,14 +128,11 @@ fn it_appeals_a_court_market_to_global_dispute() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -145,7 +142,7 @@ fn the_entire_market_lifecycle_works_with_timestamps() { // Creates a permissionless market. assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -182,7 +179,7 @@ fn the_entire_market_lifecycle_works_with_timestamps() { #[test] fn full_scalar_market_lifecycle() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), base_asset, @@ -208,9 +205,10 @@ fn full_scalar_market_lifecycle() { let assets = market.outcome_assets(); assert_eq!(assets.len(), 2); for asset in assets.iter() { - let bal = AssetManager::free_balance((*asset).into(), &CHARLIE); + let bal = Tokens::free_balance(*asset, &CHARLIE); assert_eq!(bal, 100 * BASE); } + let market = MarketCommons::market(&0).unwrap(); set_timestamp_for_on_initialize(100_000_000); let report_at = 2; @@ -250,7 +248,7 @@ fn full_scalar_market_lifecycle() { assert_eq!(disputes.len(), 0); // give EVE some shares - assert_ok!(AssetManager::transfer( + assert_ok!(Tokens::transfer( RuntimeOrigin::signed(CHARLIE), EVE, Asset::ScalarOutcome(0, ScalarPosition::Short), @@ -258,19 +256,19 @@ fn full_scalar_market_lifecycle() { )); assert_eq!( - AssetManager::free_balance(Asset::ScalarOutcome(0, ScalarPosition::Short), &CHARLIE), + Tokens::free_balance(Asset::ScalarOutcome(0, ScalarPosition::Short), &CHARLIE), 50 * BASE ); assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); for asset in assets.iter() { - let bal = AssetManager::free_balance((*asset).into(), &CHARLIE); + let bal = Tokens::free_balance(*asset, &CHARLIE); assert_eq!(bal, 0); } // check payouts is right for each CHARLIE and EVE - let base_asset_bal_charlie = AssetManager::free_balance(base_asset.into(), &CHARLIE); - let base_asset_bal_eve = AssetManager::free_balance(base_asset.into(), &EVE); + 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( @@ -295,7 +293,7 @@ fn full_scalar_market_lifecycle() { ); assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(EVE), 0)); - let base_asset_bal_eve_after = AssetManager::free_balance(base_asset.into(), &EVE); + 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( @@ -309,21 +307,18 @@ fn full_scalar_market_lifecycle() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn authorized_correctly_resolves_disputed_market() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), @@ -349,14 +344,14 @@ fn authorized_correctly_resolves_disputed_market() { OutcomeReport::Categorical(0) )); - let charlie_balance = AssetManager::free_balance(base_asset.into(), &CHARLIE); + 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(RuntimeOrigin::signed(CHARLIE), 0,)); - if base_asset == BaseAsset::Ztg { + if base_asset == Asset::Ztg { let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); assert_eq!( charlie_balance, @@ -365,7 +360,7 @@ fn authorized_correctly_resolves_disputed_market() { } 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.into(), &CHARLIE); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); assert_eq!(charlie_balance, 1_000 * BASE - CENT); } @@ -393,7 +388,7 @@ fn authorized_correctly_resolves_disputed_market() { ); assert_eq!(market_ids_1.len(), 1); - if base_asset == BaseAsset::Ztg { + if base_asset == Asset::Ztg { let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); assert_eq!( charlie_balance, @@ -402,7 +397,7 @@ fn authorized_correctly_resolves_disputed_market() { } 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.into(), &CHARLIE); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); assert_eq!(charlie_balance, 1_000 * BASE - CENT); } @@ -411,7 +406,7 @@ fn authorized_correctly_resolves_disputed_market() { let market_after = MarketCommons::market(&0).unwrap(); assert_eq!(market_after.status, MarketStatus::Disputed); - if base_asset == BaseAsset::Ztg { + if base_asset == Asset::Ztg { let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); assert_eq!( charlie_balance, @@ -420,13 +415,13 @@ fn authorized_correctly_resolves_disputed_market() { } 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.into(), &CHARLIE); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); assert_eq!(charlie_balance, 1_000 * BASE - CENT); } run_blocks(1); - if base_asset == BaseAsset::Ztg { + if base_asset == Asset::Ztg { let charlie_balance = AssetManager::free_balance(Asset::Ztg, &CHARLIE); assert_eq!( charlie_balance, @@ -435,7 +430,7 @@ fn authorized_correctly_resolves_disputed_market() { } 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.into(), &CHARLIE); + let charlie_balance = AssetManager::free_balance(base_asset, &CHARLIE); assert_eq!(charlie_balance, 1_000 * BASE - CENT); } @@ -446,13 +441,13 @@ fn authorized_correctly_resolves_disputed_market() { assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(CHARLIE), 0)); - if base_asset == BaseAsset::Ztg { + 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.into(), &CHARLIE); + 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); @@ -470,20 +465,17 @@ fn authorized_correctly_resolves_disputed_market() { assert!(market_after.bonds.oracle.unwrap().is_settled); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn it_resolves_a_disputed_court_market() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let juror_0 = 1000; let juror_1 = 1001; let juror_2 = 1002; @@ -709,18 +701,18 @@ fn it_resolves_a_disputed_court_market() { assert_eq!(free_juror_2_after, free_juror_2_before + juror_2_share * total_slashed); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn outsider_reports_wrong_outcome() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; @@ -795,13 +787,10 @@ fn outsider_reports_wrong_outcome() { assert_eq!(Balances::free_balance(DAVE), dave_balance_before + outcome_bond); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } diff --git a/zrml/prediction-markets/src/tests/manually_close_market.rs b/zrml/prediction-markets/src/tests/manually_close_market.rs index 8af1ee78c..b88cab214 100644 --- a/zrml/prediction-markets/src/tests/manually_close_market.rs +++ b/zrml/prediction-markets/src/tests/manually_close_market.rs @@ -36,7 +36,7 @@ fn manually_close_market_after_long_stall() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -49,7 +49,7 @@ fn manually_close_market_after_long_stall() { )); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -105,7 +105,7 @@ fn manually_close_market_fails_if_market_not_in_close_time_frame_list() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -146,7 +146,7 @@ fn manually_close_market_fails_if_not_allowed_for_block_based_markets() { let end = 5; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Block(0..end), diff --git a/zrml/prediction-markets/src/tests/mod.rs b/zrml/prediction-markets/src/tests/mod.rs index da264b1f9..5954a1561 100644 --- a/zrml/prediction-markets/src/tests/mod.rs +++ b/zrml/prediction-markets/src/tests/mod.rs @@ -22,7 +22,7 @@ mod admin_move_market_to_closed; mod admin_move_market_to_resolved; mod approve_market; mod buy_complete_set; -mod close_market; +mod close_trusted_market; mod create_market; mod create_market_and_deploy_pool; mod dispute; @@ -42,20 +42,20 @@ mod schedule_early_close; mod sell_complete_set; mod start_global_dispute; -use crate::{mock::*, AccountIdOf, BalanceOf, Config, Error, Event, MarketIdsPerDisputeBlock}; -use core::ops::Range; -use frame_support::{ - assert_noop, assert_ok, storage::unhashed::get_or, traits::NamedReservableCurrency, +use crate::{ + mock::*, AccountIdOf, AssetOf, BalanceOf, Config, DeadlinesOf, Error, Event, + MarketIdsPerDisputeBlock, }; -use frame_system::pallet_prelude::BlockNumberFor; +use core::ops::Range; +use frame_support::{assert_noop, assert_ok, traits::NamedReservableCurrency}; use orml_traits::MultiCurrency; use sp_arithmetic::Perbill; use sp_runtime::traits::{BlakeTwo256, Hash, Zero}; use zeitgeist_primitives::{ constants::mock::{BASE, CENT}, types::{ - Asset, BaseAsset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketId, - MarketPeriod, MarketStatus, MarketType, MultiHash, OutcomeReport, ScoringRule, + Asset, Deadlines, MarketCreation, MarketDisputeMechanism, MarketId, MarketPeriod, + MarketStatus, MarketType, MultiHash, OutcomeReport, ScoringRule, }, }; use zrml_court::types::VoteItem; @@ -63,36 +63,7 @@ use zrml_market_commons::MarketCommonsPalletApi; const SENTINEL_AMOUNT: u128 = BASE; -impl StateTransitionMock { - pub(super) fn on_proposal_triggered() -> bool { - get_or(&ON_PROPOSAL_STORAGE, false) - } - pub(super) fn on_activation_triggered() -> bool { - get_or(&ON_ACTIVATION_STORAGE, false) - } - pub(super) fn on_closure_triggered() -> bool { - get_or(&ON_CLOSURE_STORAGE, false) - } - pub(super) fn on_report_triggered() -> bool { - get_or(&ON_REPORT_STORAGE, false) - } - pub(super) fn on_dispute_triggered() -> bool { - get_or(&ON_DISPUTE_STORAGE, false) - } - pub(super) fn on_resolution_triggered() -> bool { - get_or(&ON_RESOLUTION_STORAGE, false) - } - pub(super) fn ensure_empty_state() { - assert!(!StateTransitionMock::on_proposal_triggered()); - assert!(!StateTransitionMock::on_activation_triggered()); - assert!(!StateTransitionMock::on_closure_triggered()); - assert!(!StateTransitionMock::on_report_triggered()); - assert!(!StateTransitionMock::on_dispute_triggered()); - assert!(!StateTransitionMock::on_resolution_triggered()); - } -} - -fn get_deadlines() -> Deadlines> { +fn get_deadlines() -> DeadlinesOf { Deadlines { grace_period: 1_u32.into(), oracle_duration: ::MinOracleDuration::get(), @@ -108,7 +79,7 @@ fn gen_metadata(byte: u8) -> MultiHash { } fn simple_create_categorical_market( - base_asset: BaseAsset, + base_asset: AssetOf, creation: MarketCreation, period: Range, scoring_rule: ScoringRule, @@ -129,7 +100,7 @@ fn simple_create_categorical_market( } fn simple_create_scalar_market( - base_asset: BaseAsset, + base_asset: AssetOf, creation: MarketCreation, period: Range, scoring_rule: ScoringRule, diff --git a/zrml/prediction-markets/src/tests/on_initialize.rs b/zrml/prediction-markets/src/tests/on_initialize.rs index b8c5588c1..b78388fbf 100644 --- a/zrml/prediction-markets/src/tests/on_initialize.rs +++ b/zrml/prediction-markets/src/tests/on_initialize.rs @@ -31,7 +31,7 @@ fn on_initialize_skips_the_genesis_block() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), diff --git a/zrml/prediction-markets/src/tests/on_market_close.rs b/zrml/prediction-markets/src/tests/on_market_close.rs index 866797798..63054872c 100644 --- a/zrml/prediction-markets/src/tests/on_market_close.rs +++ b/zrml/prediction-markets/src/tests/on_market_close.rs @@ -24,7 +24,7 @@ use zeitgeist_primitives::constants::MILLISECS_PER_BLOCK; #[test] fn on_market_close_auto_rejects_expired_advised_market() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { // 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)); @@ -60,20 +60,17 @@ fn on_market_close_auto_rejects_expired_advised_market() { System::assert_has_event(Event::MarketExpired(market_id).into()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { // 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)); @@ -122,14 +119,11 @@ fn on_market_close_auto_rejects_expired_advised_market_with_edit_request() { System::assert_has_event(Event::MarketExpired(market_id).into()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -140,7 +134,7 @@ fn on_market_close_successfully_auto_closes_market_with_blocks() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Block(0..end), @@ -172,7 +166,7 @@ fn on_market_close_successfully_auto_closes_market_with_timestamps() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -212,7 +206,7 @@ fn on_market_close_successfully_auto_closes_multiple_markets_after_stall() { let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -225,7 +219,7 @@ fn on_market_close_successfully_auto_closes_multiple_markets_after_stall() { )); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -263,7 +257,7 @@ fn on_market_close_market_status_manager_exceeds_max_recovery_time_frames_after_ let category_count = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), @@ -276,7 +270,7 @@ fn on_market_close_market_status_manager_exceeds_max_recovery_time_frames_after_ )); assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), ALICE, MarketPeriod::Timestamp(0..end), diff --git a/zrml/prediction-markets/src/tests/on_resolution.rs b/zrml/prediction-markets/src/tests/on_resolution.rs index 08b965073..7e70a6730 100644 --- a/zrml/prediction-markets/src/tests/on_resolution.rs +++ b/zrml/prediction-markets/src/tests/on_resolution.rs @@ -27,7 +27,7 @@ fn it_correctly_resolves_a_market_that_was_reported_on() { ExtBuilder::default().build().execute_with(|| { let end = 2; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -58,21 +58,22 @@ fn it_correctly_resolves_a_market_that_was_reported_on() { // Check balance of winning outcome asset. let share_b = Asset::CategoricalOutcome(0, 1); - let share_b_total = AssetManager::total_issuance(share_b); + let share_b_total = Tokens::total_issuance(share_b); assert_eq!(share_b_total, CENT); - let share_b_bal = AssetManager::free_balance(share_b, &CHARLIE); + let share_b_bal = Tokens::free_balance(share_b, &CHARLIE); assert_eq!(share_b_bal, CENT); + // TODO(#792): Remove other assets. let share_a = Asset::CategoricalOutcome(0, 0); - let share_a_total = AssetManager::total_issuance(share_a); - assert_eq!(share_a_total, 0); - let share_a_bal = AssetManager::free_balance(share_a, &CHARLIE); - assert_eq!(share_a_bal, 0); + let share_a_total = Tokens::total_issuance(share_a); + assert_eq!(share_a_total, CENT); + let share_a_bal = Tokens::free_balance(share_a, &CHARLIE); + assert_eq!(share_a_bal, CENT); let share_c = Asset::CategoricalOutcome(0, 2); - let share_c_total = AssetManager::total_issuance(share_c); + let share_c_total = Tokens::total_issuance(share_c); assert_eq!(share_c_total, 0); - let share_c_bal = AssetManager::free_balance(share_c, &CHARLIE); + let share_c_bal = Tokens::free_balance(share_c, &CHARLIE); assert_eq!(share_c_bal, 0); assert!(market.bonds.creation.unwrap().is_settled); @@ -84,7 +85,7 @@ fn it_correctly_resolves_a_market_that_was_reported_on() { fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_market_on_oracle_report() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -121,14 +122,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma assert_eq!(Balances::free_balance(ALICE), alice_balance_before + OracleBond::get()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -136,7 +134,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_market_on_outsider_report() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -173,14 +171,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma assert_eq!(Balances::free_balance(ALICE), alice_balance_before); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -189,7 +184,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark { // Oracle reports in time but incorrect report, so OracleBond gets slashed on resolution // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -227,14 +222,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark assert_eq!(Balances::free_balance(ALICE), alice_balance_before + ValidityBond::get()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -243,7 +235,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma { // Oracle reports in time but incorrect report, so OracleBond gets slashed on resolution // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -285,14 +277,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_approved_advised_ma assert_eq!(Balances::free_balance(ALICE), alice_balance_before); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -301,7 +290,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark { // Oracle reports in time and correct report, so OracleBond does not get slashed on resolution // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -348,14 +337,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -364,7 +350,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma { // Oracle reports in time and correct report, so OracleBond does not get slashed on resolution // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -412,14 +398,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma assert_eq!(Balances::free_balance(ALICE), alice_balance_before + OracleBond::get()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -428,7 +411,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark { // Oracle does not report in time, so OracleBond gets slashed on resolution // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -487,14 +470,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -503,7 +483,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma { // Oracle does not report in time, so OracleBond gets slashed on resolution // NOTE: Bonds are always in ZTG - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -565,14 +545,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_advised_approved_ma ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -582,7 +559,7 @@ fn trusted_market_complete_lifecycle() { let end = 3; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -629,7 +606,7 @@ fn trusted_market_complete_lifecycle() { fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_on_oracle_report() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -663,14 +640,11 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -678,7 +652,7 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_market_on_outsider_report() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { reserve_sentinel_amounts(); let end = 100; assert_ok!(PredictionMarkets::create_market( @@ -737,42 +711,10 @@ fn on_resolution_correctly_reserves_and_unreserves_bonds_for_permissionless_mark assert!(market.bonds.outsider.unwrap().is_settled); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); - }); -} - -#[test] -fn does_trigger_market_transition_api() { - ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - let end = 3; - assert_ok!(PredictionMarkets::create_market( - RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, - Perbill::zero(), - BOB, - MarketPeriod::Block(0..end), - Deadlines { - grace_period: 0, - oracle_duration: ::MinOracleDuration::get(), - dispute_duration: Zero::zero(), - }, - gen_metadata(0x99), - MarketCreation::Permissionless, - MarketType::Categorical(3), - None, - ScoringRule::AmmCdaHybrid, - )); - run_to_block(end); - let outcome = OutcomeReport::Categorical(1); - assert_ok!(PredictionMarkets::report(RuntimeOrigin::signed(BOB), 0, outcome.clone())); - assert!(StateTransitionMock::on_resolution_triggered()); + test(Asset::ForeignAsset(100)); }); } diff --git a/zrml/prediction-markets/src/tests/redeem_shares.rs b/zrml/prediction-markets/src/tests/redeem_shares.rs index c71921add..f95511119 100644 --- a/zrml/prediction-markets/src/tests/redeem_shares.rs +++ b/zrml/prediction-markets/src/tests/redeem_shares.rs @@ -27,7 +27,7 @@ use zeitgeist_primitives::types::{OutcomeReport, ScalarPosition}; #[test] fn it_allows_to_redeem_shares() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let end = 2; simple_create_categorical_market( base_asset, @@ -58,20 +58,17 @@ fn it_allows_to_redeem_shares() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test_case(ScoringRule::Parimutuel; "parimutuel")] fn redeem_shares_fails_if_invalid_resolution_mechanism(scoring_rule: ScoringRule) { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { let end = 2; simple_create_categorical_market( base_asset, @@ -91,57 +88,48 @@ fn redeem_shares_fails_if_invalid_resolution_mechanism(scoring_rule: ScoringRule ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn scalar_market_correctly_resolves_on_out_of_range_outcomes_below_threshold() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { scalar_market_correctly_resolves_common(base_asset, 50); - assert_eq!(AssetManager::free_balance(base_asset.into(), &CHARLIE), 900 * BASE); - assert_eq!(AssetManager::free_balance(base_asset.into(), &EVE), 1100 * BASE); + 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(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test] fn scalar_market_correctly_resolves_on_out_of_range_outcomes_above_threshold() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { scalar_market_correctly_resolves_common(base_asset, 250); - assert_eq!(AssetManager::free_balance(base_asset.into(), &CHARLIE), 1000 * BASE); - assert_eq!(AssetManager::free_balance(base_asset.into(), &EVE), 1000 * BASE); + 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(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } // Common code of `scalar_market_correctly_resolves_*` -fn scalar_market_correctly_resolves_common(base_asset: BaseAsset, reported_value: u128) { +fn scalar_market_correctly_resolves_common(base_asset: AssetOf, reported_value: u128) { let end = 100; simple_create_scalar_market( base_asset, @@ -150,7 +138,7 @@ fn scalar_market_correctly_resolves_common(base_asset: BaseAsset, reported_value ScoringRule::AmmCdaHybrid, ); assert_ok!(PredictionMarkets::buy_complete_set(RuntimeOrigin::signed(CHARLIE), 0, 100 * BASE)); - assert_ok!(AssetManager::transfer( + assert_ok!(Tokens::transfer( RuntimeOrigin::signed(CHARLIE), EVE, Asset::ScalarOutcome(0, ScalarPosition::Short), @@ -179,15 +167,15 @@ fn scalar_market_correctly_resolves_common(base_asset: BaseAsset, reported_value // Check balances before redeeming (just to make sure that our tests are based on correct // assumptions)! - assert_eq!(AssetManager::free_balance(base_asset.into(), &CHARLIE), 900 * BASE); - assert_eq!(AssetManager::free_balance(base_asset.into(), &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(RuntimeOrigin::signed(CHARLIE), 0)); assert_ok!(PredictionMarkets::redeem_shares(RuntimeOrigin::signed(EVE), 0)); let market = &MarketCommons::market(&0).unwrap(); let assets = market.outcome_assets(); for asset in assets.iter() { - assert_eq!(AssetManager::free_balance((*asset).into(), &CHARLIE), 0); - assert_eq!(AssetManager::free_balance((*asset).into(), &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/tests/reject_early_close.rs b/zrml/prediction-markets/src/tests/reject_early_close.rs index e4b0de19c..fc40098c6 100644 --- a/zrml/prediction-markets/src/tests/reject_early_close.rs +++ b/zrml/prediction-markets/src/tests/reject_early_close.rs @@ -29,7 +29,7 @@ fn reject_early_close_emits_event() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -58,7 +58,7 @@ fn reject_early_close_fails_if_state_is_scheduled_as_market_creator() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -89,7 +89,7 @@ fn reject_early_close_fails_if_state_is_rejected() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -126,7 +126,7 @@ fn reject_early_close_resets_to_old_market_period() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -170,7 +170,7 @@ fn reject_early_close_settles_bonds() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), diff --git a/zrml/prediction-markets/src/tests/reject_market.rs b/zrml/prediction-markets/src/tests/reject_market.rs index 3af2f2a74..462d794df 100644 --- a/zrml/prediction-markets/src/tests/reject_market.rs +++ b/zrml/prediction-markets/src/tests/reject_market.rs @@ -27,7 +27,7 @@ use crate::{MarketIdsForEdit, MarketIdsPerCloseBlock}; fn it_allows_the_advisory_origin_to_reject_markets() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 4..6, ScoringRule::AmmCdaHybrid, @@ -58,7 +58,7 @@ fn reject_errors_if_reject_reason_is_too_long() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -86,7 +86,7 @@ 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( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, @@ -122,7 +122,7 @@ fn it_allows_the_advisory_origin_to_reject_markets_with_edit_request() { #[test] fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { // NOTE: Bonds are always in ZTG, irrespective of base_asset. - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Advised, @@ -179,14 +179,11 @@ fn reject_market_unreserves_oracle_bond_and_slashes_advisory_bond() { assert_eq!(balance_treasury_after, slash_amount_advisory_bond); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -196,19 +193,19 @@ fn reject_market_clears_auto_close_blocks() { // can not be deployed on pending advised pools. ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 33..66, ScoringRule::AmmCdaHybrid, ); simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 22..66, ScoringRule::AmmCdaHybrid, ); simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 22..33, ScoringRule::AmmCdaHybrid, @@ -232,7 +229,7 @@ fn reject_market_fails_on_permissionless_market() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -255,7 +252,7 @@ fn reject_market_fails_on_approved_market() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, diff --git a/zrml/prediction-markets/src/tests/report.rs b/zrml/prediction-markets/src/tests/report.rs index 34f5e72d6..0cd5fe807 100644 --- a/zrml/prediction-markets/src/tests/report.rs +++ b/zrml/prediction-markets/src/tests/report.rs @@ -18,7 +18,6 @@ use super::*; -use test_case::test_case; use zeitgeist_primitives::{constants::MILLISECS_PER_BLOCK, types::OutcomeReport}; // TODO(#1239) MarketDoesNotExist @@ -33,7 +32,7 @@ fn it_allows_to_report_the_outcome_of_a_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -66,7 +65,7 @@ fn report_fails_before_grace_period_is_over() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -92,7 +91,7 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -134,7 +133,7 @@ fn it_allows_only_oracle_to_report_the_outcome_of_a_market_during_oracle_duratio ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -175,7 +174,7 @@ fn report_fails_on_mismatched_outcome_for_categorical_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -198,7 +197,7 @@ fn report_fails_on_out_of_range_outcome_for_categorical_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -221,7 +220,7 @@ fn report_fails_on_mismatched_outcome_for_scalar_market() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_scalar_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -244,7 +243,7 @@ fn it_allows_anyone_to_report_an_unreported_market() { ExtBuilder::default().build().execute_with(|| { let end = 2; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -282,7 +281,7 @@ fn report_fails_on_market_state_proposed() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -305,7 +304,7 @@ fn report_fails_on_market_state_closed_for_advised_market() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -328,7 +327,7 @@ fn report_fails_on_market_state_active() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -351,7 +350,7 @@ fn report_fails_on_market_state_resolved() { ExtBuilder::default().build().execute_with(|| { assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(0..100_000_000), @@ -373,38 +372,35 @@ fn report_fails_on_market_state_resolved() { }); } -#[test_case(Some(MarketDisputeMechanism::SimpleDisputes); "with_dispute_mechanism")] -#[test_case(None; "without_dispute_mechanism")] -fn does_trigger_market_transition_api(dispute_mechanism: Option) { +#[test] +fn report_fails_if_reporter_is_not_the_oracle() { ExtBuilder::default().build().execute_with(|| { - StateTransitionMock::ensure_empty_state(); - let mut deadlines = get_deadlines(); - - if dispute_mechanism.is_none() { - deadlines.dispute_duration = Zero::zero(); - } - assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, - MarketPeriod::Block(0..2), - deadlines, + MarketPeriod::Timestamp(0..100_000_000), + get_deadlines(), gen_metadata(2), MarketCreation::Permissionless, MarketType::Categorical(2), - dispute_mechanism, + Some(MarketDisputeMechanism::SimpleDisputes), ScoringRule::AmmCdaHybrid, )); - let market = MarketCommons::market(&0).unwrap(); - run_to_block(2 + market.deadlines.grace_period + market.deadlines.oracle_duration + 1); - assert_ok!(PredictionMarkets::report( - RuntimeOrigin::signed(BOB), - 0, - OutcomeReport::Categorical(1) - )); - assert!(StateTransitionMock::on_report_triggered()); + set_timestamp_for_on_initialize(100_000_000); + // Trigger hooks which close the market. + run_to_block(2); + 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( + RuntimeOrigin::signed(CHARLIE), + 0, + OutcomeReport::Categorical(1) + ), + Error::::ReporterNotOracle, + ); }); } diff --git a/zrml/prediction-markets/src/tests/request_edit.rs b/zrml/prediction-markets/src/tests/request_edit.rs index 3736f06c9..fb09532a1 100644 --- a/zrml/prediction-markets/src/tests/request_edit.rs +++ b/zrml/prediction-markets/src/tests/request_edit.rs @@ -27,7 +27,7 @@ use sp_runtime::DispatchError; fn it_allows_request_edit_origin_to_request_edits_for_markets() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 2..4, ScoringRule::AmmCdaHybrid, @@ -68,7 +68,7 @@ fn request_edit_fails_on_bad_origin() { frame_system::Pallet::::set_block_number(1); // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 2..4, ScoringRule::AmmCdaHybrid, @@ -92,7 +92,7 @@ fn edit_request_fails_if_edit_reason_is_too_long() { ExtBuilder::default().build().execute_with(|| { // Creates an advised market. simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Advised, 0..2, ScoringRule::AmmCdaHybrid, diff --git a/zrml/prediction-markets/src/tests/schedule_early_close.rs b/zrml/prediction-markets/src/tests/schedule_early_close.rs index 3709df23e..2e3886235 100644 --- a/zrml/prediction-markets/src/tests/schedule_early_close.rs +++ b/zrml/prediction-markets/src/tests/schedule_early_close.rs @@ -36,7 +36,7 @@ fn schedule_early_close_emits_event() { ExtBuilder::default().build().execute_with(|| { let end = 100; simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..end, ScoringRule::AmmCdaHybrid, @@ -71,7 +71,7 @@ fn sudo_schedule_early_close_at_block_works() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -143,7 +143,7 @@ fn sudo_schedule_early_close_at_timeframe_works() { let end = start + (42 * MILLISECS_PER_BLOCK) as u64; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(start..end), @@ -213,7 +213,7 @@ fn schedule_early_close_block_fails_if_early_close_request_too_late() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), @@ -245,7 +245,7 @@ fn schedule_early_close_timestamp_fails_if_early_close_request_too_late() { let end = start + (42 * MILLISECS_PER_BLOCK) as u64; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Timestamp(start..end), @@ -274,7 +274,7 @@ fn schedule_early_close_as_market_creator_works() { let end = 100; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..end), diff --git a/zrml/prediction-markets/src/tests/sell_complete_set.rs b/zrml/prediction-markets/src/tests/sell_complete_set.rs index a2ed720b2..899b3f3c0 100644 --- a/zrml/prediction-markets/src/tests/sell_complete_set.rs +++ b/zrml/prediction-markets/src/tests/sell_complete_set.rs @@ -23,7 +23,7 @@ use test_case::test_case; #[test_case(ScoringRule::AmmCdaHybrid)] fn sell_complete_set_works(scoring_rule: ScoringRule) { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Permissionless, @@ -51,24 +51,21 @@ fn sell_complete_set_works(scoring_rule: ScoringRule) { let market = MarketCommons::market(&market_id).unwrap(); let assets = market.outcome_assets(); for asset in assets.iter() { - let bal = AssetManager::free_balance((*asset).into(), &who); + let bal = AssetManager::free_balance(*asset, &who); assert_eq!(bal, expected_amount); } - let bal = AssetManager::free_balance(base_asset.into(), &who); + let bal = AssetManager::free_balance(base_asset, &who); assert_eq!(bal, 1_000 * BASE - expected_amount); System::assert_last_event(Event::SoldCompleteSet(market_id, sell_amount, who).into()); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } @@ -76,7 +73,7 @@ fn sell_complete_set_works(scoring_rule: ScoringRule) { fn sell_complete_set_fails_on_zero_amount() { ExtBuilder::default().build().execute_with(|| { simple_create_categorical_market( - BaseAsset::Ztg, + Asset::Ztg, MarketCreation::Permissionless, 0..2, ScoringRule::AmmCdaHybrid, @@ -90,7 +87,7 @@ fn sell_complete_set_fails_on_zero_amount() { #[test] fn sell_complete_set_fails_on_insufficient_share_balance() { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Permissionless, @@ -112,20 +109,17 @@ fn sell_complete_set_fails_on_insufficient_share_balance() { ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } #[test_case(ScoringRule::Parimutuel; "parimutuel")] fn sell_complete_set_fails_if_market_has_wrong_scoring_rule(scoring_rule: ScoringRule) { - let test = |base_asset: BaseAsset| { + let test = |base_asset: AssetOf| { simple_create_categorical_market( base_asset, MarketCreation::Permissionless, @@ -138,13 +132,10 @@ fn sell_complete_set_fails_if_market_has_wrong_scoring_rule(scoring_rule: Scorin ); }; ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::CampaignAsset(100)); - }); - ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::Ztg); + test(Asset::Ztg); }); #[cfg(feature = "parachain")] ExtBuilder::default().build().execute_with(|| { - test(BaseAsset::ForeignAsset(100)); + test(Asset::ForeignAsset(100)); }); } diff --git a/zrml/prediction-markets/src/tests/start_global_dispute.rs b/zrml/prediction-markets/src/tests/start_global_dispute.rs index b87ed6ac8..2ed871296 100644 --- a/zrml/prediction-markets/src/tests/start_global_dispute.rs +++ b/zrml/prediction-markets/src/tests/start_global_dispute.rs @@ -33,7 +33,7 @@ fn start_global_dispute_fails_on_wrong_mdm() { let end = 2; assert_ok!(PredictionMarkets::create_market( RuntimeOrigin::signed(ALICE), - BaseAsset::Ztg, + Asset::Ztg, Perbill::zero(), BOB, MarketPeriod::Block(0..2), diff --git a/zrml/prediction-markets/src/weights.rs b/zrml/prediction-markets/src/weights.rs index 5ac4c5a91..41e2737fc 100644 --- a/zrml/prediction-markets/src/weights.rs +++ b/zrml/prediction-markets/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_prediction_markets //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -89,736 +89,688 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_prediction_markets (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 63]`. fn admin_move_market_to_closed(_c: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `726 + c * (16 ±0)` - // Estimated: `7195` - // Minimum execution time: 47_010 nanoseconds. - Weight::from_parts(62_466_368, 7195) + // Measured: `662 + c * (16 ±0)` + // Estimated: `4515` + // Minimum execution time: 49_510 nanoseconds. + Weight::from_parts(67_994_214, 4515) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerReportBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerReportBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerReportBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 63]`. - fn admin_move_market_to_resolved_scalar_reported(r: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `772 + r * (16 ±0)` - // Estimated: `10408` - // Minimum execution time: 84_500 nanoseconds. - Weight::from_parts(116_294_372, 10408) - // Standard Error: 15_139 - .saturating_add(Weight::from_parts(22_900, 0).saturating_mul(r.into())) + fn admin_move_market_to_resolved_scalar_reported(_r: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `708 + r * (16 ±0)` + // Estimated: `4714` + // Minimum execution time: 101_380 nanoseconds. + Weight::from_parts(141_575_488, 4714) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerReportBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:63 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:63 w:63) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerReportBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerReportBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 63]`. fn admin_move_market_to_resolved_categorical_reported(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `17743 + r * (16 ±0)` - // Estimated: `420008` - // Minimum execution time: 977_573 nanoseconds. - Weight::from_parts(1_233_328_742, 420008) - // Standard Error: 144_771 - .saturating_add(Weight::from_parts(164_049, 0).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(131)) - .saturating_add(T::DbWeight::get().writes(67)) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:2 w:2) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + // Measured: `664 + r * (16 ±0)` + // Estimated: `4714` + // Minimum execution time: 101_461 nanoseconds. + Weight::from_parts(135_739_374, 4714) + // Standard Error: 24_998 + .saturating_add(Weight::from_parts(33_913, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:2 w:2) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 63]`. - fn admin_move_market_to_resolved_scalar_disputed(_r: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `1369 + r * (16 ±0)` - // Estimated: `22134` - // Minimum execution time: 141_201 nanoseconds. - Weight::from_parts(193_086_493, 22134) + fn admin_move_market_to_resolved_scalar_disputed(r: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `1240 + r * (16 ±0)` + // Estimated: `8438` + // Minimum execution time: 179_161 nanoseconds. + Weight::from_parts(233_307_766, 8438) + // Standard Error: 44_850 + .saturating_add(Weight::from_parts(267_513, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(6)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:2 w:2) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:63 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:63 w:63) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:2 w:2) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 63]`. fn admin_move_market_to_resolved_categorical_disputed(_r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `18325 + r * (16 ±0)` - // Estimated: `431734` - // Minimum execution time: 1_027_543 nanoseconds. - Weight::from_parts(1_303_716_166, 431734) - .saturating_add(T::DbWeight::get().reads(135)) - .saturating_add(T::DbWeight::get().writes(70)) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsForEdit (r:1 w:0) - /// Proof: PredictionMarkets MarketIdsForEdit (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + // Measured: `1181 + r * (16 ±0)` + // Estimated: `8438` + // Minimum execution time: 177_800 nanoseconds. + Weight::from_parts(238_334_645, 8438) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsForEdit` (r:1 w:0) + /// Proof: `PredictionMarkets::MarketIdsForEdit` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn approve_market() -> Weight { // Proof Size summary in bytes: - // Measured: `672` - // Estimated: `183216` - // Minimum execution time: 578_002 nanoseconds. - Weight::from_parts(751_902_000, 183216) - .saturating_add(T::DbWeight::get().reads(67)) - .saturating_add(T::DbWeight::get().writes(66)) - } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsForEdit (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsForEdit (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + // Measured: `564` + // Estimated: `4714` + // Minimum execution time: 71_920 nanoseconds. + Weight::from_parts(87_730_000, 4714) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsForEdit` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsForEdit` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `r` is `[0, 1024]`. fn request_edit(r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `6692` - // Minimum execution time: 26_710 nanoseconds. - Weight::from_parts(35_866_931, 6692) - // Standard Error: 339 - .saturating_add(Weight::from_parts(1_624, 0).saturating_mul(r.into())) + // Measured: `503` + // Estimated: `4515` + // Minimum execution time: 29_490 nanoseconds. + Weight::from_parts(37_974_205, 4515) + // Standard Error: 425 + .saturating_add(Weight::from_parts(2_637, 0).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) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:64 w:64) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:64 w:64) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:64 w:64) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 64]`. fn buy_complete_set(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `595 + a * (265 ±0)` - // Estimated: `5774 + a * (5292 ±0)` - // Minimum execution time: 116_930 nanoseconds. - Weight::from_parts(94_849_694, 5774) - // Standard Error: 124_185 - .saturating_add(Weight::from_parts(24_826_280, 0).saturating_mul(a.into())) + // Measured: `538` + // Estimated: `4159 + a * (2598 ±0)` + // Minimum execution time: 144_410 nanoseconds. + Weight::from_parts(103_677_076, 4159) + // Standard Error: 92_821 + .saturating_add(Weight::from_parts(28_850_139, 0).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()))) - .saturating_add(Weight::from_parts(0, 5292).saturating_mul(a.into())) - } - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: MarketCommons MarketCounter (r:1 w:1) - /// Proof: MarketCommons MarketCounter (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:0 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(a.into())) + } + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::MarketCounter` (r:1 w:1) + /// Proof: `MarketCommons::MarketCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:0 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) /// The range of component `m` is `[0, 63]`. fn create_market(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `316 + m * (16 ±0)` - // Estimated: `181063` - // Minimum execution time: 580_722 nanoseconds. - Weight::from_parts(746_949_580, 181063) - // Standard Error: 134_673 - .saturating_add(Weight::from_parts(95_879, 0).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(68)) - .saturating_add(T::DbWeight::get().writes(68)) - } - /// Storage: PredictionMarkets MarketIdsForEdit (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsForEdit (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + // Measured: `208 + m * (16 ±0)` + // Estimated: `4714` + // Minimum execution time: 74_090 nanoseconds. + Weight::from_parts(96_846_263, 4714) + // Standard Error: 18_347 + .saturating_add(Weight::from_parts(102_037, 0).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) + /// Proof: `PredictionMarkets::MarketIdsForEdit` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) /// The range of component `m` is `[0, 63]`. - fn edit_market(m: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `751 + m * (16 ±0)` - // Estimated: `10720` - // Minimum execution time: 56_321 nanoseconds. - Weight::from_parts(74_197_986, 10720) - // Standard Error: 12_078 - .saturating_add(Weight::from_parts(99_545, 0).saturating_mul(m.into())) + fn edit_market(_m: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `687 + m * (16 ±0)` + // Estimated: `4515` + // Minimum execution time: 63_690 nanoseconds. + Weight::from_parts(84_684_176, 4515) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:1) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: Court MarketIdToCourtId (r:1 w:0) - /// Proof: Court MarketIdToCourtId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court CourtPool (r:1 w:0) - /// Proof: Court CourtPool (max_values: Some(1), max_size: Some(96002), added: 96497, mode: MaxEncodedLen) - /// Storage: Court Courts (r:1 w:1) - /// Proof: Court Courts (max_values: None, max_size: Some(349), added: 2824, mode: MaxEncodedLen) - /// Storage: Court CourtIdToMarketId (r:1 w:0) - /// Proof: Court CourtIdToMarketId (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) - /// Storage: Court SelectedDraws (r:1 w:1) - /// Proof: Court SelectedDraws (max_values: None, max_size: Some(149974), added: 152449, mode: MaxEncodedLen) - /// Storage: Court Participants (r:31 w:31) - /// Proof: Court Participants (max_values: None, max_size: Some(251), added: 2726, mode: MaxEncodedLen) - /// Storage: GlobalDisputes Outcomes (r:1 w:1) - /// Proof: GlobalDisputes Outcomes (max_values: None, max_size: Some(395), added: 2870, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:1) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `Court::MarketIdToCourtId` (r:1 w:0) + /// Proof: `Court::MarketIdToCourtId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtPool` (r:1 w:0) + /// Proof: `Court::CourtPool` (`max_values`: Some(1), `max_size`: Some(96002), added: 96497, mode: `MaxEncodedLen`) + /// Storage: `Court::Courts` (r:1 w:1) + /// Proof: `Court::Courts` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Court::CourtIdToMarketId` (r:1 w:0) + /// Proof: `Court::CourtIdToMarketId` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) + /// Storage: `Court::SelectedDraws` (r:1 w:1) + /// Proof: `Court::SelectedDraws` (`max_values`: None, `max_size`: Some(149974), added: 152449, mode: `MaxEncodedLen`) + /// Storage: `Court::Participants` (r:31 w:31) + /// Proof: `Court::Participants` (`max_values`: None, `max_size`: Some(251), added: 2726, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::Outcomes` (r:1 w:1) + /// Proof: `GlobalDisputes::Outcomes` (`max_values`: None, `max_size`: Some(395), added: 2870, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) /// The range of component `m` is `[1, 64]`. /// The range of component `n` is `[1, 64]`. fn start_global_dispute(m: u32, n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `10022 + m * (16 ±0)` - // Estimated: `353731` - // Minimum execution time: 320_101 nanoseconds. - Weight::from_parts(392_505_353, 353731) - // Standard Error: 43_508 - .saturating_add(Weight::from_parts(186_891, 0).saturating_mul(m.into())) - // Standard Error: 43_508 - .saturating_add(Weight::from_parts(73_177, 0).saturating_mul(n.into())) + // Measured: `8805 + m * (16 ±0)` + // Estimated: `153439` + // Minimum execution time: 381_092 nanoseconds. + Weight::from_parts(467_180_792, 153439) + // Standard Error: 63_125 + .saturating_add(Weight::from_parts(569_392, 0).saturating_mul(m.into())) + // Standard Error: 63_125 + .saturating_add(Weight::from_parts(507_292, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(40)) .saturating_add(T::DbWeight::get().writes(36)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn dispute_authorized() -> Weight { // Proof Size summary in bytes: - // Measured: `642` - // Estimated: `6891` - // Minimum execution time: 44_220 nanoseconds. - Weight::from_parts(59_390_000, 6891) + // Measured: `610` + // Estimated: `4714` + // Minimum execution time: 54_360 nanoseconds. + Weight::from_parts(67_401_000, 4714) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsForEdit (r:0 w:1) - /// Proof: PredictionMarkets MarketIdsForEdit (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsForEdit` (r:0 w:1) + /// Proof: `PredictionMarkets::MarketIdsForEdit` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) fn handle_expired_advised_market() -> Weight { // Proof Size summary in bytes: - // Measured: `555` - // Estimated: `6891` - // Minimum execution time: 77_490 nanoseconds. - Weight::from_parts(79_210_000, 6891) + // Measured: `523` + // Estimated: `4714` + // Minimum execution time: 94_720 nanoseconds. + Weight::from_parts(97_491_000, 4714) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:63 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:63 w:63) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn internal_resolve_categorical_reported() -> Weight { // Proof Size summary in bytes: - // Measured: `17613` - // Estimated: `416491` - // Minimum execution time: 994_903 nanoseconds. - Weight::from_parts(1_206_524_000, 416491) - .saturating_add(T::DbWeight::get().reads(130)) - .saturating_add(T::DbWeight::get().writes(66)) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:63 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:63 w:63) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + // Measured: `566` + // Estimated: `4714` + // Minimum execution time: 76_380 nanoseconds. + Weight::from_parts(111_071_000, 4714) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn internal_resolve_categorical_disputed() -> Weight { // Proof Size summary in bytes: - // Measured: `17939` - // Estimated: `421886` - // Minimum execution time: 1_024_403 nanoseconds. - Weight::from_parts(1_238_704_000, 421886) - .saturating_add(T::DbWeight::get().reads(132)) - .saturating_add(T::DbWeight::get().writes(67)) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + // Measured: `859` + // Estimated: `4714` + // Minimum execution time: 137_721 nanoseconds. + Weight::from_parts(170_280_000, 4714) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn internal_resolve_scalar_reported() -> Weight { // Proof Size summary in bytes: - // Measured: `642` - // Estimated: `6891` - // Minimum execution time: 68_250 nanoseconds. - Weight::from_parts(83_570_000, 6891) + // Measured: `610` + // Estimated: `4714` + // Minimum execution time: 93_531 nanoseconds. + Weight::from_parts(113_090_000, 4714) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:0) - /// Proof: GlobalDisputes GlobalDisputesInfo (max_values: None, max_size: Some(396), added: 2871, mode: MaxEncodedLen) - /// Storage: Authorized AuthorizedOutcomeReports (r:1 w:1) - /// Proof: Authorized AuthorizedOutcomeReports (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `GlobalDisputes::GlobalDisputesInfo` (r:1 w:0) + /// Proof: `GlobalDisputes::GlobalDisputesInfo` (`max_values`: None, `max_size`: Some(396), added: 2871, mode: `MaxEncodedLen`) + /// Storage: `Authorized::AuthorizedOutcomeReports` (r:1 w:1) + /// Proof: `Authorized::AuthorizedOutcomeReports` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) fn internal_resolve_scalar_disputed() -> Weight { // Proof Size summary in bytes: - // Measured: `983` - // Estimated: `12286` - // Minimum execution time: 118_200 nanoseconds. - Weight::from_parts(144_091_000, 12286) + // Measured: `918` + // Estimated: `4714` + // Minimum execution time: 169_591 nanoseconds. + Weight::from_parts(177_071_000, 4714) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets LastTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets LastTimeFrame (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseBlock (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerReportBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::LastTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::LastTimeFrame` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseBlock` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerReportBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerReportBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) fn on_initialize_resolve_overhead() -> Weight { // Proof Size summary in bytes: // Measured: `79` - // Estimated: `15090` - // Minimum execution time: 27_990 nanoseconds. - Weight::from_parts(34_200_000, 15090) + // Estimated: `4515` + // Minimum execution time: 39_860 nanoseconds. + Weight::from_parts(41_071_000, 4515) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:1 w:1) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:1 w:1) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:1 w:1) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) fn redeem_shares_categorical() -> Weight { // Proof Size summary in bytes: - // Measured: `3910` - // Estimated: `94450` - // Minimum execution time: 163_190 nanoseconds. - Weight::from_parts(168_670_000, 94450) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `1982` + // Estimated: `4159` + // Minimum execution time: 182_581 nanoseconds. + Weight::from_parts(199_601_000, 4159) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:2) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:2 w:2) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:2 w:2) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:2 w:2) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) fn redeem_shares_scalar() -> Weight { // Proof Size summary in bytes: - // Measured: `1750` - // Estimated: `102260` - // Minimum execution time: 174_740 nanoseconds. - Weight::from_parts(235_220_000, 102260) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(6)) + // Measured: `1097` + // Estimated: `6186` + // Minimum execution time: 208_291 nanoseconds. + Weight::from_parts(216_581_000, 6186) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsForEdit (r:0 w:1) - /// Proof: PredictionMarkets MarketIdsForEdit (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsForEdit` (r:0 w:1) + /// Proof: `PredictionMarkets::MarketIdsForEdit` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 63]`. /// The range of component `r` is `[0, 1024]`. fn reject_market(c: u32, r: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `659 + c * (16 ±0)` - // Estimated: `10416` - // Minimum execution time: 87_590 nanoseconds. - Weight::from_parts(116_270_405, 10416) - // Standard Error: 10_421 - .saturating_add(Weight::from_parts(33_746, 0).saturating_mul(c.into())) - // Standard Error: 645 - .saturating_add(Weight::from_parts(2_262, 0).saturating_mul(r.into())) + // Measured: `595 + c * (16 ±0)` + // Estimated: `4714` + // Minimum execution time: 110_180 nanoseconds. + Weight::from_parts(142_314_814, 4714) + // Standard Error: 19_758 + .saturating_add(Weight::from_parts(67_136, 0).saturating_mul(c.into())) + // Standard Error: 1_224 + .saturating_add(Weight::from_parts(3_548, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerReportBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerReportBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerReportBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) /// The range of component `m` is `[0, 63]`. fn report_market_with_dispute_mechanism(m: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `732` - // Estimated: `7187` - // Minimum execution time: 42_990 nanoseconds. - Weight::from_parts(56_207_943, 7187) - // Standard Error: 7_812 - .saturating_add(Weight::from_parts(6_290, 0).saturating_mul(m.into())) + // Measured: `700` + // Estimated: `4507` + // Minimum execution time: 46_240 nanoseconds. + Weight::from_parts(58_820_442, 4507) + // Standard Error: 8_559 + .saturating_add(Weight::from_parts(99_053, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: AssetRouter DestroyAssets (r:1 w:1) - /// Proof: AssetRouter DestroyAssets (max_values: Some(1), max_size: Some(40962), added: 41457, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:2 w:0) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:2) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: AssetRouter IndestructibleAssets (r:1 w:0) - /// Proof: AssetRouter IndestructibleAssets (max_values: Some(1), max_size: Some(38914), added: 39409, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn report_trusted_market() -> Weight { // Proof Size summary in bytes: - // Measured: `1369` - // Estimated: `98193` - // Minimum execution time: 146_430 nanoseconds. - Weight::from_parts(179_401_000, 98193) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `522` + // Estimated: `4714` + // Minimum execution time: 125_670 nanoseconds. + Weight::from_parts(143_950_000, 4714) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:64 w:64) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:64 w:64) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:64 w:64) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 64]`. fn sell_complete_set(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `756 + a * (373 ±0)` - // Estimated: `5774 + a * (5292 ±0)` - // Minimum execution time: 147_940 nanoseconds. - Weight::from_parts(89_827_511, 5774) - // Standard Error: 219_441 - .saturating_add(Weight::from_parts(42_430_954, 0).saturating_mul(a.into())) + // Measured: `745 + a * (129 ±0)` + // Estimated: `4159 + a * (2598 ±0)` + // Minimum execution time: 203_561 nanoseconds. + Weight::from_parts(110_138_971, 4159) + // Standard Error: 201_807 + .saturating_add(Weight::from_parts(40_363_141, 0).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()))) - .saturating_add(Weight::from_parts(0, 5292).saturating_mul(a.into())) - } - /// Storage: PredictionMarkets MarketIdsPerCloseBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseBlock (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:62 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(a.into())) + } + /// Storage: `PredictionMarkets::MarketIdsPerCloseBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseBlock` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:62 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `b` is `[1, 31]`. /// The range of component `f` is `[1, 31]`. fn market_status_manager(b: u32, f: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2539 + b * (345 ±0) + f * (347 ±0)` - // Estimated: `7050 + b * (3167 ±0) + f * (3167 ±0)` - // Minimum execution time: 232_361 nanoseconds. - Weight::from_parts(89_001_117, 7050) - // Standard Error: 82_419 - .saturating_add(Weight::from_parts(6_613_776, 0).saturating_mul(b.into())) - // Standard Error: 82_419 - .saturating_add(Weight::from_parts(6_927_874, 0).saturating_mul(f.into())) + // Measured: `2475 + b * (312 ±0) + f * (314 ±0)` + // Estimated: `4515 + b * (3169 ±0) + f * (3169 ±0)` + // Minimum execution time: 215_570 nanoseconds. + Weight::from_parts(66_665_567, 4515) + // Standard Error: 89_121 + .saturating_add(Weight::from_parts(6_873_569, 0).saturating_mul(b.into())) + // Standard Error: 89_121 + .saturating_add(Weight::from_parts(6_645_077, 0).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)) - .saturating_add(Weight::from_parts(0, 3167).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 3167).saturating_mul(f.into())) - } - /// Storage: PredictionMarkets MarketIdsPerReportBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerReportBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:62 w:0) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerDisputeBlock (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerDisputeBlock (max_values: None, max_size: Some(1042), added: 3517, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 3169).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 3169).saturating_mul(f.into())) + } + /// Storage: `PredictionMarkets::MarketIdsPerReportBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerReportBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:62 w:0) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerDisputeBlock` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerDisputeBlock` (`max_values`: None, `max_size`: Some(1042), added: 3517, mode: `MaxEncodedLen`) /// The range of component `r` is `[1, 31]`. /// The range of component `d` is `[1, 31]`. fn market_resolution_manager(r: u32, d: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `2483 + r * (345 ±0) + d * (347 ±0)` - // Estimated: `7034 + r * (3167 ±0) + d * (3167 ±0)` - // Minimum execution time: 232_451 nanoseconds. - Weight::from_parts(84_083_353, 7034) - // Standard Error: 70_931 - .saturating_add(Weight::from_parts(6_584_415, 0).saturating_mul(r.into())) - // Standard Error: 70_931 - .saturating_add(Weight::from_parts(6_864_391, 0).saturating_mul(d.into())) + // Measured: `2419 + d * (314 ±0) + r * (312 ±0)` + // Estimated: `4507 + d * (3169 ±0) + r * (3169 ±0)` + // Minimum execution time: 205_081 nanoseconds. + Weight::from_parts(68_553_721, 4507) + // Standard Error: 64_199 + .saturating_add(Weight::from_parts(6_565_695, 0).saturating_mul(r.into())) + // Standard Error: 64_199 + .saturating_add(Weight::from_parts(6_336_678, 0).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)) - .saturating_add(Weight::from_parts(0, 3167).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 3167).saturating_mul(d.into())) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 3169).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 3169).saturating_mul(r.into())) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[0, 63]`. /// The range of component `n` is `[0, 63]`. - fn schedule_early_close_as_authority(o: u32, _n: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `763 + o * (16 ±0)` - // Estimated: `10720` - // Minimum execution time: 53_380 nanoseconds. - Weight::from_parts(69_829_159, 10720) - // Standard Error: 9_438 - .saturating_add(Weight::from_parts(58_622, 0).saturating_mul(o.into())) + fn schedule_early_close_as_authority(o: u32, n: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `699 + o * (16 ±0)` + // Estimated: `8040` + // Minimum execution time: 55_540 nanoseconds. + Weight::from_parts(73_241_162, 8040) + // Standard Error: 11_376 + .saturating_add(Weight::from_parts(65_723, 0).saturating_mul(o.into())) + // Standard Error: 11_376 + .saturating_add(Weight::from_parts(22_491, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[0, 63]`. /// The range of component `n` is `[0, 63]`. - fn schedule_early_close_after_dispute(_o: u32, _n: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `986 + o * (16 ±0)` - // Estimated: `14444` - // Minimum execution time: 98_240 nanoseconds. - Weight::from_parts(129_586_211, 14444) + fn schedule_early_close_after_dispute(o: u32, _n: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `922 + o * (16 ±0)` + // Estimated: `8040` + // Minimum execution time: 114_820 nanoseconds. + Weight::from_parts(160_073_439, 8040) + // Standard Error: 21_783 + .saturating_add(Weight::from_parts(19_546, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[0, 63]`. /// The range of component `n` is `[0, 63]`. fn schedule_early_close_as_market_creator(o: u32, n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `824 + o * (16 ±0)` - // Estimated: `14444` - // Minimum execution time: 75_620 nanoseconds. - Weight::from_parts(92_020_605, 14444) - // Standard Error: 13_677 - .saturating_add(Weight::from_parts(115_579, 0).saturating_mul(o.into())) - // Standard Error: 13_677 - .saturating_add(Weight::from_parts(28_959, 0).saturating_mul(n.into())) + // Measured: `760 + o * (16 ±0)` + // Estimated: `8040` + // Minimum execution time: 85_480 nanoseconds. + Weight::from_parts(113_426_839, 8040) + // Standard Error: 16_262 + .saturating_add(Weight::from_parts(49_062, 0).saturating_mul(o.into())) + // Standard Error: 16_262 + .saturating_add(Weight::from_parts(65_277, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[0, 63]`. /// The range of component `n` is `[0, 63]`. - fn dispute_early_close(_o: u32, n: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `940 + o * (16 ±0) + n * (16 ±0)` - // Estimated: `14444` - // Minimum execution time: 72_551 nanoseconds. - Weight::from_parts(96_247_822, 14444) - // Standard Error: 11_213 - .saturating_add(Weight::from_parts(22_013, 0).saturating_mul(n.into())) + fn dispute_early_close(o: u32, n: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `844 + n * (16 ±0) + o * (16 ±0)` + // Estimated: `8040` + // Minimum execution time: 81_770 nanoseconds. + Weight::from_parts(108_899_102, 8040) + // Standard Error: 15_462 + .saturating_add(Weight::from_parts(49_011, 0).saturating_mul(o.into())) + // Standard Error: 15_462 + .saturating_add(Weight::from_parts(53_793, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:2 w:2) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:2 w:2) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[0, 63]`. /// The range of component `n` is `[0, 63]`. fn reject_early_close_after_authority(_o: u32, _n: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `830 + o * (16 ±0) + n * (16 ±0)` - // Estimated: `10720` - // Minimum execution time: 57_031 nanoseconds. - Weight::from_parts(75_086_876, 10720) + // Measured: `734 + n * (16 ±0) + o * (16 ±0)` + // Estimated: `8040` + // Minimum execution time: 61_400 nanoseconds. + Weight::from_parts(84_625_166, 8040) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) fn reject_early_close_after_dispute() -> Weight { // Proof Size summary in bytes: - // Measured: `688` - // Estimated: `6891` - // Minimum execution time: 69_480 nanoseconds. - Weight::from_parts(88_480_000, 6891) + // Measured: `656` + // Estimated: `4714` + // Minimum execution time: 106_910 nanoseconds. + Weight::from_parts(108_350_000, 4714) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 63]`. - fn close_trusted_market(_c: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `725 + c * (16 ±0)` - // Estimated: `7195` - // Minimum execution time: 47_610 nanoseconds. - Weight::from_parts(61_392_473, 7195) + fn close_trusted_market(c: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `661 + c * (16 ±0)` + // Estimated: `4515` + // Minimum execution time: 50_730 nanoseconds. + Weight::from_parts(67_122_433, 4515) + // Standard Error: 11_418 + .saturating_add(Weight::from_parts(43_916, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Balances Reserves (r:1 w:1) - /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) - /// Storage: MarketCommons MarketCounter (r:1 w:1) - /// Proof: MarketCommons MarketCounter (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:64 w:64) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) - /// Storage: MarketAssets Account (r:128 w:128) - /// Proof: MarketAssets Account (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: NeoSwaps Pools (r:1 w:1) - /// Proof: NeoSwaps Pools (max_values: None, max_size: Some(144746), added: 147221, mode: MaxEncodedLen) - /// Storage: MarketCommons Markets (r:0 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Balances::Reserves` (r:1 w:1) + /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::MarketCounter` (r:1 w:1) + /// Proof: `MarketCommons::MarketCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:128 w:128) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:64 w:64) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `NeoSwaps::Pools` (r:1 w:1) + /// Proof: `NeoSwaps::Pools` (`max_values`: None, `max_size`: Some(144746), added: 147221, mode: `MaxEncodedLen`) + /// Storage: `MarketCommons::Markets` (r:0 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) /// The range of component `m` is `[0, 63]`. /// The range of component `n` is `[2, 64]`. - fn create_market_and_deploy_pool(_m: u32, n: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `371 + m * (16 ±0)` - // Estimated: `160698 + n * (7884 ±0)` - // Minimum execution time: 320_281 nanoseconds. - Weight::from_parts(232_994_984, 160698) - // Standard Error: 231_500 - .saturating_add(Weight::from_parts(73_326_774, 0).saturating_mul(n.into())) + fn create_market_and_deploy_pool(m: u32, n: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `378 + m * (16 ±0)` + // Estimated: `148211 + n * (5196 ±0)` + // Minimum execution time: 433_231 nanoseconds. + Weight::from_parts(186_531_666, 148211) + // Standard Error: 230_950 + .saturating_add(Weight::from_parts(2_641_351, 0).saturating_mul(m.into())) + // Standard Error: 234_410 + .saturating_add(Weight::from_parts(73_779_839, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(7)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into()))) - .saturating_add(Weight::from_parts(0, 7884).saturating_mul(n.into())) - } - /// Storage: MarketCommons Markets (r:1 w:1) - /// Proof: MarketCommons Markets (max_values: None, max_size: Some(692), added: 3167, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: PredictionMarkets MarketIdsPerCloseTimeFrame (r:1 w:1) - /// Proof: PredictionMarkets MarketIdsPerCloseTimeFrame (max_values: None, max_size: Some(1050), added: 3525, mode: MaxEncodedLen) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(n.into())) + } + /// Storage: `MarketCommons::Markets` (r:1 w:1) + /// Proof: `MarketCommons::Markets` (`max_values`: None, `max_size`: Some(694), added: 3169, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (r:1 w:1) + /// Proof: `PredictionMarkets::MarketIdsPerCloseTimeFrame` (`max_values`: None, `max_size`: Some(1050), added: 3525, mode: `MaxEncodedLen`) /// The range of component `o` is `[1, 63]`. fn manually_close_market(o: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `710 + o * (16 ±0)` - // Estimated: `7195` - // Minimum execution time: 45_710 nanoseconds. - Weight::from_parts(57_406_653, 7195) - // Standard Error: 9_276 - .saturating_add(Weight::from_parts(73_233, 0).saturating_mul(o.into())) + // Measured: `646 + o * (16 ±0)` + // Estimated: `4515` + // Minimum execution time: 50_480 nanoseconds. + Weight::from_parts(66_870_921, 4515) + // Standard Error: 11_179 + .saturating_add(Weight::from_parts(13_067, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/zrml/simple-disputes/src/lib.rs b/zrml/simple-disputes/src/lib.rs index dd45645bd..02f4822c6 100644 --- a/zrml/simple-disputes/src/lib.rs +++ b/zrml/simple-disputes/src/lib.rs @@ -33,7 +33,7 @@ pub use simple_disputes_pallet_api::SimpleDisputesPalletApi; use zeitgeist_primitives::{ traits::{DisputeApi, DisputeMaxWeightApi, DisputeResolutionApi}, types::{ - BaseAsset, GlobalDisputeItem, Market, MarketDispute, MarketDisputeMechanism, MarketStatus, + GlobalDisputeItem, Market, MarketDispute, MarketDisputeMechanism, MarketStatus, OutcomeReport, Report, ResultWithWeightInfo, }, }; @@ -114,7 +114,6 @@ mod pallet { BalanceOf, BlockNumberFor, MomentOf, - BaseAsset, MarketIdOf, >; pub(crate) type DisputesOf = BoundedVec< @@ -549,11 +548,11 @@ where { use frame_support::traits::Get; use sp_runtime::{traits::AccountIdConversion, SaturatedConversion}; - use zeitgeist_primitives::types::{MarketBonds, ScoringRule}; + use zeitgeist_primitives::types::{Asset, MarketBonds, ScoringRule}; zeitgeist_primitives::types::Market { market_id: Default::default(), - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: zeitgeist_primitives::types::MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: T::PalletId::get().into_account_truncating(), diff --git a/zrml/simple-disputes/src/mock.rs b/zrml/simple-disputes/src/mock.rs index 8b61bd18e..6e6268df3 100644 --- a/zrml/simple-disputes/src/mock.rs +++ b/zrml/simple-disputes/src/mock.rs @@ -31,13 +31,13 @@ use sp_runtime::{ }; use zeitgeist_primitives::{ constants::mock::{ - BlockHashCount, ExistentialDepositsAssets, GetNativeCurrencyId, MaxDisputes, MaxLocks, + BlockHashCount, ExistentialDeposits, GetNativeCurrencyId, MaxDisputes, MaxLocks, MaxReserves, MinimumPeriod, OutcomeBond, OutcomeFactor, SimpleDisputesPalletId, BASE, }, traits::{DisputeResolutionApi, MarketOfDisputeResolutionApi}, types::{ - AccountIdTest, Amount, Assets, Balance, BasicCurrencyAdapter, BlockNumber, Hash, MarketId, - Moment, + AccountIdTest, Amount, Balance, BasicCurrencyAdapter, BlockNumber, CurrencyId, Hash, + MarketId, Moment, }, }; @@ -164,10 +164,10 @@ impl orml_currencies::Config for Runtime { impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Assets; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = Everything; type RuntimeEvent = RuntimeEvent; - type ExistentialDeposits = ExistentialDepositsAssets; + type ExistentialDeposits = ExistentialDeposits; type MaxLocks = (); type MaxReserves = MaxReserves; type CurrencyHooks = (); diff --git a/zrml/simple-disputes/src/tests.rs b/zrml/simple-disputes/src/tests.rs index d8d51098c..fe0b7cfe0 100644 --- a/zrml/simple-disputes/src/tests.rs +++ b/zrml/simple-disputes/src/tests.rs @@ -27,14 +27,14 @@ use zeitgeist_primitives::{ constants::mock::{OutcomeBond, OutcomeFactor}, traits::DisputeApi, types::{ - BaseAsset, Deadlines, Market, MarketBonds, MarketCreation, MarketDispute, + Asset, Deadlines, Market, MarketBonds, MarketCreation, MarketDispute, MarketDisputeMechanism, MarketPeriod, MarketStatus, MarketType, OutcomeReport, ScoringRule, }, }; const DEFAULT_MARKET: MarketOf = Market { market_id: 0, - base_asset: BaseAsset::Ztg, + base_asset: Asset::Ztg, creation: MarketCreation::Permissionless, creator_fee: sp_runtime::Perbill::zero(), creator: 0, diff --git a/zrml/styx/src/weights.rs b/zrml/styx/src/weights.rs index d2e6fefb4..7f4c71dc8 100644 --- a/zrml/styx/src/weights.rs +++ b/zrml/styx/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_styx //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -56,26 +56,26 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_styx (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: Styx Crossings (r:1 w:1) - /// Proof: Styx Crossings (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - /// Storage: Styx BurnAmount (r:1 w:0) - /// Proof: Styx BurnAmount (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: `Styx::Crossings` (r:1 w:1) + /// Proof: `Styx::Crossings` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Styx::BurnAmount` (r:1 w:0) + /// Proof: `Styx::BurnAmount` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) fn cross() -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `3034` - // Minimum execution time: 42_280 nanoseconds. - Weight::from_parts(43_340_000, 3034) + // Estimated: `3513` + // Minimum execution time: 53_470 nanoseconds. + Weight::from_parts(54_700_000, 3513) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: Styx BurnAmount (r:0 w:1) - /// Proof: Styx BurnAmount (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: `Styx::BurnAmount` (r:0 w:1) + /// Proof: `Styx::BurnAmount` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) fn set_burn_amount() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_360 nanoseconds. - Weight::from_parts(14_110_000, 0).saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 14_570 nanoseconds. + Weight::from_parts(15_410_000, 0).saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/zrml/swaps/Cargo.toml b/zrml/swaps/Cargo.toml index dbbb83102..be3e44330 100644 --- a/zrml/swaps/Cargo.toml +++ b/zrml/swaps/Cargo.toml @@ -2,7 +2,6 @@ frame-benchmarking = { workspace = true, optional = true } frame-support = { workspace = true } frame-system = { workspace = true } -orml-tokens = { workspace = true } orml-traits = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive", "max-encoded-len"] } scale-info = { workspace = true, features = ["derive"] } @@ -15,6 +14,7 @@ zeitgeist-primitives = { workspace = true } env_logger = { workspace = true, optional = true } orml-currencies = { workspace = true, optional = true } +orml-tokens = { workspace = true, optional = true } pallet-balances = { workspace = true, optional = true } pallet-timestamp = { workspace = true, optional = true } sp-api = { workspace = true, optional = true } @@ -32,6 +32,7 @@ zrml-swaps = { workspace = true, features = ["mock"] } default = ["std"] mock = [ "orml-currencies/default", + "orml-tokens/default", "pallet-balances/default", "pallet-timestamp/default", "sp-api/default", @@ -51,7 +52,6 @@ std = [ "frame-benchmarking?/std", "frame-support/std", "frame-system/std", - "orml-tokens/default", "orml-traits/std", "parity-scale-codec/std", "sp-runtime/std", diff --git a/zrml/swaps/fuzz/create_pool.rs b/zrml/swaps/fuzz/create_pool.rs index 932212420..4e7470e87 100644 --- a/zrml/swaps/fuzz/create_pool.rs +++ b/zrml/swaps/fuzz/create_pool.rs @@ -18,14 +18,13 @@ #![no_main] +mod utils; + use libfuzzer_sys::fuzz_target; +use utils::{construct_asset, PoolCreationData}; use zeitgeist_primitives::traits::Swaps as SwapsTrait; - use zrml_swaps::mock::{ExtBuilder, Swaps}; -mod utils; -use utils::{construct_asset, PoolCreationData}; - fuzz_target!(|data: PoolCreationData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { diff --git a/zrml/swaps/fuzz/pool_exit.rs b/zrml/swaps/fuzz/pool_exit.rs index 7f595412b..134b40959 100644 --- a/zrml/swaps/fuzz/pool_exit.rs +++ b/zrml/swaps/fuzz/pool_exit.rs @@ -1,4 +1,4 @@ -// Copyright 2023-2024 Forecasting Technologies LTD. +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,22 +18,20 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; - mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; use utils::{construct_asset, GeneralPoolData}; use zeitgeist_primitives::types::Asset; -use zrml_swaps::mock::AssetManager; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: GeneralPoolData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, @@ -42,7 +40,7 @@ fuzz_target!(|data: GeneralPoolData| { let pool_creator = data.pool_creation.origin; let pool_id = data.pool_creation.create_pool(); // to exit a pool, origin also needs to have the pool tokens of the pool that they're exiting - let _ = AssetManager::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); + let _ = Currencies::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); let _ = Swaps::pool_exit( RuntimeOrigin::signed(data.origin), pool_id, 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 11f3c60f9..c5a6d3f6d 100644 --- a/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs +++ b/zrml/swaps/fuzz/pool_exit_with_exact_asset_amount.rs @@ -1,4 +1,4 @@ -// Copyright 2023-2024 Forecasting Technologies LTD. +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,23 +18,20 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; - mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; use utils::{construct_asset, ExactAssetAmountData}; -use zrml_swaps::mock::AssetManager; - use zeitgeist_primitives::types::Asset; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: ExactAssetAmountData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, @@ -44,7 +41,7 @@ fuzz_target!(|data: ExactAssetAmountData| { let pool_creator = data.pool_creation.origin; let pool_id = data.pool_creation.create_pool(); // to exit a pool, origin also needs to have the pool tokens of the pool that they're exiting - let _ = AssetManager::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); + let _ = Currencies::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); let _ = Swaps::pool_exit_with_exact_asset_amount( RuntimeOrigin::signed(data.origin), pool_id, 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 072fd3a42..145e959ff 100644 --- a/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs +++ b/zrml/swaps/fuzz/pool_exit_with_exact_pool_amount.rs @@ -1,4 +1,4 @@ -// Copyright 2023-2024 Forecasting Technologies LTD. +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -18,22 +18,20 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; - mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; use utils::{construct_asset, ExactAmountData}; use zeitgeist_primitives::types::Asset; -use zrml_swaps::mock::AssetManager; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: ExactAmountData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, @@ -43,7 +41,7 @@ fuzz_target!(|data: ExactAmountData| { let pool_creator = data.pool_creation.origin; let pool_id = data.pool_creation.create_pool(); // to exit a pool, origin also needs to have the pool tokens of the pool that they're exiting - let _ = AssetManager::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); + let _ = Currencies::deposit(Asset::PoolShare(pool_id), &pool_creator, data.pool_amount); let _ = Swaps::pool_exit_with_exact_pool_amount( RuntimeOrigin::signed(data.origin), pool_id, diff --git a/zrml/swaps/fuzz/pool_join.rs b/zrml/swaps/fuzz/pool_join.rs index 76a1bf87c..e3153bf58 100644 --- a/zrml/swaps/fuzz/pool_join.rs +++ b/zrml/swaps/fuzz/pool_join.rs @@ -1,3 +1,4 @@ +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,22 +18,19 @@ #![no_main] +mod utils; + use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; - -use utils::GeneralPoolData; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; -mod utils; -use utils::construct_asset; -use zrml_swaps::mock::AssetManager; +use utils::{construct_asset, GeneralPoolData}; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: GeneralPoolData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, 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 91f1808d6..a95d8c6db 100644 --- a/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs +++ b/zrml/swaps/fuzz/pool_join_with_exact_asset_amount.rs @@ -1,3 +1,4 @@ +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,22 +18,19 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; - -use utils::ExactAssetAmountData; mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; -use utils::construct_asset; -use zrml_swaps::mock::AssetManager; +use utils::{construct_asset, ExactAssetAmountData}; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: ExactAssetAmountData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, // In order to successfully join the pool, data.asset_amount more tokens needed 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 f480592dd..a06915703 100644 --- a/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs +++ b/zrml/swaps/fuzz/pool_join_with_exact_pool_amount.rs @@ -1,3 +1,4 @@ +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,22 +18,19 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{ExtBuilder, RuntimeOrigin, Swaps}; - -use utils::ExactAmountData; mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; -use utils::construct_asset; -use zrml_swaps::mock::AssetManager; +use utils::{construct_asset, ExactAmountData}; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: ExactAmountData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, // In order to successfully join the pool, data.asset_amount more tokens needed diff --git a/zrml/swaps/fuzz/swap_exact_amount_in.rs b/zrml/swaps/fuzz/swap_exact_amount_in.rs index 4aba80d2f..1771c7b14 100644 --- a/zrml/swaps/fuzz/swap_exact_amount_in.rs +++ b/zrml/swaps/fuzz/swap_exact_amount_in.rs @@ -1,3 +1,4 @@ +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,32 +18,27 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{AssetManager, ExtBuilder, RuntimeOrigin, Swaps}; - -use utils::SwapExactAmountInData; mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; -use utils::construct_asset; +use utils::{construct_asset, SwapExactAmountInData}; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: SwapExactAmountInData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, ); } let pool_id = data.pool_creation.create_pool(); - let _ = AssetManager::deposit( - construct_asset(data.asset_in), - &data.origin, - data.asset_amount_in, - ); + let _ = + Currencies::deposit(construct_asset(data.asset_in), &data.origin, data.asset_amount_in); let _ = Swaps::swap_exact_amount_in( RuntimeOrigin::signed(data.origin), pool_id, diff --git a/zrml/swaps/fuzz/swap_exact_amount_out.rs b/zrml/swaps/fuzz/swap_exact_amount_out.rs index 93eab4325..b254fe8e7 100644 --- a/zrml/swaps/fuzz/swap_exact_amount_out.rs +++ b/zrml/swaps/fuzz/swap_exact_amount_out.rs @@ -1,3 +1,4 @@ +// Copyright 2024 Forecasting Technologies LTD. // Copyright 2021-2022 Zeitgeist PM LLC. // // This file is part of Zeitgeist. @@ -17,20 +18,19 @@ #![no_main] -use libfuzzer_sys::fuzz_target; -use zrml_swaps::mock::{AssetManager, ExtBuilder, RuntimeOrigin, Swaps}; - mod utils; + +use libfuzzer_sys::fuzz_target; use orml_traits::currency::MultiCurrency; use utils::{construct_asset, SwapExactAmountOutData}; +use zrml_swaps::mock::{Currencies, ExtBuilder, RuntimeOrigin, Swaps}; fuzz_target!(|data: SwapExactAmountOutData| { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| { // ensure that the account origin has a sufficient balance - // use orml_traits::MultiCurrency; required for this for a in &data.pool_creation.assets { - let _ = AssetManager::deposit( + let _ = Currencies::deposit( construct_asset(*a), &data.pool_creation.origin, data.pool_creation.amount, @@ -39,7 +39,7 @@ fuzz_target!(|data: SwapExactAmountOutData| { let pool_id = data.pool_creation.create_pool(); if let Some(amount) = data.asset_amount_in { - let _ = AssetManager::deposit(construct_asset(data.asset_in), &data.origin, amount); + let _ = Currencies::deposit(construct_asset(data.asset_in), &data.origin, amount); } let _ = Swaps::swap_exact_amount_out( diff --git a/zrml/swaps/rpc/src/lib.rs b/zrml/swaps/rpc/src/lib.rs index 7de3901ef..5d4ae403c 100644 --- a/zrml/swaps/rpc/src/lib.rs +++ b/zrml/swaps/rpc/src/lib.rs @@ -27,11 +27,11 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorObject}, }; -use parity_scale_codec::{Codec, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Codec, MaxEncodedLen}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::traits::{Block as BlockT, MaybeDisplay, MaybeFromStr, NumberFor}; -use zeitgeist_primitives::types::Asset; +use zeitgeist_primitives::types::{Asset, SerdeWrapper}; pub use zrml_swaps_runtime_api::SwapsApi as SwapsRuntimeApi; @@ -39,7 +39,7 @@ pub use zrml_swaps_runtime_api::SwapsApi as SwapsRuntimeApi; pub trait SwapsApi where Balance: FromStr + Display + parity_scale_codec::MaxEncodedLen, - MarketId: FromStr + Display + HasCompact + MaxEncodedLen + Ord, + MarketId: FromStr + Display + parity_scale_codec::MaxEncodedLen + Ord, PoolId: FromStr + Display, BlockNumber: Ord + parity_scale_codec::MaxEncodedLen + Display + FromStr, { @@ -48,7 +48,7 @@ where &self, pool_id: PoolId, at: Option, - ) -> RpcResult>; + ) -> RpcResult>>; #[method(name = "swaps_poolAccountId", aliases = ["swaps_poolAccountIdAt"])] async fn pool_account_id(&self, pool_id: PoolId, at: Option) @@ -62,7 +62,7 @@ where asset_out: Asset, with_fees: bool, at: Option, - ) -> RpcResult; + ) -> RpcResult>; #[method(name = "swaps_getSpotPrices")] async fn get_spot_prices( @@ -72,7 +72,7 @@ where asset_out: Asset, with_fees: bool, blocks: Vec, - ) -> RpcResult>; + ) -> RpcResult>>; } /// A struct that implements the [`SwapsApi`]. @@ -113,22 +113,14 @@ where C::Api: SwapsRuntimeApi, PoolId: Clone + Codec + MaybeDisplay + MaybeFromStr + Send + 'static, AccountId: Clone + Display + Codec + Send + 'static, - Balance: Codec + HasCompact + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Send + 'static, - MarketId: Clone - + Codec - + HasCompact - + MaybeDisplay - + MaybeFromStr - + MaxEncodedLen - + Ord - + Send - + 'static, + Balance: Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Send + 'static, + MarketId: Clone + Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen + Ord + Send + 'static, { async fn pool_shares_id( &self, pool_id: PoolId, at: Option<::Hash>, - ) -> RpcResult> { + ) -> RpcResult>> { let api = self.client.runtime_api(); let hash = at.unwrap_or_else(|| self.client.info().best_hash); let res = api.pool_shares_id(hash, pool_id).map_err(|e| { @@ -166,7 +158,7 @@ where asset_out: Asset, with_fees: bool, at: Option<::Hash>, - ) -> RpcResult { + ) -> RpcResult> { let api = self.client.runtime_api(); let hash = at.unwrap_or_else(|| self.client.info().best_hash); let res = @@ -187,7 +179,7 @@ where asset_out: Asset, with_fees: bool, blocks: Vec>, - ) -> RpcResult> { + ) -> RpcResult>> { let api = self.client.runtime_api(); blocks .into_iter() diff --git a/zrml/swaps/runtime-api/src/lib.rs b/zrml/swaps/runtime-api/src/lib.rs index 2045560a2..b76ca8038 100644 --- a/zrml/swaps/runtime-api/src/lib.rs +++ b/zrml/swaps/runtime-api/src/lib.rs @@ -19,24 +19,26 @@ #![doc = include_str!("../README.md")] #![cfg_attr(not(feature = "std"), no_std)] -use parity_scale_codec::{Codec, HasCompact, MaxEncodedLen}; +use parity_scale_codec::{Codec, MaxEncodedLen}; use sp_runtime::traits::{MaybeDisplay, MaybeFromStr}; -use zeitgeist_primitives::types::Asset; +use zeitgeist_primitives::types::{Asset, SerdeWrapper}; sp_api::decl_runtime_apis! { pub trait SwapsApi where PoolId: Codec, AccountId: Codec, - Balance: Codec + MaybeDisplay + MaybeFromStr + HasCompact + MaxEncodedLen, - MarketId: Codec + HasCompact + MaxEncodedLen, + Balance: Codec + MaybeDisplay + MaybeFromStr + MaxEncodedLen, + MarketId: Codec + MaxEncodedLen, { - fn pool_shares_id(pool_id: PoolId) -> Asset; + fn pool_shares_id(pool_id: PoolId) -> Asset>; + fn pool_account_id(pool_id: &PoolId) -> AccountId; + fn get_spot_price( pool_id: &PoolId, asset_in: &Asset, asset_out: &Asset, with_fees: bool, - ) -> Balance; + ) -> SerdeWrapper; } } diff --git a/zrml/swaps/src/benchmarks.rs b/zrml/swaps/src/benchmarks.rs index 69bc5fc22..6c32fb53d 100644 --- a/zrml/swaps/src/benchmarks.rs +++ b/zrml/swaps/src/benchmarks.rs @@ -62,7 +62,7 @@ where for i in 0..asset_count { let asset = T::Asset::create_asset_id(i as u128); assets.push(asset); - T::AssetManager::deposit(asset, owner, asset_amount).unwrap() + T::MultiCurrency::deposit(asset, owner, asset_amount).unwrap() } (assets, asset_amount) } @@ -182,7 +182,7 @@ benchmarks! { true, ); let asset_in = assets[0]; - T::AssetManager::deposit(asset_in, &caller, u64::MAX.saturated_into()).unwrap(); + T::MultiCurrency::deposit(asset_in, &caller, u64::MAX.saturated_into()).unwrap(); let asset_out = assets[asset_count as usize - 1]; let min_asset_amount_out: Option> = Some(0u128.saturated_into()); let max_price = Some(u128::MAX.saturated_into()); @@ -218,7 +218,7 @@ benchmarks! { true, ); let asset_in = assets[0]; - T::AssetManager::deposit(asset_in, &caller, u64::MAX.saturated_into()).unwrap(); + T::MultiCurrency::deposit(asset_in, &caller, u64::MAX.saturated_into()).unwrap(); let asset_out = assets[asset_count as usize - 1]; let max_asset_amount_in: Option> = Some(u128::MAX.saturated_into()); let max_price = Some(u128::MAX.saturated_into()); diff --git a/zrml/swaps/src/lib.rs b/zrml/swaps/src/lib.rs index 54f55e4b3..f07f4bdd5 100644 --- a/zrml/swaps/src/lib.rs +++ b/zrml/swaps/src/lib.rs @@ -90,9 +90,9 @@ mod pallet { pub(crate) type AccountIdOf = ::AccountId; pub(crate) type AssetOf = - <::AssetManager as MultiCurrency>>::CurrencyId; + <::MultiCurrency as MultiCurrency>>::CurrencyId; pub(crate) type BalanceOf = - <::AssetManager as MultiCurrency>>::Balance; + <::MultiCurrency as MultiCurrency>>::Balance; pub(crate) type PoolOf = Pool, BalanceOf>; const MIN_BALANCE: u128 = CENT; @@ -360,8 +360,6 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type AssetManager: MultiCurrency; - type Asset: Parameter + Member + Copy @@ -371,6 +369,8 @@ mod pallet { + TypeInfo + PoolSharesId; + type MultiCurrency: MultiCurrency; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type WeightInfo: WeightInfoZeitgeist; @@ -602,13 +602,13 @@ mod pallet { // If transferring to `who` triggers the existential deposit, burn the tokens // instead. let new_balance = - T::AssetManager::free_balance(asset, &who).checked_add_res(&amount)?; - if new_balance >= T::AssetManager::minimum_balance(asset) { + T::MultiCurrency::free_balance(asset, &who).checked_add_res(&amount)?; + if new_balance >= T::MultiCurrency::minimum_balance(asset) { ensure!(amount >= amount_bound, Error::::LimitOut); - T::AssetManager::transfer(asset, &pool_account_id, &who, amount)?; + T::MultiCurrency::transfer(asset, &pool_account_id, &who, amount)?; } else { ensure!(amount_bound.is_zero(), Error::::LimitOut); - T::AssetManager::withdraw(asset, &pool_account_id, amount)?; + T::MultiCurrency::withdraw(asset, &pool_account_id, amount)?; } Ok(()) }, @@ -696,7 +696,7 @@ mod pallet { pool: &pool, transfer_asset: |amount, amount_bound, asset| { ensure!(amount <= amount_bound, Error::::LimitIn); - T::AssetManager::transfer(asset, &who, &pool_account_id, amount)?; + T::MultiCurrency::transfer(asset, &who, &pool_account_id, amount)?; Ok(()) }, transfer_pool: || Self::mint_pool_shares(pool_id, &who, pool_amount), @@ -860,15 +860,15 @@ mod pallet { let pool = Pallet::::pool_by_id(pool_id)?; let pool_account_id = Pallet::::pool_account_id(&pool_id); ensure!( - T::AssetManager::free_balance(asset_in, &who) >= asset_amount_in, + T::MultiCurrency::free_balance(asset_in, &who) >= asset_amount_in, Error::::InsufficientBalance ); let params = SwapExactAmountParams { // TODO(#1215): This probably doesn't need to be a closure. asset_amounts: || { - let balance_out = T::AssetManager::free_balance(asset_out, &pool_account_id); - let balance_in = T::AssetManager::free_balance(asset_in, &pool_account_id); + let balance_out = T::MultiCurrency::free_balance(asset_out, &pool_account_id); + let balance_in = T::MultiCurrency::free_balance(asset_in, &pool_account_id); ensure!( asset_amount_in <= balance_in.bmul(MAX_IN_RATIO.saturated_into())?, Error::::MaxInRatio @@ -922,13 +922,13 @@ mod pallet { let params = SwapExactAmountParams { asset_amounts: || { - let balance_out = T::AssetManager::free_balance(asset_out, &pool_account_id); + let balance_out = T::MultiCurrency::free_balance(asset_out, &pool_account_id); ensure!( asset_amount_out <= balance_out.bmul(MAX_OUT_RATIO.saturated_into())?, Error::::MaxOutRatio, ); - let balance_in = T::AssetManager::free_balance(asset_in, &pool_account_id); + let balance_in = T::MultiCurrency::free_balance(asset_in, &pool_account_id); let asset_amount_in: BalanceOf = crate::math::calc_in_given_out( balance_in.saturated_into(), Self::pool_weight_rslt(&pool, &asset_in)?.saturated_into(), @@ -969,8 +969,8 @@ mod pallet { ensure!(pool.assets.binary_search(asset_in).is_ok(), Error::::AssetNotInPool); ensure!(pool.assets.binary_search(asset_out).is_ok(), Error::::AssetNotInPool); let pool_account = Self::pool_account_id(pool_id); - let balance_in = T::AssetManager::free_balance(*asset_in, &pool_account); - let balance_out = T::AssetManager::free_balance(*asset_out, &pool_account); + let balance_in = T::MultiCurrency::free_balance(*asset_in, &pool_account); + let balance_out = T::MultiCurrency::free_balance(*asset_out, &pool_account); let in_weight = Self::pool_weight_rslt(&pool, asset_in)?; let out_weight = Self::pool_weight_rslt(&pool, asset_out)?; @@ -993,7 +993,7 @@ mod pallet { /// The minimum allowed balance of `asset` in a liquidity pool. pub(crate) fn min_balance(asset: AssetOf) -> BalanceOf { - T::AssetManager::minimum_balance(asset).max(MIN_BALANCE.saturated_into()) + T::MultiCurrency::minimum_balance(asset).max(MIN_BALANCE.saturated_into()) } /// Returns the minimum allowed balance allowed for a pool with id `pool_id` containing @@ -1023,7 +1023,7 @@ mod pallet { return Ok(()); } let pool_shares_id = Self::pool_shares_id(pool_id); - let total_issuance = T::AssetManager::total_issuance(pool_shares_id); + let total_issuance = T::MultiCurrency::total_issuance(pool_shares_id); let max_withdraw = total_issuance.saturating_sub(Self::min_balance(pool_shares_id).saturated_into()); ensure!(amount <= max_withdraw, Error::::PoolDrain); @@ -1041,7 +1041,7 @@ mod pallet { return Ok(()); } let pool_account = Self::pool_account_id(&pool_id); - let balance = T::AssetManager::free_balance(asset, &pool_account); + let balance = T::MultiCurrency::free_balance(asset, &pool_account); let max_withdraw = balance.saturating_sub(Self::min_balance(asset).saturated_into()); ensure!(amount <= max_withdraw, Error::::PoolDrain); Ok(()) @@ -1054,9 +1054,9 @@ mod pallet { ) -> DispatchResult { let shares_id = Self::pool_shares_id(pool_id); // Check that the account has at least as many free shares as we wish to burn! - T::AssetManager::ensure_can_withdraw(shares_id, from, amount) + T::MultiCurrency::ensure_can_withdraw(shares_id, from, amount) .map_err(|_| Error::::InsufficientBalance)?; - T::AssetManager::withdraw(shares_id, from, amount)?; + T::MultiCurrency::withdraw(shares_id, from, amount)?; Ok(()) } @@ -1088,7 +1088,7 @@ mod pallet { amount: BalanceOf, ) -> DispatchResult { let shares_id = Self::pool_shares_id(pool_id); - T::AssetManager::deposit(shares_id, to, amount) + T::MultiCurrency::deposit(shares_id, to, amount) } pub(crate) fn pool_shares_id(pool_id: PoolId) -> AssetOf { @@ -1186,17 +1186,17 @@ mod pallet { Self::check_provided_values_len_must_equal_assets_len(&assets, &weights)?; for (asset, weight) in assets.iter().copied().zip(weights) { - let free_balance = T::AssetManager::free_balance(asset, &who); + let free_balance = T::MultiCurrency::free_balance(asset, &who); ensure!(free_balance >= amount, Error::::InsufficientBalance); ensure!(weight >= T::MinWeight::get(), Error::::BelowMinimumWeight); ensure!(weight <= T::MaxWeight::get(), Error::::AboveMaximumWeight); map.insert(asset, weight); total_weight = total_weight.checked_add_res(&weight)?; - T::AssetManager::transfer(asset, &who, &pool_account, amount)?; + T::MultiCurrency::transfer(asset, &who, &pool_account, amount)?; } ensure!(total_weight <= T::MaxTotalWeight::get(), Error::::MaxTotalWeight); - T::AssetManager::deposit(pool_shares_id, &who, amount)?; + T::MultiCurrency::deposit(pool_shares_id, &who, amount)?; let pool = Pool { assets: sorted_assets @@ -1239,8 +1239,8 @@ mod pallet { let pool_account = Self::pool_account_id(&pool_id); let asset_len = pool.assets.len() as u32; for asset in pool.assets.into_iter() { - let amount = T::AssetManager::free_balance(asset, &pool_account); - T::AssetManager::withdraw(asset, &pool_account, amount)?; + let amount = T::MultiCurrency::free_balance(asset, &pool_account); + T::MultiCurrency::withdraw(asset, &pool_account, amount)?; } // NOTE: Currently we don't clean up accounts with pool_share_id. // TODO(#792): Remove pool_share_id asset for accounts! It may require storage migration. diff --git a/zrml/swaps/src/mock.rs b/zrml/swaps/src/mock.rs index 12450ed6e..ab18e5464 100644 --- a/zrml/swaps/src/mock.rs +++ b/zrml/swaps/src/mock.rs @@ -46,8 +46,8 @@ use zeitgeist_primitives::{ BASE, }, types::{ - AccountIdTest, Amount, Asset, Assets, Balance, BasicCurrencyAdapter, Hash, MarketId, - Moment, PoolId, UncheckedExtrinsicTest, + AccountIdTest, Amount, Asset, Balance, BasicCurrencyAdapter, CurrencyId, Hash, MarketId, + Moment, PoolId, SerdeWrapper, UncheckedExtrinsicTest, }, }; @@ -88,10 +88,9 @@ construct_runtime!( } ); -pub type AssetManager = Currencies; - impl crate::Config for Runtime { type Asset = Asset; + type MultiCurrency = Currencies; type RuntimeEvent = RuntimeEvent; type ExitFee = ExitFeeMock; type MaxAssets = MaxAssets; @@ -101,7 +100,6 @@ impl crate::Config for Runtime { type MinAssets = MinAssets; type MinWeight = MinWeight; type PalletId = SwapsPalletId; - type AssetManager = AssetManager; type WeightInfo = zrml_swaps::weights::WeightInfo; } @@ -139,7 +137,7 @@ impl orml_currencies::Config for Runtime { } parameter_type_with_key! { - pub ExistentialDeposits: |currency_id: Assets| -> Balance { + pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { match currency_id { &BASE_ASSET => ExistentialDeposit::get(), Asset::Ztg => ExistentialDeposit::get(), @@ -176,7 +174,7 @@ where impl orml_tokens::Config for Runtime { type Amount = Amount; type Balance = Balance; - type CurrencyId = Assets; + type CurrencyId = CurrencyId; type DustRemovalWhitelist = DustRemovalWhitelist; type RuntimeEvent = RuntimeEvent; type ExistentialDeposits = ExistentialDeposits; @@ -255,15 +253,15 @@ sp_api::mock_impl_runtime_apis! { asset_in: &Asset, asset_out: &Asset, with_fees: bool, - ) -> Balance { - Swaps::get_spot_price(pool_id, asset_in, asset_out, with_fees).ok().unwrap_or(0) + ) -> SerdeWrapper { + SerdeWrapper(Swaps::get_spot_price(pool_id, asset_in, asset_out, with_fees).ok().unwrap_or(0)) } fn pool_account_id(pool_id: &PoolId) -> AccountIdTest { Swaps::pool_account_id(pool_id) } - fn pool_shares_id(pool_id: PoolId) -> Asset { + fn pool_shares_id(pool_id: PoolId) -> Asset> { Asset::PoolShare(pool_id) } } diff --git a/zrml/swaps/src/utils.rs b/zrml/swaps/src/utils.rs index 7e746b808..041f8fc37 100644 --- a/zrml/swaps/src/utils.rs +++ b/zrml/swaps/src/utils.rs @@ -53,17 +53,17 @@ where ensure!(p.pool.bound(&p.asset), Error::::AssetNotInPool); let pool_account = Pallet::::pool_account_id(&p.pool_id); - let asset_balance = T::AssetManager::free_balance(p.asset, &pool_account); + let asset_balance = T::MultiCurrency::free_balance(p.asset, &pool_account); (p.ensure_balance)(asset_balance)?; let pool_shares_id = Pallet::::pool_shares_id(p.pool_id); - let total_issuance = T::AssetManager::total_issuance(pool_shares_id); + let total_issuance = T::MultiCurrency::total_issuance(pool_shares_id); let asset_amount = (p.asset_amount)(asset_balance, total_issuance)?; let pool_amount = (p.pool_amount)(asset_balance, total_issuance)?; Pallet::::burn_pool_shares(p.pool_id, &p.who, pool_amount)?; - T::AssetManager::transfer(p.asset, &pool_account, &p.who, asset_amount)?; + T::MultiCurrency::transfer(p.asset, &pool_account, &p.who, asset_amount)?; (p.event)(PoolAssetEvent { asset: p.asset, @@ -89,16 +89,16 @@ where Pallet::::ensure_pool_is_active(p.pool)?; let pool_shares_id = Pallet::::pool_shares_id(p.pool_id); let pool_account_id = Pallet::::pool_account_id(&p.pool_id); - let total_issuance = T::AssetManager::total_issuance(pool_shares_id); + let total_issuance = T::MultiCurrency::total_issuance(pool_shares_id); ensure!(p.pool.bound(&p.asset), Error::::AssetNotInPool); - let asset_balance = T::AssetManager::free_balance(p.asset, p.pool_account_id); + let asset_balance = T::MultiCurrency::free_balance(p.asset, p.pool_account_id); let asset_amount = (p.asset_amount)(asset_balance, total_issuance)?; let pool_amount = (p.pool_amount)(asset_balance, total_issuance)?; Pallet::::mint_pool_shares(p.pool_id, &p.who, pool_amount)?; - T::AssetManager::transfer(p.asset, &p.who, &pool_account_id, asset_amount)?; + T::MultiCurrency::transfer(p.asset, &p.who, &pool_account_id, asset_amount)?; (p.event)(PoolAssetEvent { asset: p.asset, @@ -121,7 +121,7 @@ where T: Config, { let pool_shares_id = Pallet::::pool_shares_id(p.pool_id); - let total_issuance = T::AssetManager::total_issuance(pool_shares_id); + let total_issuance = T::MultiCurrency::total_issuance(pool_shares_id); let ratio = p.pool_amount.bdiv(total_issuance)?; Pallet::::check_provided_values_len_must_equal_assets_len(&p.pool.assets, &p.asset_bounds)?; @@ -130,7 +130,7 @@ where let mut transferred = Vec::with_capacity(p.asset_bounds.len()); for (asset, amount_bound) in p.pool.assets.iter().cloned().zip(p.asset_bounds.iter().cloned()) { - let balance = T::AssetManager::free_balance(asset, p.pool_account_id); + let balance = T::MultiCurrency::free_balance(asset, p.pool_account_id); // Dusting may result in zero balances in the pool; just ignore these. if balance.is_zero() { continue; @@ -183,8 +183,8 @@ where let [asset_amount_in, asset_amount_out] = (p.asset_amounts)()?; - T::AssetManager::transfer(p.asset_in, &p.who, p.pool_account_id, asset_amount_in)?; - T::AssetManager::transfer(p.asset_out, p.pool_account_id, &p.who, asset_amount_out)?; + T::MultiCurrency::transfer(p.asset_in, &p.who, p.pool_account_id, asset_amount_in)?; + T::MultiCurrency::transfer(p.asset_out, p.pool_account_id, &p.who, asset_amount_out)?; let spot_price_after = Pallet::::get_spot_price(&p.pool_id, &p.asset_in, &p.asset_out, true)?; diff --git a/zrml/swaps/src/weights.rs b/zrml/swaps/src/weights.rs index 4e923b1d0..3a94e79cc 100644 --- a/zrml/swaps/src/weights.rs +++ b/zrml/swaps/src/weights.rs @@ -19,10 +19,10 @@ //! Autogenerated weights for zrml_swaps //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: `2024-04-15`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: `2024-07-25`, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `zeitgeist-benchmark`, CPU: `AMD EPYC 7601 32-Core Processor` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: // ./target/production/zeitgeist @@ -65,211 +65,193 @@ pub trait WeightInfoZeitgeist { /// Weight functions for zrml_swaps (automatically generated) pub struct WeightInfo(PhantomData); impl WeightInfoZeitgeist for WeightInfo { - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:66 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:131 w:131) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:131 w:131) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 65]`. fn pool_exit(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `957 + a * (176 ±0)` - // Estimated: `16477 + a * (7896 ±0)` - // Minimum execution time: 162_820 nanoseconds. - Weight::from_parts(122_679_185, 16477) - // Standard Error: 178_424 - .saturating_add(Weight::from_parts(47_099_181, 0).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(a.into()))) + // Measured: `753 + a * (144 ±0)` + // Estimated: `7044 + a * (5196 ±0)` + // Minimum execution time: 183_541 nanoseconds. + Weight::from_parts(96_285_356, 7044) + // Standard Error: 252_865 + .saturating_add(Weight::from_parts(52_212_929, 0).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()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(a.into())) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn pool_exit_with_exact_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `5655` - // Estimated: `24373` - // Minimum execution time: 127_140 nanoseconds. - Weight::from_parts(156_601_000, 24373) - .saturating_add(T::DbWeight::get().reads(8)) + // Measured: `5419` + // Estimated: `8784` + // Minimum execution time: 167_471 nanoseconds. + Weight::from_parts(188_981_000, 8784) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn pool_exit_with_exact_pool_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `5655` - // Estimated: `24373` - // Minimum execution time: 127_670 nanoseconds. - Weight::from_parts(155_520_000, 24373) - .saturating_add(T::DbWeight::get().reads(8)) + // Measured: `5419` + // Estimated: `8784` + // Minimum execution time: 144_390 nanoseconds. + Weight::from_parts(208_540_000, 8784) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:66 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:131 w:131) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:131 w:131) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 65]`. fn pool_join(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `835 + a * (289 ±0)` - // Estimated: `13870 + a * (7896 ±0)` - // Minimum execution time: 115_110 nanoseconds. - Weight::from_parts(79_330_150, 13870) - // Standard Error: 110_208 - .saturating_add(Weight::from_parts(32_859_066, 0).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(a.into()))) + // Measured: `662 + a * (225 ±0)` + // Estimated: `7044 + a * (5196 ±0)` + // Minimum execution time: 120_061 nanoseconds. + Weight::from_parts(111_747_674, 7044) + // Standard Error: 226_096 + .saturating_add(Weight::from_parts(38_098_845, 0).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()))) - .saturating_add(Weight::from_parts(0, 7896).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 5196).saturating_mul(a.into())) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) fn pool_join_with_exact_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `6338` - // Estimated: `21766` - // Minimum execution time: 111_461 nanoseconds. - Weight::from_parts(138_571_000, 21766) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `6101` + // Estimated: `8784` + // Minimum execution time: 157_271 nanoseconds. + Weight::from_parts(174_021_000, 8784) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:1 w:1) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:3 w:3) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) fn pool_join_with_exact_pool_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `6338` - // Estimated: `21766` - // Minimum execution time: 107_820 nanoseconds. - Weight::from_parts(131_030_000, 21766) - .saturating_add(T::DbWeight::get().reads(7)) + // Measured: `6101` + // Estimated: `8784` + // Minimum execution time: 142_221 nanoseconds. + Weight::from_parts(160_941_000, 8784) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:4) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn swap_exact_amount_in() -> Weight { // Proof Size summary in bytes: - // Measured: `5253` - // Estimated: `24453` - // Minimum execution time: 179_090 nanoseconds. - Weight::from_parts(219_440_000, 24453) - .saturating_add(T::DbWeight::get().reads(8)) + // Measured: `4984` + // Estimated: `11382` + // Minimum execution time: 233_881 nanoseconds. + Weight::from_parts(249_260_000, 11382) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:0) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:2 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:4 w:4) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:0) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:4 w:4) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) fn swap_exact_amount_out() -> Weight { // Proof Size summary in bytes: - // Measured: `5253` - // Estimated: `24453` - // Minimum execution time: 180_160 nanoseconds. - Weight::from_parts(218_621_000, 24453) - .saturating_add(T::DbWeight::get().reads(8)) + // Measured: `4984` + // Estimated: `11382` + // Minimum execution time: 192_100 nanoseconds. + Weight::from_parts(240_390_000, 11382) + .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: Swaps Pools (r:1 w:1) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:1) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 65]`. fn open_pool(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `168 + a * (54 ±0)` - // Estimated: `6054` - // Minimum execution time: 18_010 nanoseconds. - Weight::from_parts(24_025_251, 6054) - // Standard Error: 5_601 - .saturating_add(Weight::from_parts(344_175, 0).saturating_mul(a.into())) + // Measured: `136 + a * (54 ±0)` + // Estimated: `7044` + // Minimum execution time: 20_900 nanoseconds. + Weight::from_parts(31_093_447, 7044) + // Standard Error: 10_657 + .saturating_add(Weight::from_parts(518_245, 0).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) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:1) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 65]`. fn close_pool(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `168 + a * (54 ±0)` - // Estimated: `6054` - // Minimum execution time: 15_560 nanoseconds. - Weight::from_parts(21_271_791, 6054) - // Standard Error: 4_190 - .saturating_add(Weight::from_parts(199_418, 0).saturating_mul(a.into())) + // Measured: `136 + a * (54 ±0)` + // Estimated: `7044` + // Minimum execution time: 18_400 nanoseconds. + Weight::from_parts(24_417_157, 7044) + // Standard Error: 7_470 + .saturating_add(Weight::from_parts(383_035, 0).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) - /// Proof: Swaps Pools (max_values: None, max_size: Some(3579), added: 6054, mode: MaxEncodedLen) - /// Storage: MarketAssets Asset (r:65 w:0) - /// Proof: MarketAssets Asset (max_values: None, max_size: Some(225), added: 2700, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:65 w:65) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(123), added: 2598, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:65 w:65) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: `Swaps::Pools` (r:1 w:1) + /// Proof: `Swaps::Pools` (`max_values`: None, `max_size`: Some(3579), added: 6054, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:65 w:65) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(123), added: 2598, mode: `MaxEncodedLen`) + /// Storage: `Tokens::TotalIssuance` (r:65 w:65) + /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(43), added: 2518, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) /// The range of component `a` is `[2, 65]`. fn destroy_pool(a: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `678 + a * (214 ±0)` - // Estimated: `8661 + a * (7816 ±0)` - // Minimum execution time: 96_981 nanoseconds. - Weight::from_parts(68_984_475, 8661) - // Standard Error: 122_585 - .saturating_add(Weight::from_parts(29_342_794, 0).saturating_mul(a.into())) + // Measured: `505 + a * (182 ±0)` + // Estimated: `7044 + a * (2598 ±0)` + // Minimum execution time: 108_320 nanoseconds. + Weight::from_parts(41_690_862, 7044) + // Standard Error: 183_188 + .saturating_add(Weight::from_parts(35_118_993, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(a.into()))) + .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()))) - .saturating_add(Weight::from_parts(0, 7816).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 2598).saturating_mul(a.into())) } }