From ba729272c2731a80a9966c6398de41d163942dc1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 8 Jun 2023 13:22:51 +0200 Subject: [PATCH 01/11] remove common runtime and refactor pallet configs --- Cargo.lock | 223 ++--- Cargo.toml | 1 - .../parachain-runtime-mock/Cargo.toml | 3 +- .../parachain-runtime-mock/src/lib.rs | 2 +- node/Cargo.toml | 3 +- node/src/chain_spec.rs | 8 +- node/src/service.rs | 2 +- primitives/Cargo.toml | 4 +- primitives/src/lib.rs | 43 +- runtime/basilisk/Cargo.toml | 3 +- runtime/{common => basilisk}/src/adapter.rs | 0 .../basilisk/src/benchmarking/currencies.rs | 20 +- runtime/basilisk/src/benchmarking/mod.rs | 3 +- runtime/basilisk/src/benchmarking/vesting.rs | 24 +- runtime/basilisk/src/democracy.rs | 253 +++++ runtime/basilisk/src/finance.rs | 407 ++++++++ runtime/basilisk/src/lib.rs | 907 +----------------- runtime/basilisk/src/system.rs | 529 ++++++++++ runtime/basilisk/src/tests.rs | 8 +- .../src/weights/asset_registry.rs | 0 .../src/weights/balances.rs | 0 .../src/weights/collator_selection.rs | 0 .../src/weights/currencies.rs | 0 .../src/weights/democracy.rs | 0 .../src/weights/duster.rs | 0 .../src/weights/ema_oracle.rs | 0 .../{common => basilisk}/src/weights/lbp.rs | 0 .../src/weights/marketplace.rs | 0 .../{common => basilisk}/src/weights/mod.rs | 0 .../{common => basilisk}/src/weights/nft.rs | 0 .../src/weights/payment.rs | 0 .../src/weights/route_executor.rs | 0 .../src/weights/scheduler.rs | 0 .../src/weights/system.rs | 0 .../src/weights/timestamp.rs | 0 .../{common => basilisk}/src/weights/tips.rs | 0 .../src/weights/tokens.rs | 0 .../src/weights/transaction_pause.rs | 0 .../src/weights/treasury.rs | 0 .../src/weights/utility.rs | 0 .../src/weights/vesting.rs | 0 .../{common => basilisk}/src/weights/xcm.rs | 0 .../src/weights/xcmp_queue.rs | 0 .../{common => basilisk}/src/weights/xyk.rs | 0 .../src/weights/xyk_liquidity_mining.rs | 0 runtime/basilisk/src/xcm.rs | 45 +- runtime/common/Cargo.toml | 63 -- runtime/common/src/lib.rs | 310 ------ runtime/common/src/locked_balance.rs | 35 - 49 files changed, 1422 insertions(+), 1474 deletions(-) rename runtime/{common => basilisk}/src/adapter.rs (100%) create mode 100644 runtime/basilisk/src/democracy.rs create mode 100644 runtime/basilisk/src/finance.rs create mode 100644 runtime/basilisk/src/system.rs rename runtime/{common => basilisk}/src/weights/asset_registry.rs (100%) rename runtime/{common => basilisk}/src/weights/balances.rs (100%) rename runtime/{common => basilisk}/src/weights/collator_selection.rs (100%) rename runtime/{common => basilisk}/src/weights/currencies.rs (100%) rename runtime/{common => basilisk}/src/weights/democracy.rs (100%) rename runtime/{common => basilisk}/src/weights/duster.rs (100%) rename runtime/{common => basilisk}/src/weights/ema_oracle.rs (100%) rename runtime/{common => basilisk}/src/weights/lbp.rs (100%) rename runtime/{common => basilisk}/src/weights/marketplace.rs (100%) rename runtime/{common => basilisk}/src/weights/mod.rs (100%) rename runtime/{common => basilisk}/src/weights/nft.rs (100%) rename runtime/{common => basilisk}/src/weights/payment.rs (100%) rename runtime/{common => basilisk}/src/weights/route_executor.rs (100%) rename runtime/{common => basilisk}/src/weights/scheduler.rs (100%) rename runtime/{common => basilisk}/src/weights/system.rs (100%) rename runtime/{common => basilisk}/src/weights/timestamp.rs (100%) rename runtime/{common => basilisk}/src/weights/tips.rs (100%) rename runtime/{common => basilisk}/src/weights/tokens.rs (100%) rename runtime/{common => basilisk}/src/weights/transaction_pause.rs (100%) rename runtime/{common => basilisk}/src/weights/treasury.rs (100%) rename runtime/{common => basilisk}/src/weights/utility.rs (100%) rename runtime/{common => basilisk}/src/weights/vesting.rs (100%) rename runtime/{common => basilisk}/src/weights/xcm.rs (100%) rename runtime/{common => basilisk}/src/weights/xcmp_queue.rs (100%) rename runtime/{common => basilisk}/src/weights/xyk.rs (100%) rename runtime/{common => basilisk}/src/weights/xyk_liquidity_mining.rs (100%) delete mode 100644 runtime/common/Cargo.toml delete mode 100644 runtime/common/src/lib.rs delete mode 100644 runtime/common/src/locked_balance.rs diff --git a/Cargo.lock b/Cargo.lock index bb0ea6ea83d..72acdfe26a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -153,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -165,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -181,9 +181,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -413,7 +413,7 @@ dependencies = [ "polling", "rustix 0.37.19", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -490,7 +490,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide 0.6.2", - "object 0.30.3", + "object 0.30.4", "rustc-demangle", ] @@ -532,11 +532,10 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basilisk" -version = "10.0.0" +version = "10.0.1" dependencies = [ "basilisk-runtime", "clap", - "common-runtime", "cumulus-client-cli", "cumulus-client-collator", "cumulus-client-consensus-aura", @@ -613,9 +612,8 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "99.0.0" +version = "100.0.0" dependencies = [ - "common-runtime", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -1223,9 +1221,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", "clap_derive", @@ -1234,9 +1232,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", @@ -1247,9 +1245,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", "proc-macro2", @@ -1302,50 +1300,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "common-runtime" -version = "2.3.12" -dependencies = [ - "cumulus-pallet-xcmp-queue", - "frame-support", - "frame-system", - "hydradx-traits", - "orml-tokens", - "orml-traits", - "orml-vesting", - "pallet-asset-registry", - "pallet-balances", - "pallet-collator-selection", - "pallet-currencies", - "pallet-democracy", - "pallet-duster", - "pallet-ema-oracle", - "pallet-lbp", - "pallet-marketplace", - "pallet-nft", - "pallet-route-executor", - "pallet-scheduler", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-multi-payment", - "pallet-transaction-pause", - "pallet-transaction-payment", - "pallet-treasury", - "pallet-utility", - "pallet-xcm", - "pallet-xyk", - "pallet-xyk-liquidity-mining", - "parity-scale-codec", - "primitives", - "scale-info", - "sp-core", - "sp-npos-elections", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", -] - [[package]] name = "concurrent-queue" version = "2.2.0" @@ -2977,9 +2931,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -3453,9 +3407,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -3778,7 +3732,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hydra-dx-build-script-utils" version = "1.0.2" -source = "git+https://github.com/galacticcouncil/HydraDX-node?branch=master#bafa9778a2fb5313815899bbda610fe69f357396" +source = "git+https://github.com/galacticcouncil/HydraDX-node?branch=master#d08e5a86c6d9d0b502a1ad7cb241c9817c0ef74f" dependencies = [ "cargo-lock", "platforms 1.1.0", @@ -3847,7 +3801,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.9", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3871,9 +3825,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3911,9 +3865,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -4079,13 +4033,13 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", + "socket2 0.5.3", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] @@ -4443,9 +4397,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" [[package]] name = "libloading" @@ -4478,7 +4432,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.9", + "getrandom 0.2.10", "instant", "libp2p-core 0.38.0", "libp2p-dns", @@ -4660,7 +4614,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "tokio", "trust-dns-proto", "void", @@ -4821,7 +4775,7 @@ dependencies = [ "libc", "libp2p-core 0.38.0", "log", - "socket2", + "socket2 0.4.9", "tokio", ] @@ -5044,9 +4998,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -5695,9 +5649,9 @@ dependencies = [ [[package]] name = "object" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] @@ -5722,9 +5676,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -7337,10 +7291,9 @@ dependencies = [ [[package]] name = "parachain-runtime-mock" -version = "0.2.6" +version = "0.2.7" dependencies = [ "basilisk-runtime", - "common-runtime", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -7509,7 +7462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.8", ] [[package]] @@ -7528,15 +7481,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -7589,9 +7542,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -9060,7 +9013,7 @@ dependencies = [ [[package]] name = "primitives" -version = "6.4.6" +version = "6.5.0" dependencies = [ "frame-support", "frame-system", @@ -9387,7 +9340,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -9504,7 +9457,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] @@ -9556,11 +9509,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.3" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-syntax 0.7.2", ] @@ -11555,6 +11508,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -12614,15 +12577,16 @@ checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix 0.37.19", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -12859,7 +12823,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.9", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -13154,7 +13118,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -13359,12 +13323,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna 0.4.0", "percent-encoding", ] @@ -13380,7 +13344,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -13979,7 +13943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.9", "thiserror", "tokio", "webrtc-util", @@ -14178,9 +14142,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -14232,7 +14196,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] @@ -14263,37 +14227,13 @@ dependencies = [ "windows_x86_64_msvc 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -14466,11 +14406,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 48e6e041ff6..2d2da12d7a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ panic = 'unwind' [workspace] members = [ 'node', - 'runtime/common', 'runtime/basilisk', 'pallets/marketplace', 'pallets/xyk', diff --git a/integration-tests/parachain-runtime-mock/Cargo.toml b/integration-tests/parachain-runtime-mock/Cargo.toml index 3ef119b451f..ff5860cf36f 100644 --- a/integration-tests/parachain-runtime-mock/Cargo.toml +++ b/integration-tests/parachain-runtime-mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parachain-runtime-mock" -version = "0.2.6" +version = "0.2.7" description = "A mock runtime for a parachain" authors = ["GalacticCouncil"] edition = "2021" @@ -28,7 +28,6 @@ pallet-xyk = { path = "../../pallets/xyk",default-features = false} pallet-lbp = { path = "../../pallets/lbp", default-features = false } pallet-marketplace = { path = '../../pallets/marketplace', default-features = false } -common-runtime = { path = "../../runtime/common", default-features = true} primitives = { default-features = false, path = "../../primitives" } pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } diff --git a/integration-tests/parachain-runtime-mock/src/lib.rs b/integration-tests/parachain-runtime-mock/src/lib.rs index e49662b7970..e55949e5a99 100644 --- a/integration-tests/parachain-runtime-mock/src/lib.rs +++ b/integration-tests/parachain-runtime-mock/src/lib.rs @@ -250,7 +250,7 @@ impl pallet_xcm::Config for ParachainRuntime { type TrustedLockers = (); type SovereignAccountOf = (); type MaxLockers = ConstU32<8>; - type WeightInfo = common_runtime::weights::xcm::BasiliskWeight; + type WeightInfo = basilisk_runtime::weights::xcm::BasiliskWeight; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = (); } diff --git a/node/Cargo.toml b/node/Cargo.toml index 24e73617bf9..839aef52d86 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk" -version = "10.0.0" +version = "10.0.1" description = "Basilisk node" authors = ["GalacticCouncil"] edition = "2021" @@ -29,7 +29,6 @@ clap = { version = "4.1.8", features = [ "derive" ] } futures = "0.3.21" # local dependencies -common-runtime = { path = "../runtime/common" } basilisk-runtime = { path = "../runtime/basilisk" } primitives = { path = "../primitives" } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index e075651bdea..95b2135151f 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -22,12 +22,14 @@ use basilisk_runtime::{ AccountId, AssetRegistryConfig, AuraId, Balance, BalancesConfig, CollatorSelectionConfig, CouncilConfig, DusterConfig, ElectionsConfig, GenesisConfig, MultiTransactionPaymentConfig, ParachainInfoConfig, SessionConfig, - Signature, SystemConfig, TechnicalCommitteeConfig, TokensConfig, VestingConfig, NATIVE_EXISTENTIAL_DEPOSIT, UNITS, - WASM_BINARY, + Signature, SystemConfig, TechnicalCommitteeConfig, TokensConfig, VestingConfig, WASM_BINARY, }; use cumulus_primitives_core::ParaId; use hex_literal::hex; -use primitives::{AssetId, BlockNumber, Price}; +use primitives::{ + constants::currency::{NATIVE_EXISTENTIAL_DEPOSIT, UNITS}, + AssetId, BlockNumber, Price, +}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use sc_telemetry::TelemetryEndpoints; diff --git a/node/src/service.rs b/node/src/service.rs index da53561833c..18f12ea5155 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -19,7 +19,6 @@ #![allow(clippy::all)] -use common_runtime::{AccountId, Balance, Block, Index}; use cumulus_client_cli::CollatorOptions; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_common::{ParachainBlockImport as TParachainBlockImport, ParachainConsensus}; @@ -33,6 +32,7 @@ use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node; use jsonrpsee::RpcModule; use polkadot_service::CollatorPair; +use primitives::{AccountId, Balance, Block, Index}; use sc_consensus::ImportQueue; use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion}; use sc_network::NetworkService; diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 58d6ae596a1..0a57d43ae73 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "6.4.6" +version = "6.5.0" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/Basilisk-node" @@ -23,9 +23,9 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } [features] diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 27d562959dc..1a68fb76edf 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -26,7 +26,15 @@ use serde::{Deserialize, Serialize}; use scale_info::TypeInfo; -use frame_support::{parameter_types, sp_runtime::FixedU128}; +use frame_support::{ + parameter_types, + sp_runtime::FixedU128, + sp_runtime::{ + generic, + traits::{BlakeTwo256, IdentifyAccount, Verify}, + MultiSignature, Perbill, + }, +}; pub mod asset; pub mod constants; @@ -34,6 +42,32 @@ pub mod constants; /// An index to a block. pub type BlockNumber = u32; +/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. +pub type Signature = MultiSignature; + +/// Some way of identifying an account on the chain. We intentionally make it equivalent +/// to the public key of our transaction signing scheme. +pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + +/// The type for looking up accounts. We don't expect more than 4 billion of them, but you +/// never know... +pub type AccountIndex = u32; + +/// Index of a transaction in the chain. +pub type Index = u32; + +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; + +/// Opaque, encoded, unchecked extrinsic. +pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + +/// Header type. +pub type Header = generic::Header; + +/// Block type. +pub type Block = generic::Block; + /// Type used for expressing timestamp. pub type Moment = u64; @@ -55,6 +89,13 @@ pub type CollectionId = u128; /// NFT Item ID pub type ItemId = u128; +/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic +/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + parameter_types! { /// NFT metadata limit pub const UniquesStringLimit: u32 = 72; diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index fdf3feb8bce..6a013bf0f9d 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk-runtime" -version = "99.0.0" +version = "100.0.0" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" @@ -23,7 +23,6 @@ smallvec = "1.9.0" # local dependencies primitives = { default-features = false, path = "../../primitives" } -common-runtime = { path = '../common', default-features = false } pallet-xyk = { path = "../../pallets/xyk",default-features = false} pallet-lbp = { path = "../../pallets/lbp", default-features = false } pallet-marketplace = { path = '../../pallets/marketplace', default-features = false } diff --git a/runtime/common/src/adapter.rs b/runtime/basilisk/src/adapter.rs similarity index 100% rename from runtime/common/src/adapter.rs rename to runtime/basilisk/src/adapter.rs diff --git a/runtime/basilisk/src/benchmarking/currencies.rs b/runtime/basilisk/src/benchmarking/currencies.rs index 5b626de338c..6086e1a79dc 100644 --- a/runtime/basilisk/src/benchmarking/currencies.rs +++ b/runtime/basilisk/src/benchmarking/currencies.rs @@ -1,21 +1,19 @@ -use crate::{AccountId, Amount, AssetId, Balance, Currencies, NativeAssetId, Runtime, NATIVE_EXISTENTIAL_DEPOSIT}; - -use sp_std::prelude::*; +use super::*; +use crate::{Currencies, NativeAssetId, Runtime}; +use primitives::{constants::currency::NATIVE_EXISTENTIAL_DEPOSIT, AccountId, Amount, AssetId, Balance}; use frame_benchmarking::{account, whitelisted_caller}; use frame_system::RawOrigin; -use sp_runtime::traits::UniqueSaturatedInto; +use sp_std::prelude::*; use frame_benchmarking::BenchmarkError; -use frame_support::assert_ok; +use frame_support::{ + assert_ok, + sp_runtime::traits::{SaturatedConversion, StaticLookup, UniqueSaturatedInto}, +}; use orml_benchmarking::runtime_benchmarks; -use orml_traits::MultiCurrency; -use orml_traits::MultiCurrencyExtended; - -use super::*; - -use sp_runtime::traits::{SaturatedConversion, StaticLookup}; +use orml_traits::{MultiCurrency, MultiCurrencyExtended}; const SEED: u32 = 0; diff --git a/runtime/basilisk/src/benchmarking/mod.rs b/runtime/basilisk/src/benchmarking/mod.rs index 9a091af1104..575a63cecfa 100644 --- a/runtime/basilisk/src/benchmarking/mod.rs +++ b/runtime/basilisk/src/benchmarking/mod.rs @@ -16,8 +16,7 @@ use crate::Currencies; use frame_support::assert_ok; use frame_system::RawOrigin; -use common_runtime::AccountId; -use primitives::{AssetId, Balance}; +use primitives::{AccountId, AssetId, Balance}; use sp_std::vec; use sp_std::vec::Vec; diff --git a/runtime/basilisk/src/benchmarking/vesting.rs b/runtime/basilisk/src/benchmarking/vesting.rs index 51f4a47d144..a18b156fda5 100644 --- a/runtime/basilisk/src/benchmarking/vesting.rs +++ b/runtime/basilisk/src/benchmarking/vesting.rs @@ -1,25 +1,17 @@ -use crate::{AccountId, AssetId, Balance, NativeAssetId, Runtime}; -use crate::{BlockNumber, Currencies, MaxVestingSchedules, System, Vesting}; - use super::BSX; - -use common_runtime::VestingPalletId; - -use sp_std::prelude::*; +use crate::{Currencies, MaxVestingSchedules, NativeAssetId, Runtime, System, Vesting, VestingPalletId}; +use primitives::{constants::currency::NATIVE_EXISTENTIAL_DEPOSIT, AccountId, AssetId, Balance, BlockNumber}; use frame_benchmarking::{account, whitelisted_caller}; -use frame_support::assert_ok; +use frame_support::{ + assert_ok, + sp_runtime::traits::{AccountIdConversion, SaturatedConversion, StaticLookup}, +}; use frame_system::RawOrigin; -use sp_runtime::traits::AccountIdConversion; - use orml_benchmarking::runtime_benchmarks; -use orml_traits::MultiCurrency; -use orml_traits::MultiCurrencyExtended; +use orml_traits::{MultiCurrency, MultiCurrencyExtended}; use orml_vesting::VestingSchedule; - -use primitives::constants::currency::NATIVE_EXISTENTIAL_DEPOSIT; - -use sp_runtime::traits::{SaturatedConversion, StaticLookup}; +use sp_std::prelude::*; pub type Schedule = VestingSchedule; diff --git a/runtime/basilisk/src/democracy.rs b/runtime/basilisk/src/democracy.rs new file mode 100644 index 00000000000..dc9b7d2ca16 --- /dev/null +++ b/runtime/basilisk/src/democracy.rs @@ -0,0 +1,253 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use primitives::constants::{ + currency::{deposit, CENTS, DOLLARS}, + time::{DAYS, HOURS}, +}; + +use frame_support::{ + parameter_types, + sp_runtime::Percent, + traits::{EitherOfDiverse, LockIdentifier, U128CurrencyToVote}, +}; +use frame_system::EnsureRoot; +use pallet_collective::EnsureProportionAtLeast; + +// pallet democracy +parameter_types! { + pub const LaunchPeriod: BlockNumber = 3 * DAYS; + pub const VotingPeriod: BlockNumber = 3 * DAYS; + pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; + pub const MinimumDeposit: Balance = 1000 * DOLLARS; + pub const EnactmentPeriod: BlockNumber = 12 * HOURS; + // Make sure VoteLockingPeriod > EnactmentPeriod + pub const VoteLockingPeriod: BlockNumber = 6 * DAYS; + pub const CooloffPeriod: BlockNumber = 7 * DAYS; + pub const InstantAllowed: bool = true; + pub const MaxVotes: u32 = 100; + pub const MaxProposals: u32 = 100; +} + +pub type MajorityCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type UnanimousCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type SuperMajorityCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type SuperMajorityTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type UnanimousTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type MajorityTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; + +impl pallet_democracy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = MajorityCouncilOrRoot; + /// A majority can have the next scheduled referendum be a straight majority-carries vote + type ExternalMajorityOrigin = MajorityCouncilOrRoot; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = UnanimousCouncilOrRoot; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = MajorityTechCommitteeOrRoot; + type InstantOrigin = UnanimousTechCommitteeOrRoot; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = SuperMajorityCouncilOrRoot; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = UnanimousTechCommitteeOrRoot; + type BlacklistOrigin = EnsureRoot; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cooloff period. + type VetoOrigin = pallet_collective::EnsureMember; + type CooloffPeriod = CooloffPeriod; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type WeightInfo = weights::democracy::BasiliskWeight; + type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; + type VoteLockingPeriod = VoteLockingPeriod; +} + +// pallet elections phragmen +parameter_types! { + // Bond for candidacy into governance + pub const CandidacyBond: Balance = 5 * DOLLARS; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + pub const VotingBondBase: Balance = CENTS; + // additional data per vote is 32 bytes (account id). + pub const VotingBondFactor: Balance = CENTS; + pub const TermDuration: BlockNumber = 7 * DAYS; + pub const DesiredMembers: u32 = 7; + pub const DesiredRunnersUp: u32 = 9; + pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; + pub const MaxElectionCandidates: u32 = 1_000; + pub const MaxElectionVoters: u32 = 10_000; +} + +impl pallet_elections_phragmen::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type PalletId = ElectionsPhragmenPalletId; + type Currency = Balances; + type ChangeMembers = Council; + type InitializeMembers = (); // Set to () if defined in chain spec + type CurrencyToVote = U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; + type DesiredMembers = DesiredMembers; + type DesiredRunnersUp = DesiredRunnersUp; + type TermDuration = TermDuration; + type MaxCandidates = MaxElectionCandidates; + type MaxVoters = MaxElectionVoters; + type WeightInfo = (); +} + +// pallet collective - council collective +parameter_types! { + pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; + pub const CouncilMaxProposals: u32 = 13; + pub const CouncilMaxMembers: u32 = 7; +} + +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = (); +} + +// pallet collective - technical collective +parameter_types! { + pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; + pub const TechnicalMaxProposals: u32 = 20; + pub const TechnicalMaxMembers: u32 = 10; +} + +type TechnicalCollective = pallet_collective::Instance2; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = (); +} + +// pallet tips +parameter_types! { + pub const DataDepositPerByte: Balance = CENTS; + pub const TipCountdown: BlockNumber = 2 * HOURS; + pub const TipFindersFee: Percent = Percent::from_percent(1); + pub const TipReportDepositBase: Balance = 10 * DOLLARS; + pub const TipReportDepositPerByte: Balance = CENTS; + pub const MaximumReasonLength: u32 = 1024; +} + +impl pallet_tips::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type DataDepositPerByte = DataDepositPerByte; + type MaximumReasonLength = MaximumReasonLength; + type Tippers = Elections; + type TipCountdown = TipCountdown; + type TipFindersFee = TipFindersFee; + type TipReportDepositBase = TipReportDepositBase; + type WeightInfo = (); +} + +// pallet preimage +parameter_types! { + pub const PreimageMaxSize: u32 = 4096 * 1024; + pub PreimageBaseDeposit: Balance = deposit(2, 64); + pub PreimageByteDeposit: Balance = deposit(0, 1); +} + +impl pallet_preimage::Config for Runtime { + type WeightInfo = (); + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; +} + +// pallet identity +parameter_types! { + pub const BasicDeposit: Balance = 5 * DOLLARS; + pub const FieldDeposit: Balance = DOLLARS; + pub const SubAccountDeposit: Balance = 5 * DOLLARS; + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = MajorityCouncilOrRoot; + type RegistrarOrigin = MajorityCouncilOrRoot; + type WeightInfo = (); +} + +// pallet multisig +parameter_types! { + pub DepositBase: Balance = deposit(1, 88); + pub DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = (); +} diff --git a/runtime/basilisk/src/finance.rs b/runtime/basilisk/src/finance.rs new file mode 100644 index 00000000000..ebb1a9106be --- /dev/null +++ b/runtime/basilisk/src/finance.rs @@ -0,0 +1,407 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate::democracy::{SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, UnanimousTechCommitteeOrRoot}; +use crate::system::NativeAssetId; +use adapter::OrmlTokensAdapter; + +use hydradx_adapters::inspect::MultiInspectAdapter; +use hydradx_traits::{AssetPairAccountIdFor, LockedBalance, OraclePeriod}; +use pallet_currencies::BasicCurrencyAdapter; +use pallet_transaction_multi_payment::{AddTxAssetOnAccount, RemoveTxAssetOnKilled}; +use primitives::constants::{ + chain::{DISCOUNTED_FEE, MAX_IN_RATIO, MAX_OUT_RATIO, MIN_POOL_LIQUIDITY, MIN_TRADING_LIMIT}, + currency::{NATIVE_EXISTENTIAL_DEPOSIT, UNITS}, +}; + +use codec::Decode; +use frame_support::{ + parameter_types, + sp_runtime::{app_crypto::sp_core::crypto::UncheckedFrom, traits::Zero}, + traits::{AsEnsureOriginWithArg, Contains, Defensive, EnsureOrigin, NeverEnsureOrigin, Get, LockIdentifier}, + BoundedVec, PalletId, +}; +use frame_system::RawOrigin; +use orml_tokens::CurrencyAdapter; +use orml_traits::currency::MutationHooks; + +pub struct RelayChainAssetId; +impl Get for RelayChainAssetId { + fn get() -> AssetId { + let invalid_id = pallet_asset_registry::Pallet::::next_asset_id().defensive_unwrap_or(AssetId::MAX); + + match pallet_asset_registry::Pallet::::location_to_asset(RELAY_CHAIN_ASSET_LOCATION) { + Some(asset_id) => asset_id, + None => invalid_id, + } + } +} + +type KusamaCurrency = CurrencyAdapter; + +// pallet balances +parameter_types! { + pub const NativeExistentialDeposit: u128 = NATIVE_EXISTENTIAL_DEPOSIT; + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; +} + +impl pallet_balances::Config for Runtime { + type MaxLocks = MaxLocks; + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type DustRemoval = Treasury; + type ExistentialDeposit = NativeExistentialDeposit; + type AccountStore = System; + type WeightInfo = weights::balances::BasiliskWeight; + type MaxReserves = MaxReserves; + type ReserveIdentifier = (); +} + +// pallet orml tokens +pub struct CurrencyHooks; +impl MutationHooks for CurrencyHooks { + type OnDust = Duster; + type OnSlash = (); + type PreDeposit = (); + type PostDeposit = (); + type PreTransfer = (); + type PostTransfer = (); + type OnNewTokenAccount = AddTxAssetOnAccount; + type OnKilledTokenAccount = RemoveTxAssetOnKilled; +} + +pub struct DustRemovalWhitelist; +impl Contains for DustRemovalWhitelist { + fn contains(a: &AccountId) -> bool { + get_all_module_accounts().contains(a) || pallet_duster::DusterWhitelist::::contains(a) + } +} + +impl orml_tokens::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = AssetId; + type WeightInfo = weights::tokens::BasiliskWeight; + type ExistentialDeposits = AssetRegistry; + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = (); + type DustRemovalWhitelist = DustRemovalWhitelist; + type CurrencyHooks = CurrencyHooks; +} + +// The latest versions of the orml-currencies pallet don't emit events. +// The infrastructure relies on the events from this pallet, so we use the latest version of +// the pallet that contains and emit events and was updated to the polkadot version we use. +impl pallet_currencies::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MultiCurrency = OrmlTokensAdapter; + type NativeCurrency = BasicCurrencyAdapter; + type GetNativeCurrencyId = NativeAssetId; + type WeightInfo = weights::currencies::BasiliskWeight; +} + +// pallet xyk +parameter_types! { + pub ExchangeFee: (u32, u32) = (3, 1_000); + pub const MinTradingLimit: Balance = MIN_TRADING_LIMIT; + pub const MinPoolLiquidity: Balance = MIN_POOL_LIQUIDITY; + pub const MaxInRatio: u128 = MAX_IN_RATIO; + pub const MaxOutRatio: u128 = MAX_OUT_RATIO; + pub const RegistryStrLimit: u32 = 32; + pub const DiscountedFee: (u32, u32) = DISCOUNTED_FEE; +} + +pub struct AssetPairAccountId(PhantomData); +impl AssetPairAccountIdFor for AssetPairAccountId +where + T::AccountId: UncheckedFrom + AsRef<[u8]>, +{ + fn from_assets(asset_a: AssetId, asset_b: AssetId, identifier: &str) -> T::AccountId { + let mut buf: Vec = identifier.as_bytes().to_vec(); + + if asset_a < asset_b { + buf.extend_from_slice(&asset_a.to_le_bytes()); + buf.extend_from_slice(&asset_b.to_le_bytes()); + } else { + buf.extend_from_slice(&asset_b.to_le_bytes()); + buf.extend_from_slice(&asset_a.to_le_bytes()); + } + T::AccountId::unchecked_from(::hash(&buf[..])) + } +} + +impl pallet_xyk::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AssetRegistry = AssetRegistry; + type AssetPairAccountId = AssetPairAccountId; + type Currency = Currencies; + type NativeAssetId = NativeAssetId; + type WeightInfo = weights::xyk::BasiliskWeight; + type GetExchangeFee = ExchangeFee; + type MinTradingLimit = MinTradingLimit; + type MinPoolLiquidity = MinPoolLiquidity; + type MaxInRatio = MaxInRatio; + type MaxOutRatio = MaxOutRatio; + type CanCreatePool = pallet_lbp::DisallowWhenLBPPoolRunning; + type AMMHandler = pallet_ema_oracle::OnActivityHandler; + type DiscountedFee = DiscountedFee; + type NonDustableWhitelistHandler = Duster; +} + +// pallet lbp +parameter_types! { + pub LBPExchangeFee: (u32, u32) = (2, 1_000); +} + +pub struct MultiCurrencyLockedBalance(PhantomData); + +impl + LockedBalance for MultiCurrencyLockedBalance +where + AssetId: Into<::CurrencyId>, + Balance: From<::Balance>, + Balance: From<::Balance>, +{ + fn get_by_lock(lock_id: LockIdentifier, currency_id: AssetId, who: T::AccountId) -> Balance { + if currency_id == NativeAssetId::get() { + match pallet_balances::Pallet::::locks(who) + .into_iter() + .find(|lock| lock.id == lock_id) + { + Some(lock) => lock.amount.into(), + None => Zero::zero(), + } + } else { + match orml_tokens::Pallet::::locks(who, currency_id.into()) + .into_iter() + .find(|lock| lock.id == lock_id) + { + Some(lock) => lock.amount.into(), + None => Zero::zero(), + } + } + } +} + +impl pallet_lbp::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MultiCurrency = Currencies; + type LockedBalance = MultiCurrencyLockedBalance; + type CreatePoolOrigin = SuperMajorityTechCommitteeOrRoot; + type LBPWeightFunction = pallet_lbp::LBPWeightFunction; + type AssetPairAccountId = AssetPairAccountId; + type MinTradingLimit = MinTradingLimit; + type MinPoolLiquidity = MinPoolLiquidity; + type MaxInRatio = MaxInRatio; + type MaxOutRatio = MaxOutRatio; + type WeightInfo = weights::lbp::BasiliskWeight; + type BlockNumberProvider = RelayChainBlockNumberProvider; +} + +// pallet vesting +parameter_types! { + pub MinVestedTransfer: Balance = 100_000; + pub const MaxVestingSchedules: u32 = 15; + pub const VestingPalletId: PalletId = PalletId(*b"py/vstng"); +} + +pub struct RootAsVestingPallet; +impl EnsureOrigin for RootAsVestingPallet { + type Success = AccountId; + + fn try_origin(o: RuntimeOrigin) -> Result { + Into::, RuntimeOrigin>>::into(o).and_then(|o| match o { + RawOrigin::Root => Ok(VestingPalletId::get().into_account_truncating()), + r => Err(RuntimeOrigin::from(r)), + }) + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"); + Ok(RuntimeOrigin::from(RawOrigin::Signed(zero_account_id))) + } +} + +impl orml_vesting::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type MinVestedTransfer = MinVestedTransfer; + type VestedTransferOrigin = RootAsVestingPallet; + type WeightInfo = weights::vesting::BasiliskWeight; + type MaxVestingSchedules = MaxVestingSchedules; + type BlockNumberProvider = RelayChainBlockNumberProvider; +} + +// pallet marketplace +parameter_types! { + pub const MinimumOfferAmount: Balance = UNITS / 100; + pub const RoyaltyBondAmount: Balance = 0; +} + +impl pallet_marketplace::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = KusamaCurrency; + type WeightInfo = pallet_marketplace::weights::BasiliskWeight; + type MinimumOfferAmount = MinimumOfferAmount; + type RoyaltyBondAmount = RoyaltyBondAmount; +} + +pub mod ksm { + use primitives::Balance; + + pub const UNITS: Balance = 1_000_000_000_000; + pub const CENTS: Balance = UNITS / 30_000; + pub const MILLICENTS: Balance = CENTS / 1_000; + + pub const fn deposit(items: u32, bytes: u32) -> Balance { + (items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS) / 10 + } +} + +// pallet uniques +parameter_types! { + pub const CollectionDeposit: Balance = 0; + pub const ItemDeposit: Balance = 0; + pub const KeyLimit: u32 = 256; // Max 256 bytes per key + pub const ValueLimit: u32 = 1024; // Max 1024 bytes per value + pub const UniquesMetadataDepositBase: Balance = ksm::deposit(1,129); + pub const AttributeDepositBase: Balance = ksm::deposit(1,0); + pub const DepositPerByte: Balance = ksm::deposit(0,1); +} + +impl pallet_uniques::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type CollectionId = CollectionId; + type ItemId = ItemId; + type Currency = KusamaCurrency; + type ForceOrigin = SuperMajorityCouncilOrRoot; + // Standard collection creation is disallowed + type CreateOrigin = AsEnsureOriginWithArg>; + type Locker = (); + type CollectionDeposit = CollectionDeposit; + type ItemDeposit = ItemDeposit; + type MetadataDepositBase = UniquesMetadataDepositBase; + type AttributeDepositBase = AttributeDepositBase; + type DepositPerByte = DepositPerByte; + type StringLimit = primitives::UniquesStringLimit; + type KeyLimit = KeyLimit; + type ValueLimit = ValueLimit; + type WeightInfo = (); + #[cfg(feature = "runtime-benchmarks")] + type Helper = (); +} + +// pallet liquidity mining +parameter_types! { + pub const LMPalletId: PalletId = PalletId(*b"LiqMinId"); + pub const LiquidityMiningNftCollectionId: primitives::CollectionId = 1; +} + +impl pallet_xyk_liquidity_mining::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MultiCurrency = Currencies; + type CreateOrigin = UnanimousTechCommitteeOrRoot; + type PalletId = LMPalletId; + type NftCollectionId = LiquidityMiningNftCollectionId; + type AMM = XYK; + type WeightInfo = weights::xyk_liquidity_mining::BasiliskWeight; + type NFTHandler = NFT; + type LiquidityMiningHandler = XYKWarehouseLM; + type NonDustableWhitelistHandler = Duster; +} + +// warehouse pallet liquidity mining +parameter_types! { + pub const WarehouseLMPalletId: PalletId = PalletId(*b"WhouseLm"); + pub const MaxEntriesPerDeposit: u8 = 5; //NOTE: Rebenchmark when this change, TODO: + pub const MaxYieldFarmsPerGlobalFarm: u8 = 50; //NOTE: Includes deleted/destroyed farms, TODO: + pub const MinPlannedYieldingPeriods: BlockNumber = 100_800; //1w, TODO: + pub const MinTotalFarmRewards: Balance = NATIVE_EXISTENTIAL_DEPOSIT * 100; //TODO: +} + +type XYKLiquidityMiningInstance = warehouse_liquidity_mining::Instance1; +impl warehouse_liquidity_mining::Config for Runtime { + type AssetId = AssetId; + type MultiCurrency = Currencies; + type PalletId = WarehouseLMPalletId; + type MinTotalFarmRewards = MinTotalFarmRewards; + type MinPlannedYieldingPeriods = MinPlannedYieldingPeriods; + type BlockNumberProvider = RelayChainBlockNumberProvider; + type AmmPoolId = AccountId; + type MaxFarmEntriesPerDeposit = MaxEntriesPerDeposit; + type MaxYieldFarmsPerGlobalFarm = MaxYieldFarmsPerGlobalFarm; + type AssetRegistry = AssetRegistry; + type NonDustableWhitelistHandler = Duster; + type RuntimeEvent = RuntimeEvent; + type PriceAdjustment = warehouse_liquidity_mining::DefaultPriceAdjustment; +} + +// pallet route executor +parameter_types! { + pub const MaxNumberOfTrades: u8 = 5; +} + +impl pallet_route_executor::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AssetId = AssetId; + type Balance = Balance; + type MaxNumberOfTrades = MaxNumberOfTrades; + type Currency = MultiInspectAdapter; + type AMM = (XYK, LBP); + type WeightInfo = weights::route_executor::BasiliskWeight; +} + +// pallet ema oracle +parameter_types! { + pub SupportedPeriods: BoundedVec> = BoundedVec::truncate_from( + vec![OraclePeriod::LastBlock, OraclePeriod::Hour, OraclePeriod::Day, OraclePeriod::Week] + ); + // There are currently only a few pools, so the number of entries per block is limited. + // NOTE: Needs to be updated once the number of pools grows. + pub MaxUniqueOracleEntries: u32 = 30; +} + +impl pallet_ema_oracle::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::ema_oracle::BasiliskWeight; + type BlockNumberProvider = RelayChainBlockNumberProvider; + type SupportedPeriods = SupportedPeriods; + type MaxUniqueEntries = MaxUniqueOracleEntries; +} + +// pallet nft +parameter_types! { + pub ReserveCollectionIdUpTo: u128 = 999_999; +} + +impl pallet_nft::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::nft::BasiliskWeight; + type NftCollectionId = CollectionId; + type NftItemId = ItemId; + type CollectionType = pallet_nft::CollectionType; + type Permissions = pallet_nft::NftPermissions; + type ReserveCollectionIdUpTo = ReserveCollectionIdUpTo; +} diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 33dc329de03..f522e069b37 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Basilisk-node. -// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,67 +24,46 @@ #![allow(clippy::from_over_into)] #![allow(clippy::match_like_matches_macro)] -#[cfg(test)] -mod tests; - // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -use frame_system::{EnsureRoot, RawOrigin}; -use hydradx_adapters::inspect::MultiInspectAdapter; -use sp_api::impl_runtime_apis; -use sp_core::{ConstU32, OpaqueMetadata}; -use sp_runtime::{ - app_crypto::sp_core::crypto::UncheckedFrom, +#[cfg(test)] +mod tests; + +mod benchmarking; +mod migrations; +pub mod weights; + +mod adapter; +mod democracy; +mod finance; +mod system; +mod xcm; + +pub use democracy::*; +pub use finance::*; +pub use system::*; +pub use xcm::*; + +pub use primitives::{AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Signature}; + +use frame_support::sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, IdentityLookup}, + traits::{AccountIdConversion, BlakeTwo256, Block as BlockT}, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, Perbill, + ApplyExtrinsicResult, }; -use sp_std::convert::From; -use sp_std::marker::PhantomData; -use sp_std::prelude::*; +use sp_api::impl_runtime_apis; +pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use sp_core::{ConstU32, OpaqueMetadata}; +use sp_std::{convert::From, marker::PhantomData, prelude::*, vec}; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; -#[cfg(feature = "runtime-benchmarks")] -use codec::Decode; - // A few exports that help ease life for downstream crates. -use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - parameter_types, - traits::{ - AsEnsureOriginWithArg, Contains, Defensive, EitherOfDiverse, EnsureOrigin, EqualPrivilegeOnly, Get, - InstanceFilter, NeverEnsureOrigin, U128CurrencyToVote, - }, - weights::{ - constants::{BlockExecutionWeight, RocksDbWeight}, - ConstantMultiplier, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, - }, - BoundedVec, -}; -use hydradx_traits::{AssetPairAccountIdFor, OraclePeriod}; -use pallet_transaction_payment::TargetedFeeAdjustment; -pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; - -mod xcm; - -mod benchmarking; - -use orml_tokens::CurrencyAdapter; -use orml_traits::currency::MutationHooks; -use pallet_collective::EnsureProportionAtLeast; -use pallet_currencies::BasicCurrencyAdapter; - -use common_runtime::locked_balance::MultiCurrencyLockedBalance; -pub use common_runtime::*; -use pallet_transaction_multi_payment::{AddTxAssetOnAccount, DepositAll, RemoveTxAssetOnKilled, TransferFees}; - -mod migrations; +use frame_support::{construct_runtime, weights::Weight}; /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats @@ -113,7 +92,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 99, + spec_version: 100, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -129,68 +108,20 @@ pub fn native_version() -> NativeVersion { } } -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &RuntimeCall) -> bool { - if matches!( - call, - RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_) - ) { - // always allow - // Note: this is done to avoid unnecessary check of paused storage. - return true; - } - - if pallet_transaction_pause::PausedTransactionFilter::::contains(call) { - // if paused, dont allow! - return false; - } - - match call { - RuntimeCall::Uniques(_) => false, - RuntimeCall::PolkadotXcm(_) => false, - RuntimeCall::OrmlXcm(_) => false, - _ => true, - } - } +pub fn get_all_module_accounts() -> vec::Vec { + vec![ + system::TreasuryPalletId::get().into_account_truncating(), + finance::VestingPalletId::get().into_account_truncating(), + ] } -use common_runtime::adapter::OrmlTokensAdapter; -use primitives::{CollectionId, ItemId}; -use smallvec::smallvec; use sp_runtime::traits::BlockNumberProvider; -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - - /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the - /// node's balance type. - /// - /// This should typically create a mapping between the following ranges: - /// - [0, MAXIMUM_BLOCK_WEIGHT] - /// - [Balance::min, Balance::max] - /// - /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: - /// - Setting it to `0` will essentially disable the weight fee. - /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. - fn polynomial() -> WeightToFeeCoefficients { - let p = 11 * CENTS; - let q = Balance::from(ExtrinsicBaseWeight::get().ref_time()); - smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - // Relay chain Block number provider. // Reason why the implementation is different for benchmarks is that it is not possible // to set or change the block number in a benchmark using parachain system pallet. // That's why we revert to using the system pallet in the benchmark. -pub struct RelayChainBlockNumberProvider(sp_std::marker::PhantomData); +pub struct RelayChainBlockNumberProvider(PhantomData); #[cfg(not(feature = "runtime-benchmarks"))] impl BlockNumberProvider @@ -218,772 +149,6 @@ impl BlockNumberProvider for RelayChainBlockNumberProvi } } -pub struct AssetPairAccountId(PhantomData); -impl AssetPairAccountIdFor for AssetPairAccountId -where - T::AccountId: UncheckedFrom + AsRef<[u8]>, -{ - fn from_assets(asset_a: AssetId, asset_b: AssetId, identifier: &str) -> T::AccountId { - let mut buf: Vec = identifier.as_bytes().to_vec(); - - if asset_a < asset_b { - buf.extend_from_slice(&asset_a.to_le_bytes()); - buf.extend_from_slice(&asset_b.to_le_bytes()); - } else { - buf.extend_from_slice(&asset_b.to_le_bytes()); - buf.extend_from_slice(&asset_a.to_le_bytes()); - } - T::AccountId::unchecked_from(::hash(&buf[..])) - } -} - -parameter_types! { - pub const Version: RuntimeVersion = VERSION; - /// Block weights base values and limits. - pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() - .base_block(BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get(); - }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have an extra reserved space, so that they - // are included even if block reachd `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - - pub ExtrinsicBaseWeight: Weight = common_runtime::BasiliskExtrinsicBaseWeight::get(); -} - -// Configure FRAME pallets to include in runtime. - -impl frame_system::Config for Runtime { - /// The basic call filter to use in dispatchable. - type BaseCallFilter = BaseFilter; - type BlockWeights = BlockWeights; - type BlockLength = BlockLength; - /// The ubiquitous origin type. - type RuntimeOrigin = RuntimeOrigin; - /// The aggregated dispatch type that is available for extrinsics. - type RuntimeCall = RuntimeCall; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The hashing algorithm used. - type Hashing = BlakeTwo256; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = IdentityLookup; - /// The header type. - type Header = generic::Header; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// The weight of the overhead invoked on the block import process, independent of the - /// extrinsics included in that block. - /// Version of the runtime. - type Version = Version; - /// Converts a module to the index of the module in `construct_runtime!`. - /// - /// This type is being generated by `construct_runtime!`. - type PalletInfo = PalletInfo; - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - /// What to do if a new account is created. - type OnNewAccount = (); - /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = weights::system::BasiliskWeight; - type SS58Prefix = SS58Prefix; - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = weights::timestamp::BasiliskWeight; -} - -impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = Treasury; - type ExistentialDeposit = NativeExistentialDeposit; - type AccountStore = System; - type WeightInfo = weights::balances::BasiliskWeight; - type MaxReserves = MaxReserves; - type ReserveIdentifier = (); -} - -/// Parameterized slow adjusting fee updated based on -/// https://w3f-research.readthedocs.io/en/latest/polkadot/overview/2-token-economics.html?highlight=token%20economics#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = TransferFees, TreasuryAccount>; - type OperationalFeeMultiplier = (); - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; -} - -parameter_types! { - pub TreasuryAccount: AccountId = Treasury::account_id(); -} - -impl pallet_transaction_multi_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type AcceptedCurrencyOrigin = MajorityTechCommitteeOrRoot; - type Currencies = Currencies; - type SpotPriceProvider = pallet_xyk::XYKSpotPrice; - type WeightInfo = weights::payment::BasiliskWeight; - type WeightToFee = WeightToFee; - type NativeAssetId = NativeAssetId; -} - -impl InstanceFilter for ProxyType { - fn filter(&self, c: &RuntimeCall) -> bool { - match self { - ProxyType::Any => true, - ProxyType::CancelProxy => matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })), - ProxyType::Governance => matches!( - c, - RuntimeCall::Democracy(..) - | RuntimeCall::Council(..) - | RuntimeCall::TechnicalCommittee(..) - | RuntimeCall::Elections(..) - | RuntimeCall::Treasury(..) - | RuntimeCall::Tips(..) - | RuntimeCall::Utility(..) - ), - ProxyType::Exchange => matches!(c, RuntimeCall::XYK(..) | RuntimeCall::LBP(..) | RuntimeCall::NFT(..)), - // Transfer group doesn't include cross-chain transfers - ProxyType::Transfer => matches!( - c, - RuntimeCall::Balances(..) | RuntimeCall::Currencies(..) | RuntimeCall::Tokens(..) - ), - } - } - fn is_superset(&self, o: &Self) -> bool { - match (self, o) { - (x, y) if x == y => true, - (ProxyType::Any, _) => true, - (_, ProxyType::Any) => false, - _ => false, - } - } -} - -impl pallet_proxy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Currency = Balances; - type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; - type WeightInfo = (); - type MaxPending = MaxPending; - type CallHasher = BlakeTwo256; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; -} - -pub struct DustRemovalWhitelist; -impl Contains for DustRemovalWhitelist { - fn contains(a: &AccountId) -> bool { - get_all_module_accounts().contains(a) || pallet_duster::DusterWhitelist::::contains(a) - } -} - -pub struct CurrencyHooks; -impl MutationHooks for CurrencyHooks { - type OnDust = Duster; - type OnSlash = (); - type PreDeposit = (); - type PostDeposit = (); - type PreTransfer = (); - type PostTransfer = (); - type OnNewTokenAccount = AddTxAssetOnAccount; - type OnKilledTokenAccount = RemoveTxAssetOnKilled; -} - -/// Tokens Configurations -impl orml_tokens::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = Amount; - type CurrencyId = AssetId; - type WeightInfo = weights::tokens::BasiliskWeight; - type ExistentialDeposits = AssetRegistry; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type ReserveIdentifier = (); - type DustRemovalWhitelist = DustRemovalWhitelist; - type CurrencyHooks = CurrencyHooks; -} - -// The latest versions of the orml-currencies pallet don't emit events. -// The infrastructure relies on the events from this pallet, so we use the latest version of -// the pallet that contains and emit events and was updated to the polkadot version we use. -impl pallet_currencies::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MultiCurrency = OrmlTokensAdapter; - type NativeCurrency = BasicCurrencyAdapter; - type GetNativeCurrencyId = NativeAssetId; - type WeightInfo = weights::currencies::BasiliskWeight; -} - -impl pallet_duster::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = Amount; - type CurrencyId = AssetId; - type MultiCurrency = Currencies; - type MinCurrencyDeposits = AssetRegistry; - type Reward = DustingReward; - type NativeCurrencyId = NativeAssetId; - type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; - type WeightInfo = weights::duster::BasiliskWeight; -} - -impl pallet_asset_registry::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; - type AssetId = AssetId; - type Balance = Balance; - type AssetNativeLocation = AssetLocation; - type StringLimit = RegistryStrLimit; - type SequentialIdStartAt = SequentialIdOffset; - type NativeAssetId = NativeAssetId; - type WeightInfo = weights::asset_registry::BasiliskWeight; -} - -impl pallet_xyk::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type AssetRegistry = AssetRegistry; - type AssetPairAccountId = AssetPairAccountId; - type Currency = Currencies; - type NativeAssetId = NativeAssetId; - type WeightInfo = weights::xyk::BasiliskWeight; - type GetExchangeFee = ExchangeFee; - type MinTradingLimit = MinTradingLimit; - type MinPoolLiquidity = MinPoolLiquidity; - type MaxInRatio = MaxInRatio; - type MaxOutRatio = MaxOutRatio; - type CanCreatePool = pallet_lbp::DisallowWhenLBPPoolRunning; - type AMMHandler = pallet_ema_oracle::OnActivityHandler; - type DiscountedFee = DiscountedFee; - type NonDustableWhitelistHandler = Duster; -} - -impl pallet_lbp::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MultiCurrency = Currencies; - type LockedBalance = MultiCurrencyLockedBalance; - type CreatePoolOrigin = SuperMajorityTechCommitteeOrRoot; - type LBPWeightFunction = pallet_lbp::LBPWeightFunction; - type AssetPairAccountId = AssetPairAccountId; - type MinTradingLimit = MinTradingLimit; - type MinPoolLiquidity = MinPoolLiquidity; - type MaxInRatio = MaxInRatio; - type MaxOutRatio = MaxOutRatio; - type WeightInfo = weights::lbp::BasiliskWeight; - type BlockNumberProvider = RelayChainBlockNumberProvider; -} - -// Parachain Config - -parameter_types! { - pub ReservedXcmpWeight: Weight = BlockWeights::get().max_block / 4; - pub ReservedDmpWeight: Weight = BlockWeights::get().max_block / 4; -} - -impl cumulus_pallet_parachain_system::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = pallet_relaychain_info::OnValidationDataHandler; - type SelfParaId = ParachainInfo; - type OutboundXcmpMessageSource = XcmpQueue; - type DmpMessageHandler = DmpQueue; - type ReservedDmpWeight = ReservedDmpWeight; - type XcmpMessageHandler = XcmpQueue; - type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -} - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type MaxAuthorities = MaxAuthorities; - type DisabledValidators = (); -} - -impl parachain_info::Config for Runtime {} - -impl cumulus_pallet_aura_ext::Config for Runtime {} - -parameter_types! { - pub ReserveCollectionIdUpTo: u128 = 999_999; -} - -impl pallet_nft::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::nft::BasiliskWeight; - type NftCollectionId = CollectionId; - type NftItemId = ItemId; - type CollectionType = pallet_nft::CollectionType; - type Permissions = pallet_nft::NftPermissions; - type ReserveCollectionIdUpTo = ReserveCollectionIdUpTo; -} - -type MajorityCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -type UnanimousCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -type SuperMajorityCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -type SuperMajorityTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; -type UnanimousTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; -type MajorityTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; - -impl pallet_democracy::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = MajorityCouncilOrRoot; - /// A majority can have the next scheduled referendum be a straight majority-carries vote - type ExternalMajorityOrigin = MajorityCouncilOrRoot; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = UnanimousCouncilOrRoot; - /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = MajorityTechCommitteeOrRoot; - type InstantOrigin = UnanimousTechCommitteeOrRoot; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = SuperMajorityCouncilOrRoot; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = UnanimousTechCommitteeOrRoot; - type BlacklistOrigin = EnsureRoot; - // Any single technical committee member may veto a coming council proposal, however they can - // only do it once and it lasts only for the cooloff period. - type VetoOrigin = pallet_collective::EnsureMember; - type CooloffPeriod = CooloffPeriod; - type Slash = Treasury; - type Scheduler = Scheduler; - type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type WeightInfo = weights::democracy::BasiliskWeight; - type MaxProposals = MaxProposals; - type Preimages = Preimage; - type MaxDeposits = ConstU32<100>; - type MaxBlacklisted = ConstU32<100>; - type VoteLockingPeriod = VoteLockingPeriod; -} - -impl pallet_elections_phragmen::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type PalletId = ElectionsPhragmenPalletId; - type Currency = Balances; - type ChangeMembers = Council; - type InitializeMembers = (); // Set to () if defined in chain spec - type CurrencyToVote = U128CurrencyToVote; - type CandidacyBond = CandidacyBond; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; - type LoserCandidate = Treasury; - type KickedMember = Treasury; - type DesiredMembers = DesiredMembers; - type DesiredRunnersUp = DesiredRunnersUp; - type TermDuration = TermDuration; - type MaxCandidates = MaxElectionCandidates; - type MaxVoters = MaxElectionVoters; - type WeightInfo = (); -} - -type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = (); -} - -type TechnicalCollective = pallet_collective::Instance2; -impl pallet_collective::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type MotionDuration = TechnicalMotionDuration; - type MaxProposals = TechnicalMaxProposals; - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = (); -} - -impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; - type Currency = Balances; - type ApproveOrigin = SuperMajorityCouncilOrRoot; - type RejectOrigin = MajorityCouncilOrRoot; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type BurnDestination = (); - type WeightInfo = weights::treasury::BasiliskWeight; - type SpendFunds = (); - type MaxApprovals = MaxApprovals; - type SpendOrigin = NeverEnsureOrigin; -} - -parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; - pub const NoPreimagePostponement: Option = Some(5 * MINUTES); -} - -impl pallet_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::scheduler::BasiliskWeight; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type Preimages = Preimage; -} - -impl pallet_utility::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = weights::utility::BasiliskWeight; - type PalletsOrigin = OriginCaller; -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (CollatorSelection,); -} - -impl pallet_tips::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type DataDepositPerByte = DataDepositPerByte; - type MaximumReasonLength = MaximumReasonLength; - type Tippers = Elections; - type TipCountdown = TipCountdown; - type TipFindersFee = TipFindersFee; - type TipReportDepositBase = TipReportDepositBase; - type WeightInfo = (); -} - -impl pallet_collator_selection::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type UpdateOrigin = MajorityTechCommitteeOrRoot; - type PotId = PotId; - type MaxCandidates = MaxCandidates; - type MinCandidates = MinCandidates; - type MaxInvulnerables = MaxInvulnerables; - // should be a multiple of session or things will get inconsistent - type KickThreshold = Period; - type ValidatorId = ::AccountId; - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ValidatorRegistration = Session; - type WeightInfo = weights::collator_selection::BasiliskWeight; -} - -impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - // we don't have stash and controller, thus we don't need the convert as well. - type ValidatorIdOf = pallet_collator_selection::IdentityCollator; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = CollatorRewards; - // Essentially just Aura, but lets be pedantic. - type SessionHandler = ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; - type WeightInfo = (); -} - -pub struct RootAsVestingPallet; -impl EnsureOrigin for RootAsVestingPallet { - type Success = AccountId; - - fn try_origin(o: RuntimeOrigin) -> Result { - Into::, RuntimeOrigin>>::into(o).and_then(|o| match o { - RawOrigin::Root => Ok(VestingPalletId::get().into_account_truncating()), - r => Err(RuntimeOrigin::from(r)), - }) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) - .expect("infinite length input; no invalid inputs for type; qed"); - Ok(RuntimeOrigin::from(RawOrigin::Signed(zero_account_id))) - } -} - -impl orml_vesting::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type MinVestedTransfer = MinVestedTransfer; - type VestedTransferOrigin = RootAsVestingPallet; - type WeightInfo = weights::vesting::BasiliskWeight; - type MaxVestingSchedules = MaxVestingSchedules; - type BlockNumberProvider = RelayChainBlockNumberProvider; -} - -parameter_types! { - pub const MinimumOfferAmount: Balance = UNITS / 100; - pub const RoyaltyBondAmount: Balance = 0; -} - -pub struct RelayChainAssetId; -impl Get for RelayChainAssetId { - fn get() -> AssetId { - let invalid_id = pallet_asset_registry::Pallet::::next_asset_id().defensive_unwrap_or(AssetId::MAX); - - match pallet_asset_registry::Pallet::::location_to_asset(RELAY_CHAIN_ASSET_LOCATION) { - Some(asset_id) => asset_id, - None => invalid_id, - } - } -} - -type KusamaCurrency = CurrencyAdapter; - -impl pallet_marketplace::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = KusamaCurrency; - type WeightInfo = pallet_marketplace::weights::BasiliskWeight; - type MinimumOfferAmount = MinimumOfferAmount; - type RoyaltyBondAmount = RoyaltyBondAmount; -} - -pub mod ksm { - use primitives::Balance; - - pub const UNITS: Balance = 1_000_000_000_000; - pub const CENTS: Balance = UNITS / 30_000; - pub const MILLICENTS: Balance = CENTS / 1_000; - - pub const fn deposit(items: u32, bytes: u32) -> Balance { - (items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS) / 10 - } -} - -parameter_types! { - pub const CollectionDeposit: Balance = 0; - pub const ItemDeposit: Balance = 0; - pub const KeyLimit: u32 = 256; // Max 256 bytes per key - pub const ValueLimit: u32 = 1024; // Max 1024 bytes per value - pub const UniquesMetadataDepositBase: Balance = ksm::deposit(1,129); - pub const AttributeDepositBase: Balance = ksm::deposit(1,0); - pub const DepositPerByte: Balance = ksm::deposit(0,1); -} - -impl pallet_uniques::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type CollectionId = CollectionId; - type ItemId = ItemId; - type Currency = KusamaCurrency; - type ForceOrigin = SuperMajorityCouncilOrRoot; - // Standard collection creation is disallowed - type CreateOrigin = AsEnsureOriginWithArg>; - type Locker = (); - type CollectionDeposit = CollectionDeposit; - type ItemDeposit = ItemDeposit; - type MetadataDepositBase = UniquesMetadataDepositBase; - type AttributeDepositBase = AttributeDepositBase; - type DepositPerByte = DepositPerByte; - type StringLimit = primitives::UniquesStringLimit; - type KeyLimit = KeyLimit; - type ValueLimit = ValueLimit; - type WeightInfo = (); - #[cfg(feature = "runtime-benchmarks")] - type Helper = (); -} - -impl pallet_relaychain_info::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RelaychainBlockNumberProvider = RelayChainBlockNumberProvider; -} - -impl pallet_xyk_liquidity_mining::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MultiCurrency = Currencies; - type CreateOrigin = UnanimousTechCommitteeOrRoot; - type PalletId = LMPalletId; - type NftCollectionId = LiquidityMiningNftCollectionId; - type AMM = XYK; - type WeightInfo = weights::xyk_liquidity_mining::BasiliskWeight; - type NFTHandler = NFT; - type LiquidityMiningHandler = XYKWarehouseLM; - type NonDustableWhitelistHandler = Duster; -} - -type XYKLiquidityMiningInstance = warehouse_liquidity_mining::Instance1; -impl warehouse_liquidity_mining::Config for Runtime { - type AssetId = AssetId; - type MultiCurrency = Currencies; - type PalletId = WarehouseLMPalletId; - type MinTotalFarmRewards = MinTotalFarmRewards; - type MinPlannedYieldingPeriods = MinPlannedYieldingPeriods; - type BlockNumberProvider = RelayChainBlockNumberProvider; - type AmmPoolId = AccountId; - type MaxFarmEntriesPerDeposit = MaxEntriesPerDeposit; - type MaxYieldFarmsPerGlobalFarm = MaxYieldFarmsPerGlobalFarm; - type AssetRegistry = AssetRegistry; - type NonDustableWhitelistHandler = Duster; - type RuntimeEvent = RuntimeEvent; - type PriceAdjustment = warehouse_liquidity_mining::DefaultPriceAdjustment; -} - -parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; - pub PreimageBaseDeposit: Balance = deposit(2, 64); - pub PreimageByteDeposit: Balance = deposit(0, 1); -} - -impl pallet_preimage::Config for Runtime { - type WeightInfo = (); - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type ManagerOrigin = EnsureRoot; - type BaseDeposit = PreimageBaseDeposit; - type ByteDeposit = PreimageByteDeposit; -} - -impl pallet_identity::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BasicDeposit = BasicDeposit; - type FieldDeposit = FieldDeposit; - type SubAccountDeposit = SubAccountDeposit; - type MaxSubAccounts = MaxSubAccounts; - type MaxAdditionalFields = MaxAdditionalFields; - type MaxRegistrars = MaxRegistrars; - type Slashed = Treasury; - type ForceOrigin = MajorityCouncilOrRoot; - type RegistrarOrigin = MajorityCouncilOrRoot; - type WeightInfo = (); -} - -impl pallet_multisig::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = (); -} - -impl pallet_transaction_pause::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type UpdateOrigin = MajorityTechCommitteeOrRoot; - type WeightInfo = weights::transaction_pause::BasiliskWeight; -} -parameter_types! { - pub const MaxNumberOfTrades: u8 = 5; -} - -impl pallet_route_executor::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type AssetId = AssetId; - type Balance = Balance; - type MaxNumberOfTrades = MaxNumberOfTrades; - type Currency = MultiInspectAdapter; - type AMM = (XYK, LBP); - type WeightInfo = weights::route_executor::BasiliskWeight; -} - -parameter_types! { - pub const RewardPerCollator: Balance = 15_216_000_000_000_000; // 12.68[BSX/block] * 1200[block] - //GalacticCouncil collators - pub ExcludedCollators: Vec = vec![ - // bXn5CfJB2qHvqnuMqTpXn6un9Fjch8mwkb9i3JUsGVD4ChLoe - hex_literal::hex!["f25e5d7b43266a5b4cca762c9be917f18852d7a5db85e734776206eeb539dd4f"].into(), - ]; -} - -impl pallet_collator_rewards::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type CurrencyId = AssetId; - type Currency = Currencies; - type RewardPerCollator = RewardPerCollator; - type ExcludedCollators = ExcludedCollators; - type RewardCurrencyId = NativeAssetId; - // We wrap the ` SessionManager` implementation of `CollatorSelection` to get the collatrs that - // we hand out rewards to. - type SessionManager = CollatorSelection; -} - -// constants need to be in scope to be used in generics -use pallet_ema_oracle::MAX_PERIODS; - -parameter_types! { - pub SupportedPeriods: BoundedVec> = BoundedVec::truncate_from( - vec![OraclePeriod::LastBlock, OraclePeriod::Hour, OraclePeriod::Day, OraclePeriod::Week] - ); - // There are currently only a few pools, so the number of entries per block is limited. - // NOTE: Needs to be updated once the number of pools grows. - pub MaxUniqueOracleEntries: u32 = 30; -} - -impl pallet_ema_oracle::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::ema_oracle::BasiliskWeight; - type BlockNumberProvider = RelayChainBlockNumberProvider; - type SupportedPeriods = SupportedPeriods; - type MaxUniqueEntries = MaxUniqueOracleEntries; -} - // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs new file mode 100644 index 00000000000..3ecff4a29a8 --- /dev/null +++ b/runtime/basilisk/src/system.rs @@ -0,0 +1,529 @@ +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate::democracy::{ + MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, +}; +use crate::finance::RegistryStrLimit; + +use pallet_transaction_multi_payment::{DepositAll, TransferFees}; +use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; +use primitives::{ + constants::{ + chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, + currency::{CENTS, DOLLARS, MILLICENTS}, + time::{DAYS, HOURS, SLOT_DURATION}, + }, + AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO, +}; + +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{ + dispatch::DispatchClass, + parameter_types, + sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Permill, Perquintill}, + traits::{Contains, EqualPrivilegeOnly, InstanceFilter, NeverEnsureOrigin}, + weights::{ + constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, + ConstantMultiplier, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + }, + PalletId, RuntimeDebug, +}; +use frame_system::EnsureRoot; +use scale_info::TypeInfo; + +// frame system +parameter_types! { + pub const BlockHashCount: BlockNumber = 250; + /// Maximum length of block. Up to 5MB. + pub BlockLength: frame_system::limits::BlockLength = + frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub const SS58Prefix: u16 = 10041; + + /// Basilisk base weight of an extrinsic + /// This includes weight for payment in non-native currency. + // Default substrate base weight is 125 * WEIGHT_PER_MICROS + pub const BasiliskExtrinsicBaseWeight: Weight = Weight::from_ref_time(200 * WEIGHT_REF_TIME_PER_MICROS); +} + +parameter_types! { + pub const Version: RuntimeVersion = VERSION; + /// Block weights base values and limits. + pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have an extra reserved space, so that they + // are included even if block reachd `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); + + pub ExtrinsicBaseWeight: Weight = BasiliskExtrinsicBaseWeight::get(); +} + +pub struct BaseFilter; +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { + if matches!( + call, + RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_) + ) { + // always allow + // Note: this is done to avoid unnecessary check of paused storage. + return true; + } + + if pallet_transaction_pause::PausedTransactionFilter::::contains(call) { + // if paused, dont allow! + return false; + } + + match call { + RuntimeCall::Uniques(_) => false, + RuntimeCall::PolkadotXcm(_) => false, + RuntimeCall::OrmlXcm(_) => false, + _ => true, + } + } +} + +impl frame_system::Config for Runtime { + /// The basic call filter to use in dispatchable. + type BaseCallFilter = BaseFilter; + type BlockWeights = BlockWeights; + type BlockLength = BlockLength; + /// The ubiquitous origin type. + type RuntimeOrigin = RuntimeOrigin; + /// The aggregated dispatch type that is available for extrinsics. + type RuntimeCall = RuntimeCall; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The index type for blocks. + type BlockNumber = BlockNumber; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// The hashing algorithm used. + type Hashing = BlakeTwo256; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = IdentityLookup; + /// The header type. + type Header = generic::Header; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; + /// The weight of the overhead invoked on the block import process, independent of the + /// extrinsics included in that block. + /// Version of the runtime. + type Version = Version; + /// Converts a module to the index of the module in `construct_runtime!`. + /// + /// This type is being generated by `construct_runtime!`. + type PalletInfo = PalletInfo; + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; + /// What to do if a new account is created. + type OnNewAccount = (); + /// What to do if an account is fully reaped from the system. + type OnKilledAccount = (); + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = weights::system::BasiliskWeight; + type SS58Prefix = SS58Prefix; + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +// pallet timestamp +parameter_types! { + pub const MinimumPeriod: u64 = SLOT_DURATION / 2; + pub const NativeAssetId : AssetId = CORE_ASSET_ID; +} + +impl pallet_timestamp::Config for Runtime { + /// A timestamp: milliseconds since the unix epoch. + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = weights::timestamp::BasiliskWeight; +} + +// pallet transaction payment +parameter_types! { + pub const TransactionByteFee: Balance = 10 * MILLICENTS; + /// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less + /// than this will decrease the weight and more will increase. + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to + /// change the fees more rapidly. + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(6, 100_000); + /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure + /// that combined with `AdjustmentVariable`, we can recover from the minimum. + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); + /// Maximum amount of the multiplier. + pub MaximumMultiplier: Multiplier = Multiplier::saturating_from_integer(4); +} + +pub struct WeightToFee; +impl WeightToFeePolynomial for WeightToFee { + type Balance = Balance; + + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the + /// node's balance type. + /// + /// This should typically create a mapping between the following ranges: + /// - [0, MAXIMUM_BLOCK_WEIGHT] + /// - [Balance::min, Balance::max] + /// + /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: + /// - Setting it to `0` will essentially disable the weight fee. + /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. + fn polynomial() -> WeightToFeeCoefficients { + let p = 11 * CENTS; + let q = Balance::from(ExtrinsicBaseWeight::get().ref_time()); + smallvec::smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } +} + +/// Parameterized slow adjusting fee updated based on +/// https://w3f-research.readthedocs.io/en/latest/polkadot/overview/2-token-economics.html?highlight=token%20economics#-2.-slow-adjusting-mechanism +pub type SlowAdjustingFeeUpdate = + TargetedFeeAdjustment; + +impl pallet_transaction_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = TransferFees, TreasuryAccount>; + type OperationalFeeMultiplier = (); + type WeightToFee = WeightToFee; + type LengthToFee = ConstantMultiplier; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; +} + +// pallet transaction multi payment +impl pallet_transaction_multi_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AcceptedCurrencyOrigin = MajorityTechCommitteeOrRoot; + type Currencies = Currencies; + type SpotPriceProvider = pallet_xyk::XYKSpotPrice; + type WeightInfo = weights::payment::BasiliskWeight; + type WeightToFee = WeightToFee; + type NativeAssetId = NativeAssetId; +} + +// pallet proxy +/// The type used to represent the kinds of proxying allowed. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] +pub enum ProxyType { + Any, + CancelProxy, + Governance, + Exchange, + Transfer, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} + +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::CancelProxy => matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })), + ProxyType::Governance => matches!( + c, + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::Elections(..) + | RuntimeCall::Treasury(..) + | RuntimeCall::Tips(..) + | RuntimeCall::Utility(..) + ), + ProxyType::Exchange => matches!(c, RuntimeCall::XYK(..) | RuntimeCall::LBP(..) | RuntimeCall::NFT(..)), + // Transfer group doesn't include cross-chain transfers + ProxyType::Transfer => matches!( + c, + RuntimeCall::Balances(..) | RuntimeCall::Currencies(..) | RuntimeCall::Tokens(..) + ), + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } + } +} + +parameter_types! { + pub ProxyDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; + pub ProxyDepositFactor: Balance = 1_980 * MILLICENTS; + pub const MaxProxies: u16 = 32; + pub AnnouncementDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; + pub AnnouncementDepositFactor: Balance = 3_960 * MILLICENTS; + pub const MaxPending: u16 = 32; +} + +impl pallet_proxy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = (); + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; +} + +// pallet duster +parameter_types! { + pub const DustingReward: u128 = 0; +} + +impl pallet_duster::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = AssetId; + type MultiCurrency = Currencies; + type MinCurrencyDeposits = AssetRegistry; + type Reward = DustingReward; + type NativeCurrencyId = NativeAssetId; + type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; + type WeightInfo = weights::duster::BasiliskWeight; +} + +// pallet asset registry +parameter_types! { + pub const SequentialIdOffset: u32 = 1_000_000; +} +impl pallet_asset_registry::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; + type AssetId = AssetId; + type Balance = Balance; + type AssetNativeLocation = AssetLocation; + type StringLimit = RegistryStrLimit; + type SequentialIdStartAt = SequentialIdOffset; + type NativeAssetId = NativeAssetId; + type WeightInfo = weights::asset_registry::BasiliskWeight; +} + +// cumulus pallet parachain system +parameter_types! { + pub ReservedXcmpWeight: Weight = BlockWeights::get().max_block / 4; + pub ReservedDmpWeight: Weight = BlockWeights::get().max_block / 4; +} + +impl cumulus_pallet_parachain_system::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnSystemEvent = pallet_relaychain_info::OnValidationDataHandler; + type SelfParaId = ParachainInfo; + type OutboundXcmpMessageSource = XcmpQueue; + type DmpMessageHandler = DmpQueue; + type ReservedDmpWeight = ReservedDmpWeight; + type XcmpMessageHandler = XcmpQueue; + type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +} + +// pallet aura +parameter_types! { + pub const MaxAuthorities: u32 = 50; +} + +impl pallet_aura::Config for Runtime { + type AuthorityId = AuraId; + type MaxAuthorities = MaxAuthorities; + type DisabledValidators = (); +} + +// pallet treasury +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(3); + pub const ProposalBondMinimum: Balance = 100 * DOLLARS; + pub const ProposalBondMaximum: Balance = 500 * DOLLARS; + pub const SpendPeriod: BlockNumber = 3 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); +} + +impl pallet_treasury::Config for Runtime { + type PalletId = TreasuryPalletId; + type Currency = Balances; + type ApproveOrigin = SuperMajorityCouncilOrRoot; + type RejectOrigin = MajorityCouncilOrRoot; + type RuntimeEvent = RuntimeEvent; + type OnSlash = Treasury; + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BurnDestination = (); + type WeightInfo = weights::treasury::BasiliskWeight; + type SpendFunds = (); + type MaxApprovals = MaxApprovals; + type SpendOrigin = NeverEnsureOrigin; +} + +// pallet scheduler +parameter_types! { + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; +} + +impl pallet_scheduler::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = weights::scheduler::BasiliskWeight; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type Preimages = Preimage; +} + +impl pallet_utility::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type WeightInfo = weights::utility::BasiliskWeight; + type PalletsOrigin = OriginCaller; +} + +// pallet authorship +parameter_types! { + pub const UncleGenerations: u32 = 0; +} + +impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type EventHandler = (CollatorSelection,); +} + +// pallet collator selection +parameter_types! { + pub const PotId: PalletId = PalletId(*b"PotStake"); + pub const MaxCandidates: u32 = 20; + pub const MinCandidates: u32 = 4; + pub const MaxInvulnerables: u32 = 50; +} + +impl pallet_collator_selection::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type UpdateOrigin = MajorityTechCommitteeOrRoot; + type PotId = PotId; + type MaxCandidates = MaxCandidates; + type MinCandidates = MinCandidates; + type MaxInvulnerables = MaxInvulnerables; + // should be a multiple of session or things will get inconsistent + type KickThreshold = Period; + type ValidatorId = ::AccountId; + type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + type ValidatorRegistration = Session; + type WeightInfo = weights::collator_selection::BasiliskWeight; +} + +// pallet session +parameter_types! { + pub const Period: u32 = 4 * HOURS; + pub const Offset: u32 = 0; +} + +impl pallet_session::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ValidatorId = ::AccountId; + // we don't have stash and controller, thus we don't need the convert as well. + type ValidatorIdOf = pallet_collator_selection::IdentityCollator; + type ShouldEndSession = pallet_session::PeriodicSessions; + type NextSessionRotation = pallet_session::PeriodicSessions; + type SessionManager = CollatorRewards; + // Essentially just Aura, but lets be pedantic. + type SessionHandler = ::KeyTypeIdProviders; + type Keys = opaque::SessionKeys; + type WeightInfo = (); +} + +impl parachain_info::Config for Runtime {} + +impl cumulus_pallet_aura_ext::Config for Runtime {} + +impl pallet_relaychain_info::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RelaychainBlockNumberProvider = RelayChainBlockNumberProvider; +} + +impl pallet_transaction_pause::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type UpdateOrigin = MajorityTechCommitteeOrRoot; + type WeightInfo = weights::transaction_pause::BasiliskWeight; +} + +// pallet collator rewards +parameter_types! { + pub const RewardPerCollator: Balance = 15_216_000_000_000_000; // 12.68[BSX/block] * 1200[block] + //GalacticCouncil collators + pub ExcludedCollators: Vec = vec![ + // bXn5CfJB2qHvqnuMqTpXn6un9Fjch8mwkb9i3JUsGVD4ChLoe + hex_literal::hex!["f25e5d7b43266a5b4cca762c9be917f18852d7a5db85e734776206eeb539dd4f"].into(), + ]; +} + +impl pallet_collator_rewards::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type CurrencyId = AssetId; + type Currency = Currencies; + type RewardPerCollator = RewardPerCollator; + type ExcludedCollators = ExcludedCollators; + type RewardCurrencyId = NativeAssetId; + // We wrap the ` SessionManager` implementation of `CollatorSelection` to get the collatrs that + // we hand out rewards to. + type SessionManager = CollatorSelection; +} diff --git a/runtime/basilisk/src/tests.rs b/runtime/basilisk/src/tests.rs index c6be0aa56bd..6aaea623ddc 100644 --- a/runtime/basilisk/src/tests.rs +++ b/runtime/basilisk/src/tests.rs @@ -4,10 +4,14 @@ use crate::*; use codec::Encode; use frame_support::{ dispatch::{DispatchClass, GetDispatchInfo}, + sp_runtime::{traits::Convert, FixedPointNumber}, weights::WeightToFee, }; -use sp_runtime::traits::Convert; -use sp_runtime::FixedPointNumber; +use pallet_transaction_payment::Multiplier; +use primitives::constants::{ + currency::{CENTS, MILLICENTS}, + time::HOURS, +}; #[test] #[ignore] diff --git a/runtime/common/src/weights/asset_registry.rs b/runtime/basilisk/src/weights/asset_registry.rs similarity index 100% rename from runtime/common/src/weights/asset_registry.rs rename to runtime/basilisk/src/weights/asset_registry.rs diff --git a/runtime/common/src/weights/balances.rs b/runtime/basilisk/src/weights/balances.rs similarity index 100% rename from runtime/common/src/weights/balances.rs rename to runtime/basilisk/src/weights/balances.rs diff --git a/runtime/common/src/weights/collator_selection.rs b/runtime/basilisk/src/weights/collator_selection.rs similarity index 100% rename from runtime/common/src/weights/collator_selection.rs rename to runtime/basilisk/src/weights/collator_selection.rs diff --git a/runtime/common/src/weights/currencies.rs b/runtime/basilisk/src/weights/currencies.rs similarity index 100% rename from runtime/common/src/weights/currencies.rs rename to runtime/basilisk/src/weights/currencies.rs diff --git a/runtime/common/src/weights/democracy.rs b/runtime/basilisk/src/weights/democracy.rs similarity index 100% rename from runtime/common/src/weights/democracy.rs rename to runtime/basilisk/src/weights/democracy.rs diff --git a/runtime/common/src/weights/duster.rs b/runtime/basilisk/src/weights/duster.rs similarity index 100% rename from runtime/common/src/weights/duster.rs rename to runtime/basilisk/src/weights/duster.rs diff --git a/runtime/common/src/weights/ema_oracle.rs b/runtime/basilisk/src/weights/ema_oracle.rs similarity index 100% rename from runtime/common/src/weights/ema_oracle.rs rename to runtime/basilisk/src/weights/ema_oracle.rs diff --git a/runtime/common/src/weights/lbp.rs b/runtime/basilisk/src/weights/lbp.rs similarity index 100% rename from runtime/common/src/weights/lbp.rs rename to runtime/basilisk/src/weights/lbp.rs diff --git a/runtime/common/src/weights/marketplace.rs b/runtime/basilisk/src/weights/marketplace.rs similarity index 100% rename from runtime/common/src/weights/marketplace.rs rename to runtime/basilisk/src/weights/marketplace.rs diff --git a/runtime/common/src/weights/mod.rs b/runtime/basilisk/src/weights/mod.rs similarity index 100% rename from runtime/common/src/weights/mod.rs rename to runtime/basilisk/src/weights/mod.rs diff --git a/runtime/common/src/weights/nft.rs b/runtime/basilisk/src/weights/nft.rs similarity index 100% rename from runtime/common/src/weights/nft.rs rename to runtime/basilisk/src/weights/nft.rs diff --git a/runtime/common/src/weights/payment.rs b/runtime/basilisk/src/weights/payment.rs similarity index 100% rename from runtime/common/src/weights/payment.rs rename to runtime/basilisk/src/weights/payment.rs diff --git a/runtime/common/src/weights/route_executor.rs b/runtime/basilisk/src/weights/route_executor.rs similarity index 100% rename from runtime/common/src/weights/route_executor.rs rename to runtime/basilisk/src/weights/route_executor.rs diff --git a/runtime/common/src/weights/scheduler.rs b/runtime/basilisk/src/weights/scheduler.rs similarity index 100% rename from runtime/common/src/weights/scheduler.rs rename to runtime/basilisk/src/weights/scheduler.rs diff --git a/runtime/common/src/weights/system.rs b/runtime/basilisk/src/weights/system.rs similarity index 100% rename from runtime/common/src/weights/system.rs rename to runtime/basilisk/src/weights/system.rs diff --git a/runtime/common/src/weights/timestamp.rs b/runtime/basilisk/src/weights/timestamp.rs similarity index 100% rename from runtime/common/src/weights/timestamp.rs rename to runtime/basilisk/src/weights/timestamp.rs diff --git a/runtime/common/src/weights/tips.rs b/runtime/basilisk/src/weights/tips.rs similarity index 100% rename from runtime/common/src/weights/tips.rs rename to runtime/basilisk/src/weights/tips.rs diff --git a/runtime/common/src/weights/tokens.rs b/runtime/basilisk/src/weights/tokens.rs similarity index 100% rename from runtime/common/src/weights/tokens.rs rename to runtime/basilisk/src/weights/tokens.rs diff --git a/runtime/common/src/weights/transaction_pause.rs b/runtime/basilisk/src/weights/transaction_pause.rs similarity index 100% rename from runtime/common/src/weights/transaction_pause.rs rename to runtime/basilisk/src/weights/transaction_pause.rs diff --git a/runtime/common/src/weights/treasury.rs b/runtime/basilisk/src/weights/treasury.rs similarity index 100% rename from runtime/common/src/weights/treasury.rs rename to runtime/basilisk/src/weights/treasury.rs diff --git a/runtime/common/src/weights/utility.rs b/runtime/basilisk/src/weights/utility.rs similarity index 100% rename from runtime/common/src/weights/utility.rs rename to runtime/basilisk/src/weights/utility.rs diff --git a/runtime/common/src/weights/vesting.rs b/runtime/basilisk/src/weights/vesting.rs similarity index 100% rename from runtime/common/src/weights/vesting.rs rename to runtime/basilisk/src/weights/vesting.rs diff --git a/runtime/common/src/weights/xcm.rs b/runtime/basilisk/src/weights/xcm.rs similarity index 100% rename from runtime/common/src/weights/xcm.rs rename to runtime/basilisk/src/weights/xcm.rs diff --git a/runtime/common/src/weights/xcmp_queue.rs b/runtime/basilisk/src/weights/xcmp_queue.rs similarity index 100% rename from runtime/common/src/weights/xcmp_queue.rs rename to runtime/basilisk/src/weights/xcmp_queue.rs diff --git a/runtime/common/src/weights/xyk.rs b/runtime/basilisk/src/weights/xyk.rs similarity index 100% rename from runtime/common/src/weights/xyk.rs rename to runtime/basilisk/src/weights/xyk.rs diff --git a/runtime/common/src/weights/xyk_liquidity_mining.rs b/runtime/basilisk/src/weights/xyk_liquidity_mining.rs similarity index 100% rename from runtime/common/src/weights/xyk_liquidity_mining.rs rename to runtime/basilisk/src/weights/xyk_liquidity_mining.rs diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index d109e01df44..7924c36f740 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -1,21 +1,42 @@ -use super::{AssetId, *}; +// This file is part of Basilisk-node. + +// Copyright (C) 2020-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate::democracy::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot}; +use crate::system::{TreasuryAccount, WeightToFee}; use cumulus_primitives_core::ParaId; use frame_support::{ - traits::{Everything, Nothing}, + parameter_types, + sp_runtime::traits::Convert, + traits::{Contains, Everything, Get, Nothing}, PalletId, }; use hydradx_adapters::{MultiCurrencyTrader, ToFeeReceiver}; use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key}; pub use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; +use pallet_transaction_multi_payment::DepositAll; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; -use polkadot_xcm::v3::prelude::*; -use polkadot_xcm::v3::Error; -use polkadot_xcm::v3::Weight as XcmWeight; -use primitives::Price; -use sp_runtime::traits::Convert; +use polkadot_xcm::v3::{prelude::*, Error, MultiLocation, Weight as XcmWeight}; +use primitives::{AssetId, Price}; +use codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, @@ -24,6 +45,14 @@ use xcm_builder::{ }; use xcm_executor::{traits::WeightTrader, Assets, Config, XcmExecutor}; +#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct AssetLocation(pub MultiLocation); + +pub const RELAY_CHAIN_ASSET_LOCATION: AssetLocation = AssetLocation(MultiLocation { + parents: 1, + interior: Here, +}); + pub type LocalOriginToLocation = SignedToAccountId32; pub type Barrier = ( @@ -219,7 +248,7 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = (); type MaxLockers = ConstU32<8>; - type WeightInfo = common_runtime::weights::xcm::BasiliskWeight; + type WeightInfo = weights::xcm::BasiliskWeight; #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml deleted file mode 100644 index efa0fda6dd9..00000000000 --- a/runtime/common/Cargo.toml +++ /dev/null @@ -1,63 +0,0 @@ -[package] -name = "common-runtime" -version = "2.3.12" -authors = ["GalacticCouncil"] -edition = "2021" -homepage = "https://github.com/galacticcouncil/Basilisk-node" -license = "Apache 2.0" -repository = "https://github.com/galacticcouncil/Basilisk-node" - -[package.metadata.docs.rs] -targets = ['x86_64-unknown-linux-gnu'] - -[build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" } - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -primitives = {path = '../../primitives', default-features = false} - -# Local dependencies -pallet-xyk = { path = "../../pallets/xyk",default-features = false} -pallet-lbp = { path = "../../pallets/lbp", default-features = false } -pallet-marketplace = { path = '../../pallets/marketplace', default-features = false } -pallet-xyk-liquidity-mining = { path = "../../pallets/xyk-liquidity-mining", default-features=false} - -# Warehouse dependencies -hydradx-traits = { workspace = true } -pallet-transaction-multi-payment = { workspace = true } -pallet-asset-registry = { workspace = true } -pallet-nft = { workspace = true } -pallet-transaction-pause = { workspace = true } -pallet-currencies = { workspace = true } -pallet-route-executor = { workspace = true } -pallet-duster = { workspace = true } -pallet-ema-oracle = { workspace = true } - -# Substrate dependencies -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38", default-features = false } -pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } -polkadot-xcm = { package = "xcm", git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false } -pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false } - -# Cumulus dependencies -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.38", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false } - -# ORML dependencies -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38", default-features = false } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38", default-features = false } -orml-vesting = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38", default-features = false } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs deleted file mode 100644 index f96a62ab0fc..00000000000 --- a/runtime/common/src/lib.rs +++ /dev/null @@ -1,310 +0,0 @@ -// This file is part of Basilisk-node. - -// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg_attr(not(feature = "std"), no_std)] - -pub mod adapter; -pub mod locked_balance; -pub mod weights; - -use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{ - parameter_types, traits::LockIdentifier, weights::constants::WEIGHT_REF_TIME_PER_MICROS, PalletId, RuntimeDebug, -}; -pub use pallet_transaction_payment::Multiplier; -use polkadot_xcm::prelude::Here; -use polkadot_xcm::v3::MultiLocation; -pub use primitives::constants::{chain::*, currency::*, time::*}; -pub use primitives::{Amount, AssetId, Balance}; -use scale_info::TypeInfo; -use sp_runtime::{ - generic, - traits::{AccountIdConversion, BlakeTwo256, Bounded, IdentifyAccount, Verify}, - FixedPointNumber, MultiSignature, Perbill, Percent, Permill, Perquintill, -}; -use sp_std::vec; - -/// An index to a block. -pub type BlockNumber = u32; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// The type for looking up accounts. We don't expect more than 4 billion of them, but you -/// never know... -pub type AccountIndex = u32; - -/// Index of a transaction in the chain. -pub type Index = u32; - -/// A hash of some data used by the chain. -pub type Hash = sp_core::H256; - -/// Opaque, encoded, unchecked extrinsic. -pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - -/// Header type. -pub type Header = generic::Header; - -/// Block type. -pub type Block = generic::Block; - -/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic -/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. -pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); -/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used -/// by Operational extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] -pub struct AssetLocation(pub MultiLocation); - -pub const RELAY_CHAIN_ASSET_LOCATION: AssetLocation = AssetLocation(MultiLocation { - parents: 1, - interior: Here, -}); - -pub fn get_all_module_accounts() -> vec::Vec { - vec![ - TreasuryPalletId::get().into_account_truncating(), - VestingPalletId::get().into_account_truncating(), - ] -} - -// frame system -parameter_types! { - pub const BlockHashCount: BlockNumber = 250; - /// Maximum length of block. Up to 5MB. - pub BlockLength: frame_system::limits::BlockLength = - frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub const SS58Prefix: u16 = 10041; - - /// Basilisk base weight of an extrinsic - /// This includes weight for payment in non-native currency. - // Default substrate base weight is 125 * WEIGHT_PER_MICROS - pub const BasiliskExtrinsicBaseWeight: Weight = Weight::from_ref_time(200 * WEIGHT_REF_TIME_PER_MICROS); -} - -// pallet timestamp -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; - pub const NativeAssetId : AssetId = CORE_ASSET_ID; -} - -// pallet balances -parameter_types! { - pub const NativeExistentialDeposit: u128 = NATIVE_EXISTENTIAL_DEPOSIT; - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; -} - -// pallet aura -parameter_types! { - pub const MaxAuthorities: u32 = 50; -} - -// pallet transaction payment -parameter_types! { - pub const TransactionByteFee: Balance = 10 * MILLICENTS; - /// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less - /// than this will decrease the weight and more will increase. - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to - /// change the fees more rapidly. - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(6, 100_000); - /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure - /// that combined with `AdjustmentVariable`, we can recover from the minimum. - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); - pub MaximumMultiplier: Multiplier = Bounded::max_value(); -} - -// pallet proxy -/// The type used to represent the kinds of proxying allowed. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] -pub enum ProxyType { - Any, - CancelProxy, - Governance, - Exchange, - Transfer, -} -impl Default for ProxyType { - fn default() -> Self { - Self::Any - } -} - -parameter_types! { - pub ProxyDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; - pub ProxyDepositFactor: Balance = 1_980 * MILLICENTS; - pub const MaxProxies: u16 = 32; - pub AnnouncementDepositBase: Balance = 4 * DOLLARS + 480 * MILLICENTS; - pub AnnouncementDepositFactor: Balance = 3_960 * MILLICENTS; - pub const MaxPending: u16 = 32; -} - -// pallet xyk -parameter_types! { - pub ExchangeFee: (u32, u32) = (3, 1_000); - pub const MinTradingLimit: Balance = MIN_TRADING_LIMIT; - pub const MinPoolLiquidity: Balance = MIN_POOL_LIQUIDITY; - pub const MaxInRatio: u128 = MAX_IN_RATIO; - pub const MaxOutRatio: u128 = MAX_OUT_RATIO; - pub const RegistryStrLimit: u32 = 32; - pub const DiscountedFee: (u32, u32) = DISCOUNTED_FEE; -} - -// pallet duster -parameter_types! { - pub const DustingReward: u128 = 0; -} - -// pallet lbp -parameter_types! { - pub LBPExchangeFee: (u32, u32) = (2, 1_000); -} - -// pallet democracy -parameter_types! { - pub const LaunchPeriod: BlockNumber = 3 * DAYS; - pub const VotingPeriod: BlockNumber = 3 * DAYS; - pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; - pub const MinimumDeposit: Balance = 1000 * DOLLARS; - pub const EnactmentPeriod: BlockNumber = 12 * HOURS; - // Make sure VoteLockingPeriod > EnactmentPeriod - pub const VoteLockingPeriod: BlockNumber = 6 * DAYS; - pub const CooloffPeriod: BlockNumber = 7 * DAYS; - // $10,000 / MB - pub const PreimageByteDeposit: Balance = 10 * MILLICENTS; - pub const InstantAllowed: bool = true; - pub const MaxVotes: u32 = 100; - pub const MaxProposals: u32 = 100; -} - -// pallet elections_phragmen -parameter_types! { - // Bond for candidacy into governance - pub const CandidacyBond: Balance = 5 * DOLLARS; - // 1 storage item created, key size is 32 bytes, value size is 16+16. - pub const VotingBondBase: Balance = CENTS; - // additional data per vote is 32 bytes (account id). - pub const VotingBondFactor: Balance = CENTS; - pub const TermDuration: BlockNumber = 7 * DAYS; - pub const DesiredMembers: u32 = 7; - pub const DesiredRunnersUp: u32 = 9; - pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; - pub const MaxElectionCandidates: u32 = 1_000; - pub const MaxElectionVoters: u32 = 10_000; -} - -// pallet collective - council collective -parameter_types! { - pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; - pub const CouncilMaxProposals: u32 = 13; - pub const CouncilMaxMembers: u32 = 7; -} - -// pallet collective - technical collective -parameter_types! { - pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; - pub const TechnicalMaxProposals: u32 = 20; - pub const TechnicalMaxMembers: u32 = 10; -} - -// pallet treasury -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; -} - -// pallet authorship -parameter_types! { - pub const UncleGenerations: u32 = 0; -} - -// pallet tips -parameter_types! { - pub const DataDepositPerByte: Balance = CENTS; - pub const TipCountdown: BlockNumber = 2 * HOURS; - pub const TipFindersFee: Percent = Percent::from_percent(1); - pub const TipReportDepositBase: Balance = 10 * DOLLARS; - pub const TipReportDepositPerByte: Balance = CENTS; - pub const MaximumReasonLength: u32 = 1024; -} - -// pallet collator selection -parameter_types! { - pub const PotId: PalletId = PalletId(*b"PotStake"); - pub const MaxCandidates: u32 = 20; - pub const MinCandidates: u32 = 4; - pub const MaxInvulnerables: u32 = 50; -} - -// pallet session -parameter_types! { - pub const Period: u32 = 4 * HOURS; - pub const Offset: u32 = 0; -} - -// pallet vesting -parameter_types! { - pub MinVestedTransfer: Balance = 100_000; - pub const MaxVestingSchedules: u32 = 15; - pub const VestingPalletId: PalletId = PalletId(*b"py/vstng"); -} - -// pallet liquidity mining -parameter_types! { - pub const LMPalletId: PalletId = PalletId(*b"LiqMinId"); - pub const LiquidityMiningNftCollectionId: primitives::CollectionId = 1; -} - -// warehouse pallet liquidity mining -parameter_types! { - pub const WarehouseLMPalletId: PalletId = PalletId(*b"WhouseLm"); - pub const MaxEntriesPerDeposit: u8 = 5; //NOTE: Rebenchmark when this change, TODO: - pub const MaxYieldFarmsPerGlobalFarm: u8 = 50; //NOTE: Includes deleted/destroyed farms, TODO: - pub const MinPlannedYieldingPeriods: BlockNumber = 100_800; //1w, TODO: - pub const MinTotalFarmRewards: Balance = NATIVE_EXISTENTIAL_DEPOSIT * 100; //TODO: -} - -// pallet identity -parameter_types! { - pub const BasicDeposit: Balance = 5 * DOLLARS; - pub const FieldDeposit: Balance = DOLLARS; - pub const SubAccountDeposit: Balance = 5 * DOLLARS; - pub const MaxSubAccounts: u32 = 100; - pub const MaxAdditionalFields: u32 = 100; - pub const MaxRegistrars: u32 = 20; - pub const SequentialIdOffset: u32 = 1_000_000; -} - -// pallet multisig -parameter_types! { - pub DepositBase: Balance = deposit(1, 88); - pub DepositFactor: Balance = deposit(0, 32); - pub const MaxSignatories: u16 = 100; -} diff --git a/runtime/common/src/locked_balance.rs b/runtime/common/src/locked_balance.rs deleted file mode 100644 index f79ae523850..00000000000 --- a/runtime/common/src/locked_balance.rs +++ /dev/null @@ -1,35 +0,0 @@ -use super::*; -use frame_support::sp_runtime::traits::Zero; - -use frame_support::traits::LockIdentifier; -use hydradx_traits::LockedBalance; - -pub struct MultiCurrencyLockedBalance(sp_std::marker::PhantomData); - -impl - LockedBalance for MultiCurrencyLockedBalance -where - AssetId: Into<::CurrencyId>, - Balance: From<::Balance>, - Balance: From<::Balance>, -{ - fn get_by_lock(lock_id: LockIdentifier, currency_id: AssetId, who: T::AccountId) -> Balance { - if currency_id == NativeAssetId::get() { - match pallet_balances::Pallet::::locks(who) - .into_iter() - .find(|lock| lock.id == lock_id) - { - Some(lock) => lock.amount.into(), - None => Zero::zero(), - } - } else { - match orml_tokens::Pallet::::locks(who, currency_id.into()) - .into_iter() - .find(|lock| lock.id == lock_id) - { - Some(lock) => lock.amount.into(), - None => Zero::zero(), - } - } - } -} From b6e3123cba07e2de0deca1150870147d3e7bf4d6 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 8 Jun 2023 13:38:44 +0200 Subject: [PATCH 02/11] formatting --- runtime/basilisk/src/finance.rs | 2 +- runtime/basilisk/src/tests.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/basilisk/src/finance.rs b/runtime/basilisk/src/finance.rs index ebb1a9106be..c25b7f69146 100644 --- a/runtime/basilisk/src/finance.rs +++ b/runtime/basilisk/src/finance.rs @@ -33,7 +33,7 @@ use codec::Decode; use frame_support::{ parameter_types, sp_runtime::{app_crypto::sp_core::crypto::UncheckedFrom, traits::Zero}, - traits::{AsEnsureOriginWithArg, Contains, Defensive, EnsureOrigin, NeverEnsureOrigin, Get, LockIdentifier}, + traits::{AsEnsureOriginWithArg, Contains, Defensive, EnsureOrigin, Get, LockIdentifier, NeverEnsureOrigin}, BoundedVec, PalletId, }; use frame_system::RawOrigin; diff --git a/runtime/basilisk/src/tests.rs b/runtime/basilisk/src/tests.rs index 14b45d85aa4..2bd4959a790 100644 --- a/runtime/basilisk/src/tests.rs +++ b/runtime/basilisk/src/tests.rs @@ -9,8 +9,8 @@ use frame_support::{ }; use pallet_transaction_payment::Multiplier; use primitives::constants::{ - currency::{DOLLARS, CENTS, MILLICENTS}, - time::{HOURS, DAYS}, + currency::{CENTS, DOLLARS, MILLICENTS}, + time::{DAYS, HOURS}, }; #[test] From dd1b7830ec5e2945eb96f35155ddef5fe4f991e1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 8 Jun 2023 13:44:09 +0200 Subject: [PATCH 03/11] bump versions --- Cargo.lock | 4 ++-- integration-tests/Cargo.toml | 2 +- integration-tests/parachain-runtime-mock/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0454283ce8..e4d891ec6a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7275,7 +7275,7 @@ dependencies = [ [[package]] name = "parachain-runtime-mock" -version = "0.2.7" +version = "0.2.8" dependencies = [ "basilisk-runtime", "cumulus-pallet-aura-ext", @@ -9731,7 +9731,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "0.9.11" +version = "0.9.12" dependencies = [ "basilisk-runtime", "cumulus-pallet-aura-ext", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 4a9ff8243bf..608c0d580d9 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "0.9.11" +version = "0.9.12" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/integration-tests/parachain-runtime-mock/Cargo.toml b/integration-tests/parachain-runtime-mock/Cargo.toml index 8391ff8dd2f..711ed555026 100644 --- a/integration-tests/parachain-runtime-mock/Cargo.toml +++ b/integration-tests/parachain-runtime-mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "parachain-runtime-mock" -version = "0.2.7" +version = "0.2.8" description = "A mock runtime for a parachain" authors = ["GalacticCouncil"] edition = "2021" From ab1ae67cddd113588465742849f540dfbba062ff Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Thu, 8 Jun 2023 20:35:49 +0200 Subject: [PATCH 04/11] relocation of some configs --- .../basilisk/src/{finance.rs => assets.rs} | 36 +++++- .../src/{democracy.rs => governance.rs} | 58 ++++----- runtime/basilisk/src/lib.rs | 8 +- runtime/basilisk/src/system.rs | 121 +++++++----------- runtime/basilisk/src/xcm.rs | 4 +- 5 files changed, 112 insertions(+), 115 deletions(-) rename runtime/basilisk/src/{finance.rs => assets.rs} (92%) rename runtime/basilisk/src/{democracy.rs => governance.rs} (87%) diff --git a/runtime/basilisk/src/finance.rs b/runtime/basilisk/src/assets.rs similarity index 92% rename from runtime/basilisk/src/finance.rs rename to runtime/basilisk/src/assets.rs index c25b7f69146..667c9f5264b 100644 --- a/runtime/basilisk/src/finance.rs +++ b/runtime/basilisk/src/assets.rs @@ -16,7 +16,7 @@ // limitations under the License. use super::*; -use crate::democracy::{SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, UnanimousTechCommitteeOrRoot}; +use crate::governance::{SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, UnanimousTechCommitteeOrRoot}; use crate::system::NativeAssetId; use adapter::OrmlTokensAdapter; @@ -120,6 +120,40 @@ impl pallet_currencies::Config for Runtime { type WeightInfo = weights::currencies::BasiliskWeight; } +// pallet asset registry +parameter_types! { + pub const SequentialIdOffset: u32 = 1_000_000; +} +impl pallet_asset_registry::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; + type AssetId = AssetId; + type Balance = Balance; + type AssetNativeLocation = AssetLocation; + type StringLimit = RegistryStrLimit; + type SequentialIdStartAt = SequentialIdOffset; + type NativeAssetId = NativeAssetId; + type WeightInfo = weights::asset_registry::BasiliskWeight; +} + +// pallet duster +parameter_types! { + pub const DustingReward: u128 = 0; +} + +impl pallet_duster::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = AssetId; + type MultiCurrency = Currencies; + type MinCurrencyDeposits = AssetRegistry; + type Reward = DustingReward; + type NativeCurrencyId = NativeAssetId; + type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; + type WeightInfo = weights::duster::BasiliskWeight; +} + // pallet xyk parameter_types! { pub ExchangeFee: (u32, u32) = (3, 1_000); diff --git a/runtime/basilisk/src/democracy.rs b/runtime/basilisk/src/governance.rs similarity index 87% rename from runtime/basilisk/src/democracy.rs rename to runtime/basilisk/src/governance.rs index dc9b7d2ca16..dddc278abeb 100644 --- a/runtime/basilisk/src/democracy.rs +++ b/runtime/basilisk/src/governance.rs @@ -23,8 +23,9 @@ use primitives::constants::{ use frame_support::{ parameter_types, - sp_runtime::Percent, - traits::{EitherOfDiverse, LockIdentifier, U128CurrencyToVote}, + sp_runtime::{Perbill, Percent, Permill}, + traits::{EitherOfDiverse, EqualPrivilegeOnly, LockIdentifier, U128CurrencyToVote}, + PalletId, }; use frame_system::EnsureRoot; use pallet_collective::EnsureProportionAtLeast; @@ -210,44 +211,33 @@ impl pallet_preimage::Config for Runtime { type ByteDeposit = PreimageByteDeposit; } -// pallet identity +// pallet treasury parameter_types! { - pub const BasicDeposit: Balance = 5 * DOLLARS; - pub const FieldDeposit: Balance = DOLLARS; - pub const SubAccountDeposit: Balance = 5 * DOLLARS; - pub const MaxSubAccounts: u32 = 100; - pub const MaxAdditionalFields: u32 = 100; - pub const MaxRegistrars: u32 = 20; + pub const ProposalBond: Permill = Permill::from_percent(3); + pub const ProposalBondMinimum: Balance = 100 * DOLLARS; + pub const ProposalBondMaximum: Balance = 500 * DOLLARS; + pub const SpendPeriod: BlockNumber = 3 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); } -impl pallet_identity::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BasicDeposit = BasicDeposit; - type FieldDeposit = FieldDeposit; - type SubAccountDeposit = SubAccountDeposit; - type MaxSubAccounts = MaxSubAccounts; - type MaxAdditionalFields = MaxAdditionalFields; - type MaxRegistrars = MaxRegistrars; - type Slashed = Treasury; - type ForceOrigin = MajorityCouncilOrRoot; - type RegistrarOrigin = MajorityCouncilOrRoot; - type WeightInfo = (); -} - -// pallet multisig +// pallet scheduler parameter_types! { - pub DepositBase: Balance = deposit(1, 88); - pub DepositFactor: Balance = deposit(0, 32); - pub const MaxSignatories: u16 = 100; + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; } -impl pallet_multisig::Config for Runtime { +impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type PalletsOrigin = OriginCaller; type RuntimeCall = RuntimeCall; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = (); + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = EnsureRoot; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = weights::scheduler::BasiliskWeight; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type Preimages = Preimage; } diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index ef3b3f0b642..73556676d1f 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -36,13 +36,13 @@ mod migrations; pub mod weights; mod adapter; -mod democracy; -mod finance; +mod assets; +mod governance; mod system; mod xcm; -pub use democracy::*; -pub use finance::*; +pub use assets::*; +pub use governance::*; pub use system::*; pub use xcm::*; diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 3ecff4a29a8..35f57bb1aa1 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -16,18 +16,15 @@ // limitations under the License. use super::*; -use crate::democracy::{ - MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, SuperMajorityTechCommitteeOrRoot, -}; -use crate::finance::RegistryStrLimit; +use crate::governance::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot}; use pallet_transaction_multi_payment::{DepositAll, TransferFees}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use primitives::{ constants::{ chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, - currency::{CENTS, DOLLARS, MILLICENTS}, - time::{DAYS, HOURS, SLOT_DURATION}, + currency::{deposit, CENTS, DOLLARS, MILLICENTS}, + time::{HOURS, SLOT_DURATION}, }, AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO, }; @@ -36,15 +33,14 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::DispatchClass, parameter_types, - sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Permill, Perquintill}, - traits::{Contains, EqualPrivilegeOnly, InstanceFilter, NeverEnsureOrigin}, + sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill}, + traits::{Contains, InstanceFilter, NeverEnsureOrigin}, weights::{ constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, ConstantMultiplier, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, RuntimeDebug, }; -use frame_system::EnsureRoot; use scale_info::TypeInfo; // frame system @@ -316,40 +312,6 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } -// pallet duster -parameter_types! { - pub const DustingReward: u128 = 0; -} - -impl pallet_duster::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = Amount; - type CurrencyId = AssetId; - type MultiCurrency = Currencies; - type MinCurrencyDeposits = AssetRegistry; - type Reward = DustingReward; - type NativeCurrencyId = NativeAssetId; - type BlacklistUpdateOrigin = MajorityTechCommitteeOrRoot; - type WeightInfo = weights::duster::BasiliskWeight; -} - -// pallet asset registry -parameter_types! { - pub const SequentialIdOffset: u32 = 1_000_000; -} -impl pallet_asset_registry::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RegistryOrigin = SuperMajorityTechCommitteeOrRoot; - type AssetId = AssetId; - type Balance = Balance; - type AssetNativeLocation = AssetLocation; - type StringLimit = RegistryStrLimit; - type SequentialIdStartAt = SequentialIdOffset; - type NativeAssetId = NativeAssetId; - type WeightInfo = weights::asset_registry::BasiliskWeight; -} - // cumulus pallet parachain system parameter_types! { pub ReservedXcmpWeight: Weight = BlockWeights::get().max_block / 4; @@ -379,18 +341,6 @@ impl pallet_aura::Config for Runtime { type DisabledValidators = (); } -// pallet treasury -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; - pub TreasuryAccount: AccountId = Treasury::account_id(); -} - impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; @@ -410,25 +360,6 @@ impl pallet_treasury::Config for Runtime { type SpendOrigin = NeverEnsureOrigin; } -// pallet scheduler -parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; -} - -impl pallet_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = weights::scheduler::BasiliskWeight; - type OriginPrivilegeCmp = EqualPrivilegeOnly; - type Preimages = Preimage; -} - impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -527,3 +458,45 @@ impl pallet_collator_rewards::Config for Runtime { // we hand out rewards to. type SessionManager = CollatorSelection; } + +// pallet identity +parameter_types! { + pub const BasicDeposit: Balance = 5 * DOLLARS; + pub const FieldDeposit: Balance = DOLLARS; + pub const SubAccountDeposit: Balance = 5 * DOLLARS; + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = MajorityCouncilOrRoot; + type RegistrarOrigin = MajorityCouncilOrRoot; + type WeightInfo = (); +} + +// pallet multisig +parameter_types! { + pub DepositBase: Balance = deposit(1, 88); + pub DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = (); +} diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 7924c36f740..efce77d7bd8 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -16,8 +16,8 @@ // limitations under the License. use super::*; -use crate::democracy::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot}; -use crate::system::{TreasuryAccount, WeightToFee}; +use crate::governance::{MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot, TreasuryAccount}; +use crate::system::WeightToFee; use cumulus_primitives_core::ParaId; use frame_support::{ From 378da60dd257469a2682e5a1f64542c5bff8b16e Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jun 2023 11:34:20 +0200 Subject: [PATCH 05/11] relocate constants --- primitives/src/lib.rs | 9 +-------- runtime/basilisk/src/system.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 1a68fb76edf..332529db3eb 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -32,7 +32,7 @@ use frame_support::{ sp_runtime::{ generic, traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, Perbill, + MultiSignature, }, }; @@ -89,13 +89,6 @@ pub type CollectionId = u128; /// NFT Item ID pub type ItemId = u128; -/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic -/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. -pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); -/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used -/// by Operational extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - parameter_types! { /// NFT metadata limit pub const UniquesStringLimit: u32 = 72; diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 35f57bb1aa1..a78acd3c4e9 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -26,7 +26,6 @@ use primitives::{ currency::{deposit, CENTS, DOLLARS, MILLICENTS}, time::{HOURS, SLOT_DURATION}, }, - AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO, }; use codec::{Decode, Encode, MaxEncodedLen}; @@ -44,6 +43,14 @@ use frame_support::{ use scale_info::TypeInfo; // frame system + +/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic +/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + parameter_types! { pub const BlockHashCount: BlockNumber = 250; /// Maximum length of block. Up to 5MB. @@ -55,9 +62,7 @@ parameter_types! { /// This includes weight for payment in non-native currency. // Default substrate base weight is 125 * WEIGHT_PER_MICROS pub const BasiliskExtrinsicBaseWeight: Weight = Weight::from_ref_time(200 * WEIGHT_REF_TIME_PER_MICROS); -} -parameter_types! { pub const Version: RuntimeVersion = VERSION; /// Block weights base values and limits. pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() From 7e600c8f4eaec8786d7cc76ee9337cc14d3f9b39 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jun 2023 11:36:22 +0200 Subject: [PATCH 06/11] formatting --- runtime/basilisk/src/system.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index a78acd3c4e9..9d16632ff00 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -20,12 +20,10 @@ use crate::governance::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, Supe use pallet_transaction_multi_payment::{DepositAll, TransferFees}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; -use primitives::{ - constants::{ - chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, - currency::{deposit, CENTS, DOLLARS, MILLICENTS}, - time::{HOURS, SLOT_DURATION}, - }, +use primitives::constants::{ + chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, + currency::{deposit, CENTS, DOLLARS, MILLICENTS}, + time::{HOURS, SLOT_DURATION}, }; use codec::{Decode, Encode, MaxEncodedLen}; From 1c11eec789ad84ac3b07caf32f5742d9bc858df1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jun 2023 13:34:55 +0200 Subject: [PATCH 07/11] adjustment --- runtime/basilisk/src/governance.rs | 12 ------------ runtime/basilisk/src/system.rs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime/basilisk/src/governance.rs b/runtime/basilisk/src/governance.rs index dddc278abeb..2fe4605f04e 100644 --- a/runtime/basilisk/src/governance.rs +++ b/runtime/basilisk/src/governance.rs @@ -211,18 +211,6 @@ impl pallet_preimage::Config for Runtime { type ByteDeposit = PreimageByteDeposit; } -// pallet treasury -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; - pub TreasuryAccount: AccountId = Treasury::account_id(); -} - // pallet scheduler parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 9d16632ff00..b0806e8d539 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -344,6 +344,18 @@ impl pallet_aura::Config for Runtime { type DisabledValidators = (); } +// pallet treasury +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(3); + pub const ProposalBondMinimum: Balance = 100 * DOLLARS; + pub const ProposalBondMaximum: Balance = 500 * DOLLARS; + pub const SpendPeriod: BlockNumber = 3 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); +} + impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; From c8c6249b50332983c7ae98baecdd15b871f946ff Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jun 2023 13:38:46 +0200 Subject: [PATCH 08/11] adjustments --- runtime/basilisk/src/governance.rs | 33 +++++++++++++++++++++++++++- runtime/basilisk/src/system.rs | 35 ++---------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/runtime/basilisk/src/governance.rs b/runtime/basilisk/src/governance.rs index 2fe4605f04e..19cbb2c5274 100644 --- a/runtime/basilisk/src/governance.rs +++ b/runtime/basilisk/src/governance.rs @@ -24,7 +24,7 @@ use primitives::constants::{ use frame_support::{ parameter_types, sp_runtime::{Perbill, Percent, Permill}, - traits::{EitherOfDiverse, EqualPrivilegeOnly, LockIdentifier, U128CurrencyToVote}, + traits::{EitherOfDiverse, NeverEnsureOrigin, EqualPrivilegeOnly, LockIdentifier, U128CurrencyToVote}, PalletId, }; use frame_system::EnsureRoot; @@ -229,3 +229,34 @@ impl pallet_scheduler::Config for Runtime { type OriginPrivilegeCmp = EqualPrivilegeOnly; type Preimages = Preimage; } + +// pallet treasury +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(3); + pub const ProposalBondMinimum: Balance = 100 * DOLLARS; + pub const ProposalBondMaximum: Balance = 500 * DOLLARS; + pub const SpendPeriod: BlockNumber = 3 * DAYS; + pub const Burn: Permill = Permill::from_percent(0); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 100; + pub TreasuryAccount: AccountId = Treasury::account_id(); +} + +impl pallet_treasury::Config for Runtime { + type PalletId = TreasuryPalletId; + type Currency = Balances; + type ApproveOrigin = SuperMajorityCouncilOrRoot; + type RejectOrigin = MajorityCouncilOrRoot; + type RuntimeEvent = RuntimeEvent; + type OnSlash = Treasury; + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BurnDestination = (); + type WeightInfo = weights::treasury::BasiliskWeight; + type SpendFunds = (); + type MaxApprovals = MaxApprovals; + type SpendOrigin = NeverEnsureOrigin; +} \ No newline at end of file diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index b0806e8d539..00a72ca962d 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -16,7 +16,7 @@ // limitations under the License. use super::*; -use crate::governance::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot, SuperMajorityCouncilOrRoot}; +use crate::governance::{MajorityCouncilOrRoot, MajorityTechCommitteeOrRoot}; use pallet_transaction_multi_payment::{DepositAll, TransferFees}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; @@ -31,7 +31,7 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, sp_runtime::{traits::IdentityLookup, FixedPointNumber, Perbill, Perquintill}, - traits::{Contains, InstanceFilter, NeverEnsureOrigin}, + traits::{Contains, InstanceFilter}, weights::{ constants::{BlockExecutionWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_MICROS}, ConstantMultiplier, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -344,37 +344,6 @@ impl pallet_aura::Config for Runtime { type DisabledValidators = (); } -// pallet treasury -parameter_types! { - pub const ProposalBond: Permill = Permill::from_percent(3); - pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const ProposalBondMaximum: Balance = 500 * DOLLARS; - pub const SpendPeriod: BlockNumber = 3 * DAYS; - pub const Burn: Permill = Permill::from_percent(0); - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; - pub TreasuryAccount: AccountId = Treasury::account_id(); -} - -impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; - type Currency = Balances; - type ApproveOrigin = SuperMajorityCouncilOrRoot; - type RejectOrigin = MajorityCouncilOrRoot; - type RuntimeEvent = RuntimeEvent; - type OnSlash = Treasury; - type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type ProposalBondMaximum = ProposalBondMaximum; - type SpendPeriod = SpendPeriod; - type Burn = Burn; - type BurnDestination = (); - type WeightInfo = weights::treasury::BasiliskWeight; - type SpendFunds = (); - type MaxApprovals = MaxApprovals; - type SpendOrigin = NeverEnsureOrigin; -} - impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; From f881d43c1d269bf46e1763e4e3d629bf9bd2c938 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jun 2023 13:47:50 +0200 Subject: [PATCH 09/11] formatting --- runtime/basilisk/src/governance.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/basilisk/src/governance.rs b/runtime/basilisk/src/governance.rs index 19cbb2c5274..6e315c9fe91 100644 --- a/runtime/basilisk/src/governance.rs +++ b/runtime/basilisk/src/governance.rs @@ -24,7 +24,7 @@ use primitives::constants::{ use frame_support::{ parameter_types, sp_runtime::{Perbill, Percent, Permill}, - traits::{EitherOfDiverse, NeverEnsureOrigin, EqualPrivilegeOnly, LockIdentifier, U128CurrencyToVote}, + traits::{EitherOfDiverse, EqualPrivilegeOnly, LockIdentifier, NeverEnsureOrigin, U128CurrencyToVote}, PalletId, }; use frame_system::EnsureRoot; @@ -259,4 +259,4 @@ impl pallet_treasury::Config for Runtime { type SpendFunds = (); type MaxApprovals = MaxApprovals; type SpendOrigin = NeverEnsureOrigin; -} \ No newline at end of file +} From f90b3a4bed84f2fcca11b461c73111cdda229a2a Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Sun, 11 Jun 2023 13:37:31 +0200 Subject: [PATCH 10/11] polishing --- runtime/basilisk/src/assets.rs | 72 ++++++++------------ runtime/basilisk/src/governance.rs | 70 +++++++++----------- runtime/basilisk/src/lib.rs | 4 +- runtime/basilisk/src/system.rs | 103 ++++++++++++----------------- runtime/basilisk/src/xcm.rs | 2 +- 5 files changed, 107 insertions(+), 144 deletions(-) diff --git a/runtime/basilisk/src/assets.rs b/runtime/basilisk/src/assets.rs index 667c9f5264b..d0e466abfac 100644 --- a/runtime/basilisk/src/assets.rs +++ b/runtime/basilisk/src/assets.rs @@ -54,7 +54,6 @@ impl Get for RelayChainAssetId { type KusamaCurrency = CurrencyAdapter; -// pallet balances parameter_types! { pub const NativeExistentialDeposit: u128 = NATIVE_EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; @@ -62,20 +61,19 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; /// The type for recording an account's balance. type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; type DustRemoval = Treasury; + type RuntimeEvent = RuntimeEvent; + /// The ubiquitous event type. type ExistentialDeposit = NativeExistentialDeposit; type AccountStore = System; type WeightInfo = weights::balances::BasiliskWeight; + type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = (); } -// pallet orml tokens pub struct CurrencyHooks; impl MutationHooks for CurrencyHooks { type OnDust = Duster; @@ -102,11 +100,11 @@ impl orml_tokens::Config for Runtime { type CurrencyId = AssetId; type WeightInfo = weights::tokens::BasiliskWeight; type ExistentialDeposits = AssetRegistry; + type CurrencyHooks = CurrencyHooks; type MaxLocks = MaxLocks; type MaxReserves = MaxReserves; type ReserveIdentifier = (); type DustRemovalWhitelist = DustRemovalWhitelist; - type CurrencyHooks = CurrencyHooks; } // The latest versions of the orml-currencies pallet don't emit events. @@ -120,7 +118,6 @@ impl pallet_currencies::Config for Runtime { type WeightInfo = weights::currencies::BasiliskWeight; } -// pallet asset registry parameter_types! { pub const SequentialIdOffset: u32 = 1_000_000; } @@ -136,7 +133,6 @@ impl pallet_asset_registry::Config for Runtime { type WeightInfo = weights::asset_registry::BasiliskWeight; } -// pallet duster parameter_types! { pub const DustingReward: u128 = 0; } @@ -154,17 +150,6 @@ impl pallet_duster::Config for Runtime { type WeightInfo = weights::duster::BasiliskWeight; } -// pallet xyk -parameter_types! { - pub ExchangeFee: (u32, u32) = (3, 1_000); - pub const MinTradingLimit: Balance = MIN_TRADING_LIMIT; - pub const MinPoolLiquidity: Balance = MIN_POOL_LIQUIDITY; - pub const MaxInRatio: u128 = MAX_IN_RATIO; - pub const MaxOutRatio: u128 = MAX_OUT_RATIO; - pub const RegistryStrLimit: u32 = 32; - pub const DiscountedFee: (u32, u32) = DISCOUNTED_FEE; -} - pub struct AssetPairAccountId(PhantomData); impl AssetPairAccountIdFor for AssetPairAccountId where @@ -184,6 +169,16 @@ where } } +parameter_types! { + pub ExchangeFee: (u32, u32) = (3, 1_000); + pub const MinTradingLimit: Balance = MIN_TRADING_LIMIT; + pub const MinPoolLiquidity: Balance = MIN_POOL_LIQUIDITY; + pub const MaxInRatio: u128 = MAX_IN_RATIO; + pub const MaxOutRatio: u128 = MAX_OUT_RATIO; + pub const RegistryStrLimit: u32 = 32; + pub const DiscountedFee: (u32, u32) = DISCOUNTED_FEE; +} + impl pallet_xyk::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AssetRegistry = AssetRegistry; @@ -202,11 +197,6 @@ impl pallet_xyk::Config for Runtime { type NonDustableWhitelistHandler = Duster; } -// pallet lbp -parameter_types! { - pub LBPExchangeFee: (u32, u32) = (2, 1_000); -} - pub struct MultiCurrencyLockedBalance(PhantomData); impl @@ -237,6 +227,10 @@ where } } +parameter_types! { + pub LBPExchangeFee: (u32, u32) = (2, 1_000); +} + impl pallet_lbp::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; @@ -244,21 +238,14 @@ impl pallet_lbp::Config for Runtime { type CreatePoolOrigin = SuperMajorityTechCommitteeOrRoot; type LBPWeightFunction = pallet_lbp::LBPWeightFunction; type AssetPairAccountId = AssetPairAccountId; + type WeightInfo = weights::lbp::BasiliskWeight; type MinTradingLimit = MinTradingLimit; type MinPoolLiquidity = MinPoolLiquidity; type MaxInRatio = MaxInRatio; type MaxOutRatio = MaxOutRatio; - type WeightInfo = weights::lbp::BasiliskWeight; type BlockNumberProvider = RelayChainBlockNumberProvider; } -// pallet vesting -parameter_types! { - pub MinVestedTransfer: Balance = 100_000; - pub const MaxVestingSchedules: u32 = 15; - pub const VestingPalletId: PalletId = PalletId(*b"py/vstng"); -} - pub struct RootAsVestingPallet; impl EnsureOrigin for RootAsVestingPallet { type Success = AccountId; @@ -278,6 +265,12 @@ impl EnsureOrigin for RootAsVestingPallet { } } +parameter_types! { + pub MinVestedTransfer: Balance = 100_000; + pub const MaxVestingSchedules: u32 = 15; + pub const VestingPalletId: PalletId = PalletId(*b"py/vstng"); +} + impl orml_vesting::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -288,7 +281,6 @@ impl orml_vesting::Config for Runtime { type BlockNumberProvider = RelayChainBlockNumberProvider; } -// pallet marketplace parameter_types! { pub const MinimumOfferAmount: Balance = UNITS / 100; pub const RoyaltyBondAmount: Balance = 0; @@ -314,7 +306,6 @@ pub mod ksm { } } -// pallet uniques parameter_types! { pub const CollectionDeposit: Balance = 0; pub const ItemDeposit: Balance = 0; @@ -342,12 +333,11 @@ impl pallet_uniques::Config for Runtime { type StringLimit = primitives::UniquesStringLimit; type KeyLimit = KeyLimit; type ValueLimit = ValueLimit; - type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = (); + type WeightInfo = (); } -// pallet liquidity mining parameter_types! { pub const LMPalletId: PalletId = PalletId(*b"LiqMinId"); pub const LiquidityMiningNftCollectionId: primitives::CollectionId = 1; @@ -356,17 +346,16 @@ parameter_types! { impl pallet_xyk_liquidity_mining::Config for Runtime { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currencies; + type AMM = XYK; type CreateOrigin = UnanimousTechCommitteeOrRoot; type PalletId = LMPalletId; type NftCollectionId = LiquidityMiningNftCollectionId; - type AMM = XYK; - type WeightInfo = weights::xyk_liquidity_mining::BasiliskWeight; type NFTHandler = NFT; type LiquidityMiningHandler = XYKWarehouseLM; type NonDustableWhitelistHandler = Duster; + type WeightInfo = weights::xyk_liquidity_mining::BasiliskWeight; } -// warehouse pallet liquidity mining parameter_types! { pub const WarehouseLMPalletId: PalletId = PalletId(*b"WhouseLm"); pub const MaxEntriesPerDeposit: u8 = 5; //NOTE: Rebenchmark when this change, TODO: @@ -377,6 +366,7 @@ parameter_types! { type XYKLiquidityMiningInstance = warehouse_liquidity_mining::Instance1; impl warehouse_liquidity_mining::Config for Runtime { + type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; type MultiCurrency = Currencies; type PalletId = WarehouseLMPalletId; @@ -388,11 +378,9 @@ impl warehouse_liquidity_mining::Config for Runtime type MaxYieldFarmsPerGlobalFarm = MaxYieldFarmsPerGlobalFarm; type AssetRegistry = AssetRegistry; type NonDustableWhitelistHandler = Duster; - type RuntimeEvent = RuntimeEvent; type PriceAdjustment = warehouse_liquidity_mining::DefaultPriceAdjustment; } -// pallet route executor parameter_types! { pub const MaxNumberOfTrades: u8 = 5; } @@ -407,7 +395,6 @@ impl pallet_route_executor::Config for Runtime { type WeightInfo = weights::route_executor::BasiliskWeight; } -// pallet ema oracle parameter_types! { pub SupportedPeriods: BoundedVec> = BoundedVec::truncate_from( vec![OraclePeriod::LastBlock, OraclePeriod::Hour, OraclePeriod::Day, OraclePeriod::Week] @@ -425,7 +412,6 @@ impl pallet_ema_oracle::Config for Runtime { type MaxUniqueEntries = MaxUniqueOracleEntries; } -// pallet nft parameter_types! { pub ReserveCollectionIdUpTo: u128 = 999_999; } diff --git a/runtime/basilisk/src/governance.rs b/runtime/basilisk/src/governance.rs index 6e315c9fe91..62f25c8981a 100644 --- a/runtime/basilisk/src/governance.rs +++ b/runtime/basilisk/src/governance.rs @@ -30,7 +30,19 @@ use frame_support::{ use frame_system::EnsureRoot; use pallet_collective::EnsureProportionAtLeast; -// pallet democracy +pub type MajorityCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type UnanimousCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type SuperMajorityCouncilOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type SuperMajorityTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type UnanimousTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; +pub type MajorityTechCommitteeOrRoot = + EitherOfDiverse, EnsureRoot>; + parameter_types! { pub const LaunchPeriod: BlockNumber = 3 * DAYS; pub const VotingPeriod: BlockNumber = 3 * DAYS; @@ -45,26 +57,24 @@ parameter_types! { pub const MaxProposals: u32 = 100; } -pub type MajorityCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -pub type UnanimousCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -pub type SuperMajorityCouncilOrRoot = - EitherOfDiverse, EnsureRoot>; -pub type SuperMajorityTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; -pub type UnanimousTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; -pub type MajorityTechCommitteeOrRoot = - EitherOfDiverse, EnsureRoot>; - impl pallet_democracy::Config for Runtime { + type WeightInfo = weights::democracy::BasiliskWeight; type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Preimages = Preimage; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = VoteLockingPeriod; type MinimumDeposit = MinimumDeposit; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + type CooloffPeriod = CooloffPeriod; + type MaxVotes = MaxVotes; + type MaxProposals = MaxProposals; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; /// A straight majority of the council can decide what their next motion is. type ExternalOrigin = MajorityCouncilOrRoot; /// A majority can have the next scheduled referendum be a straight majority-carries vote @@ -76,31 +86,19 @@ impl pallet_democracy::Config for Runtime { /// be tabled immediately and with a shorter voting/enactment period. type FastTrackOrigin = MajorityTechCommitteeOrRoot; type InstantOrigin = UnanimousTechCommitteeOrRoot; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. type CancellationOrigin = SuperMajorityCouncilOrRoot; + type BlacklistOrigin = EnsureRoot; // To cancel a proposal before it has been passed, the technical committee must be unanimous or // Root must agree. type CancelProposalOrigin = UnanimousTechCommitteeOrRoot; - type BlacklistOrigin = EnsureRoot; // Any single technical committee member may veto a coming council proposal, however they can // only do it once and it lasts only for the cooloff period. type VetoOrigin = pallet_collective::EnsureMember; - type CooloffPeriod = CooloffPeriod; - type Slash = Treasury; - type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type WeightInfo = weights::democracy::BasiliskWeight; - type MaxProposals = MaxProposals; - type Preimages = Preimage; - type MaxDeposits = ConstU32<100>; - type MaxBlacklisted = ConstU32<100>; - type VoteLockingPeriod = VoteLockingPeriod; + type Slash = Treasury; } -// pallet elections phragmen parameter_types! { // Bond for candidacy into governance pub const CandidacyBond: Balance = 5 * DOLLARS; @@ -136,7 +134,6 @@ impl pallet_elections_phragmen::Config for Runtime { type WeightInfo = (); } -// pallet collective - council collective parameter_types! { pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; pub const CouncilMaxProposals: u32 = 13; @@ -155,7 +152,6 @@ impl pallet_collective::Config for Runtime { type WeightInfo = (); } -// pallet collective - technical collective parameter_types! { pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; pub const TechnicalMaxProposals: u32 = 20; @@ -174,7 +170,6 @@ impl pallet_collective::Config for Runtime { type WeightInfo = (); } -// pallet tips parameter_types! { pub const DataDepositPerByte: Balance = CENTS; pub const TipCountdown: BlockNumber = 2 * HOURS; @@ -186,16 +181,15 @@ parameter_types! { impl pallet_tips::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type DataDepositPerByte = DataDepositPerByte; type MaximumReasonLength = MaximumReasonLength; - type Tippers = Elections; + type DataDepositPerByte = DataDepositPerByte; type TipCountdown = TipCountdown; type TipFindersFee = TipFindersFee; type TipReportDepositBase = TipReportDepositBase; + type Tippers = Elections; type WeightInfo = (); } -// pallet preimage parameter_types! { pub const PreimageMaxSize: u32 = 4096 * 1024; pub PreimageBaseDeposit: Balance = deposit(2, 64); @@ -203,15 +197,14 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = (); type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); type Currency = Balances; type ManagerOrigin = EnsureRoot; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } -// pallet scheduler parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(10) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 50; @@ -224,13 +217,12 @@ impl pallet_scheduler::Config for Runtime { type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; + type OriginPrivilegeCmp = EqualPrivilegeOnly; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::scheduler::BasiliskWeight; - type OriginPrivilegeCmp = EqualPrivilegeOnly; type Preimages = Preimage; } -// pallet treasury parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(3); pub const ProposalBondMinimum: Balance = 100 * DOLLARS; @@ -243,7 +235,6 @@ parameter_types! { } impl pallet_treasury::Config for Runtime { - type PalletId = TreasuryPalletId; type Currency = Balances; type ApproveOrigin = SuperMajorityCouncilOrRoot; type RejectOrigin = MajorityCouncilOrRoot; @@ -254,6 +245,7 @@ impl pallet_treasury::Config for Runtime { type ProposalBondMaximum = ProposalBondMaximum; type SpendPeriod = SpendPeriod; type Burn = Burn; + type PalletId = TreasuryPalletId; type BurnDestination = (); type WeightInfo = weights::treasury::BasiliskWeight; type SpendFunds = (); diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 73556676d1f..c5eae731247 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -46,7 +46,9 @@ pub use governance::*; pub use system::*; pub use xcm::*; -pub use primitives::{AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Signature}; +pub use primitives::{ + AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Price, Signature, +}; use frame_support::sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 00a72ca962d..7795548b95a 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -40,8 +40,6 @@ use frame_support::{ }; use scale_info::TypeInfo; -// frame system - /// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic /// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); @@ -49,18 +47,42 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); /// by Operational extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +pub struct BaseFilter; +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { + if matches!( + call, + RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_) + ) { + // always allow + // Note: this is done to avoid unnecessary check of paused storage. + return true; + } + + if pallet_transaction_pause::PausedTransactionFilter::::contains(call) { + // if paused, dont allow! + return false; + } + + match call { + RuntimeCall::Uniques(_) => false, + RuntimeCall::PolkadotXcm(_) => false, + RuntimeCall::OrmlXcm(_) => false, + _ => true, + } + } +} + parameter_types! { pub const BlockHashCount: BlockNumber = 250; /// Maximum length of block. Up to 5MB. pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u16 = 10041; - /// Basilisk base weight of an extrinsic /// This includes weight for payment in non-native currency. // Default substrate base weight is 125 * WEIGHT_PER_MICROS pub const BasiliskExtrinsicBaseWeight: Weight = Weight::from_ref_time(200 * WEIGHT_REF_TIME_PER_MICROS); - pub const Version: RuntimeVersion = VERSION; /// Block weights base values and limits. pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() @@ -81,36 +103,9 @@ parameter_types! { }) .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - pub ExtrinsicBaseWeight: Weight = BasiliskExtrinsicBaseWeight::get(); } -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &RuntimeCall) -> bool { - if matches!( - call, - RuntimeCall::System(_) | RuntimeCall::Timestamp(_) | RuntimeCall::ParachainSystem(_) - ) { - // always allow - // Note: this is done to avoid unnecessary check of paused storage. - return true; - } - - if pallet_transaction_pause::PausedTransactionFilter::::contains(call) { - // if paused, dont allow! - return false; - } - - match call { - RuntimeCall::Uniques(_) => false, - RuntimeCall::PolkadotXcm(_) => false, - RuntimeCall::OrmlXcm(_) => false, - _ => true, - } - } -} - impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = BaseFilter; @@ -161,7 +156,6 @@ impl frame_system::Config for Runtime { type MaxConsumers = frame_support::traits::ConstU32<16>; } -// pallet timestamp parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; pub const NativeAssetId : AssetId = CORE_ASSET_ID; @@ -175,22 +169,6 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = weights::timestamp::BasiliskWeight; } -// pallet transaction payment -parameter_types! { - pub const TransactionByteFee: Balance = 10 * MILLICENTS; - /// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less - /// than this will decrease the weight and more will increase. - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to - /// change the fees more rapidly. - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(6, 100_000); - /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure - /// that combined with `AdjustmentVariable`, we can recover from the minimum. - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); - /// Maximum amount of the multiplier. - pub MaximumMultiplier: Multiplier = Multiplier::saturating_from_integer(4); -} - pub struct WeightToFee; impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; @@ -222,6 +200,21 @@ impl WeightToFeePolynomial for WeightToFee { pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; +parameter_types! { + pub const TransactionByteFee: Balance = 10 * MILLICENTS; + /// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less + /// than this will decrease the weight and more will increase. + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + /// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to + /// change the fees more rapidly. + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(6, 100_000); + /// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure + /// that combined with `AdjustmentVariable`, we can recover from the minimum. + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); + /// Maximum amount of the multiplier. + pub MaximumMultiplier: Multiplier = Multiplier::saturating_from_integer(4); +} + impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = TransferFees, TreasuryAccount>; @@ -231,7 +224,6 @@ impl pallet_transaction_payment::Config for Runtime { type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } -// pallet transaction multi payment impl pallet_transaction_multi_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AcceptedCurrencyOrigin = MajorityTechCommitteeOrRoot; @@ -242,7 +234,6 @@ impl pallet_transaction_multi_payment::Config for Runtime { type NativeAssetId = NativeAssetId; } -// pallet proxy /// The type used to represent the kinds of proxying allowed. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub enum ProxyType { @@ -315,7 +306,6 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } -// cumulus pallet parachain system parameter_types! { pub ReservedXcmpWeight: Weight = BlockWeights::get().max_block / 4; pub ReservedDmpWeight: Weight = BlockWeights::get().max_block / 4; @@ -333,7 +323,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; } -// pallet aura parameter_types! { pub const MaxAuthorities: u32 = 50; } @@ -347,11 +336,10 @@ impl pallet_aura::Config for Runtime { impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; - type WeightInfo = weights::utility::BasiliskWeight; type PalletsOrigin = OriginCaller; + type WeightInfo = weights::utility::BasiliskWeight; } -// pallet authorship parameter_types! { pub const UncleGenerations: u32 = 0; } @@ -361,7 +349,6 @@ impl pallet_authorship::Config for Runtime { type EventHandler = (CollatorSelection,); } -// pallet collator selection parameter_types! { pub const PotId: PalletId = PalletId(*b"PotStake"); pub const MaxCandidates: u32 = 20; @@ -385,7 +372,6 @@ impl pallet_collator_selection::Config for Runtime { type WeightInfo = weights::collator_selection::BasiliskWeight; } -// pallet session parameter_types! { pub const Period: u32 = 4 * HOURS; pub const Offset: u32 = 0; @@ -420,7 +406,6 @@ impl pallet_transaction_pause::Config for Runtime { type WeightInfo = weights::transaction_pause::BasiliskWeight; } -// pallet collator rewards parameter_types! { pub const RewardPerCollator: Balance = 15_216_000_000_000_000; // 12.68[BSX/block] * 1200[block] //GalacticCouncil collators @@ -436,14 +421,13 @@ impl pallet_collator_rewards::Config for Runtime { type CurrencyId = AssetId; type Currency = Currencies; type RewardPerCollator = RewardPerCollator; - type ExcludedCollators = ExcludedCollators; type RewardCurrencyId = NativeAssetId; + type ExcludedCollators = ExcludedCollators; // We wrap the ` SessionManager` implementation of `CollatorSelection` to get the collatrs that // we hand out rewards to. type SessionManager = CollatorSelection; } -// pallet identity parameter_types! { pub const BasicDeposit: Balance = 5 * DOLLARS; pub const FieldDeposit: Balance = DOLLARS; @@ -468,7 +452,6 @@ impl pallet_identity::Config for Runtime { type WeightInfo = (); } -// pallet multisig parameter_types! { pub DepositBase: Balance = deposit(1, 88); pub DepositFactor: Balance = deposit(0, 32); diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index efce77d7bd8..b415f623c84 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -33,7 +33,7 @@ use pallet_transaction_multi_payment::DepositAll; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use polkadot_xcm::v3::{prelude::*, Error, MultiLocation, Weight as XcmWeight}; -use primitives::{AssetId, Price}; +use primitives::AssetId; use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; From 5316b5f13c0d827c391689a1b504f612ff64a6d0 Mon Sep 17 00:00:00 2001 From: mrq Date: Sat, 24 Jun 2023 14:51:55 +0200 Subject: [PATCH 11/11] runtime 103 --- .github/workflows/workflow.yml | 2 +- Cargo.lock | 22 +++++++++++----------- runtime/basilisk/Cargo.toml | 2 +- runtime/basilisk/src/lib.rs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 73cc27c322c..512382f3ab6 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -38,7 +38,7 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v1 with: - fail_ci_if_error: true + fail_ci_if_error: false - name: Build runtime run: cargo build --release --locked working-directory: runtime/basilisk diff --git a/Cargo.lock b/Cargo.lock index e2ae810824c..51918b9bca5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -612,17 +612,17 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "102.0.0" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", +version = "103.0.0" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", "frame-benchmarking", "frame-executive", "frame-support", diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 8affe2bbb3a..2a6c2032bc2 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk-runtime" -version = "102.0.0" +version = "103.0.0" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index c5eae731247..284ad1b0ed1 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -94,7 +94,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 102, + spec_version: 103, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1,